Class JFrameRegistrationMosaic

All Implemented Interfaces:
AlgorithmInterface, ActionListener, MouseListener, MouseMotionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants

public class JFrameRegistrationMosaic extends JFrame implements ActionListener, MouseListener, MouseMotionListener, AlgorithmInterface
JFrameRegistrationMosaic is a window/gui that enables the user to manually align two images with the mouse and then call the AlgorithmRegOAR2D registration algorithm to create a mosaic image with the two aligned images. Multiple images can be added to the mosaic and aligned one at a time.
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Use serialVersionUID for interoperability.
      See Also:
    • m_aabReference

      private boolean[][] m_aabReference
      For masking, set to true if the reference image is written into the same location:.
    • m_aabReferenceBackup

      private boolean[][] m_aabReferenceBackup
      backup:.
    • m_akBackupBorders

      private javax.media.j3d.Shape3D[] m_akBackupBorders
      Backup shape for Undo:.
    • m_akBackupImages

      private ModelImage[] m_akBackupImages
      Backup Image for Undo:.
    • m_akBackupPolygons

      private javax.media.j3d.Shape3D[] m_akBackupPolygons
      Backup shape for Undo:.
    • m_akBackupTG

      private javax.media.j3d.TransformGroup[] m_akBackupTG
      Backup Transform for Undo:.
    • m_akBorderShapes

      private javax.media.j3d.Shape3D[] m_akBorderShapes
      Reference to the border shape data structure for changing the color based on which image is selected:.
    • m_akImages

      private ModelImage[] m_akImages
      Reference to the model images:.
    • m_akImageTransforms

      private javax.media.j3d.TransformGroup[] m_akImageTransforms
      Reference and tile image transformations:.
    • m_akPolygonShapes

      private javax.media.j3d.Shape3D[] m_akPolygonShapes
      Reference to the texture-mapped polygon on which the image is displayed:.
    • m_bBruteForce

      private boolean m_bBruteForce
      Brute force default is off:.
    • m_bDisplayTransform

      private boolean m_bDisplayTransform
      Display transfromed image in separate window: set to false (no display).
    • m_bDoSubsample

      private boolean m_bDoSubsample
      Default subsample set to true:.
    • m_bDoMultiThread

      private boolean m_bDoMultiThread
    • m_bFileLoaded

      private boolean m_bFileLoaded
      Boolean to check that a file is loaded before mouse operations are allowed to occur.
    • m_bFirst

      private boolean m_bFirst
      For blending the reference and tile images, reference image is not blended with background, reset when initData() is called.
    • m_bResetAlpha

      private boolean m_bResetAlpha
      To reset m_kReferenceAlpha:.
    • m_bSetScale

      private boolean m_bSetScale
      True when scale factor should be used:.
    • m_fCoarseRate

      private float m_fCoarseRate
      Default rotation coarse rate, set to 2 degrees:.
    • m_fFineRate

      private float m_fFineRate
      Default rotation fine rate, set to 1 degree:.
    • m_fRotateBegin

      private float m_fRotateBegin
      Default rotation start, set to negative 5 degrees:.
    • m_fRotateEnd

      private float m_fRotateEnd
      Default rotation end, set to postive 5 degrees:.
    • m_fRotationRange

      private float m_fRotationRange
      default rotation range (0).
    • m_fScale

      private float m_fScale
      Scale factor for large images:.
    • m_fXScaleRange

      private float m_fXScaleRange
      default x scale range (0).
    • m_fYScaleRange

      private float m_fYScaleRange
      default y scale range (0).
    • m_iCost

      private int m_iCost
      Default cost function, set to correlation ratio (smoothed, weighted):.
    • m_iDOF

      private int m_iDOF
      Default degrees of freedom:.
    • m_iInterp

      private int m_iInterp
      Default image interpolation, set to be bilinear interpolation:.
    • m_iInterp2

      private int m_iInterp2
      Default interpolation for the transform algorithm:.
    • m_iMaxIterations

      private int m_iMaxIterations
      Default number of iteration set to 2:.
    • m_iNumMinima

      private int m_iNumMinima
      Default number of minima to test from level 8 at level 4 (set to 3):.
    • m_iOpen

      private int m_iOpen
      index of the non-selected image:.
    • m_iOpenSave

      private int m_iOpenSave
      Backup of the open index:.
    • m_iReference

      private int m_iReference
      Index of the reference image:.
    • m_iReferenceSave

      private int m_iReferenceSave
      Backup of the reference index:.
    • m_iScaleSteps

      private int m_iScaleSteps
      default number of divisions for scale optimazation:.
    • m_iSelected

      private int m_iSelected
      index of the selected image:
    • m_iTile

      private int m_iTile
      Index of the tile image:.
    • m_iTranslationRange

      private int m_iTranslationRange
      default x,y translation range (0).
    • m_iXClick

      private int m_iXClick
      x,y positions of the mouse when one of the mouse buttons is pressed:.
    • m_iYClick

      private int m_iYClick
      x,y positions of the mouse when one of the mouse buttons is pressed:.
    • m_kAdvancedOptionsButton

      private JButton m_kAdvancedOptionsButton
      Launches the JDialogRegistrationOAR2D dialog to set registration options:.
    • m_kCanvas

      private javax.media.j3d.Canvas3D m_kCanvas
      Drawing canvas:.
    • m_kCloseAllButton

      private JButton m_kCloseAllButton
      Close all images and remove them from the scene:.
    • m_kCurrentTransform

      private javax.media.j3d.Transform3D m_kCurrentTransform
      current transformation based on mouseDragged event:.
    • m_kMouseEvent

      private MouseEvent m_kMouseEvent
      Reference to the mousePressed event:.
    • m_kOldTransform

      private javax.media.j3d.Transform3D m_kOldTransform
      Accumulated transformation prior to current mouseDrag:.
    • m_kOpenReferenceButton

      private JButton m_kOpenReferenceButton
      Open reference image:.
    • m_kOpenTileButton

      private JButton m_kOpenTileButton
      Open tile image:.
    • m_kReferenceAlpha

      private ModelImage m_kReferenceAlpha
      For blending between refernce and transformed tile images:.
    • m_kReferenceAlphaBackup

      private ModelImage m_kReferenceAlphaBackup
      For blending between refernce and transformed tile images:.
    • m_kRegisterButton

      private JButton m_kRegisterButton
      Initialize and start the registration based on how the user positioned the two images:.
    • m_kSaveButton

      private JButton m_kSaveButton
      Save the mosaic image:.
    • m_kHelpButton

      private JButton m_kHelpButton
      Open the mosaic image help.
    • m_kScene

      private javax.media.j3d.BranchGroup m_kScene
      Scene graph root node:.
    • m_kTileAlpha

      private ModelImage m_kTileAlpha
      For blending between refernce and transformed tile images:.
    • m_kToggleSelectedButton

      private JButton m_kToggleSelectedButton
      Toggle which image is currently selected:.
    • m_kUndoButton

      private JButton m_kUndoButton
      Undo the last registration for the mosaic image:.
    • m_kUniverse

      private com.sun.j3d.utils.universe.SimpleUniverse m_kUniverse
      SimpleUniverse:.
  • Constructor Details

    • JFrameRegistrationMosaic

      public JFrameRegistrationMosaic()
      JFrameRegistrationMosaic - Creates new window for manual (mouse-based) registration of two images.
  • Method Details

    • actionPerformed

      public void actionPerformed(ActionEvent event)
      actionPerformed - JButton events:
      Specified by:
      actionPerformed in interface ActionListener
      Parameters:
      event - button event
    • repaintButtons

      private void repaintButtons()
    • algorithmPerformed

      public void algorithmPerformed(AlgorithmBase kAlgorithm)
      algorithmPerformed - when the alignment algorithm finishes, the transformed tile is blended with the reference image and displayed:
      Specified by:
      algorithmPerformed in interface AlgorithmInterface
      Parameters:
      kAlgorithm - AlgorithmBase
    • dispose

      public void dispose()
      dispose - Removes member variables.
      Overrides:
      dispose in class Window
    • getVariablesFromDialog

      public void getVariablesFromDialog(JDialogRegistrationOAR2D kOptionsDialog, boolean bCallAlgorithm)
      Called from inside the JDialogRegistrationOAR2D class when the user has set the parameters and closes the dialog.
      Parameters:
      kOptionsDialog - the JDialogRegistrationOAR2D object containing the updated registration parameters
      bCallAlgorithm - boolean when true this function activates the registration algorithm, when false, the user must then press the "register images" button to register.
    • mouseClicked

      public void mouseClicked(MouseEvent e)
      mouseClicked.
      Specified by:
      mouseClicked in interface MouseListener
      Parameters:
      e - MouseEvent
    • mouseDragged

      public void mouseDragged(MouseEvent e)
      mouseDragged.
      Specified by:
      mouseDragged in interface MouseMotionListener
      Parameters:
      e - MouseEvent
    • mouseEntered

      public void mouseEntered(MouseEvent e)
      mouseEntered.
      Specified by:
      mouseEntered in interface MouseListener
      Parameters:
      e - MouseEvent
    • mouseExited

      public void mouseExited(MouseEvent e)
      mouseExited.
      Specified by:
      mouseExited in interface MouseListener
      Parameters:
      e - MouseEvent
    • mouseMoved

      public void mouseMoved(MouseEvent e)
      mouseMoved.
      Specified by:
      mouseMoved in interface MouseMotionListener
      Parameters:
      e - MouseEvent
    • mousePressed

      public void mousePressed(MouseEvent kMouseEvent)
      mousePressed, store the current transformation for the selected image so the new transformations calculated in the mouseDragged function can be concatenated onto the current transform.
      Specified by:
      mousePressed in interface MouseListener
      Parameters:
      kMouseEvent - MouseEvent
    • mouseReleased

      public void mouseReleased(MouseEvent e)
      mouseReleased.
      Specified by:
      mouseReleased in interface MouseListener
      Parameters:
      e - MouseEvent
    • backupMosaic

      private void backupMosaic()
      backupMosaic -- Backs up the reference invalid input: '&' tile polygon shapes, borders, ModelImages, and TransformGroups before the registration is called, so that registration can be undone by the user:
    • closeAllImages

      private void closeAllImages(boolean bResetAlpha)
      closeAllImages -- clears the scenegraph of all displayed images and deletes references to the images:
      Parameters:
      bResetAlpha - true if all images are closed, false if a new mosaic is created
    • createCanvas

      private javax.media.j3d.Canvas3D createCanvas(JPanel kPanel)
      createCanvas - Creates the Canvas3D for rendering the images.
      Parameters:
      kPanel - the JPanel that contains the Canvas3D in the frame
      Returns:
      Canvas3D the new canvas
    • createMosaicOpenDialog

      private boolean createMosaicOpenDialog(boolean bSave)
      createMosaicOpenDialog - Creates a file open dialog for image files (.jpg, tiff, etc.). If a new file is opened it is mapped onto a polygon and placed in the scene graph:
      Parameters:
      bSave - open file for saving (true) or open file for reading (false)
      Returns:
      boolean, success or failure for the file open
    • createTexturedPolygon

      private void createTexturedPolygon(javax.media.j3d.TransformGroup kTransformGroup, BufferedImage kImage, int iWidth, int iHeight, int iWidthPow2, int iHeightPow2)
      createTexturedPolygon - Creates a texture-mapped polygon with the BufferedImage displayed as the texture. The texture-mapped polygon is created so that the displayed texture and size of the polygon match the size in pixels of the original image loaded from file -- even when the original image size is not a power of two. The displayed image must match the original data image so that the registration is accurate.
      Parameters:
      kTransformGroup - the TransformGroup which will contain the new textured polygon in the scene graph
      kImage - the BufferedImage, power or two size image, padded if necessary, containing the original image data.
      iWidth - the original image width
      iHeight - the original image height
      iWidthPow2 - the next-largest power of two width
      iHeightPow2 - the next-largest power of two height
    • initData

      private void initData()
      initData -- Initializes the selected, open, reference and tile indexes. Called on startup and after a closeAllImages()
    • initGUI

      private void initGUI()
      initGUI - Initializes GUI toolbar and buttons and displays the registration window.
    • registerImages

      private boolean registerImages()
      registerImages - Registers the reference and tile images based on the how the user positions the images with the mouse. Two new registered images are created, each containing one registered sub-image. The AlgorithmRegOAR2D is then called on the two new registered images, to better refine the registration. Upon completion of the registration algorithm, a new mosaic image is created.
      Returns:
      boolean, sucess/failure of registeration
    • saveMosaic

      private boolean saveMosaic()
      saveMosaic -- Opens a save dialog and saves the mosaic image in the selected file format.
      Returns:
      boolean, sucess/failure of file save
    • storeImage

      private void storeImage(ModelImage kImage)
      storeImage - creates a BufferedImage from the ModelImage data where the BufferedImage's size is the next-largest power of two from the ModelImage size. The BufferedImage is then passed to the createTexturedPolygon function for display in the scene graph.
      Parameters:
      kImage - the input ModelImage containing the image data.
    • toggleSelectedImage

      private void toggleSelectedImage()
      toggleSelectedImage - Toggles which image is currently selected. Changes the color of the image borders.
    • undoMosaic

      private void undoMosaic()
      undoMosaic -- Restores the backed-up ImageTransforms, PolygonShapes, BorderShapes, and ModelImages after an undo button press: