Manual image registration

Manual image registration tool


The manual image registration tool is available in the DataViewer app. The tool allows one to interactively align an image from a .dat file to a reference image. The geometric transformations are then applied to the misaligned .dat file.

Important
If you are using the umIToolbox app, click here to access the old manual aligment tool. This tool will be deprecated in a later version of the umIT toolbox.

Sections

Interface components

Options panel

  • Image sharpening:
    • None: No sharpening
    • Enhance Contrast: Enhances the contrast of both images using the adapthisteq function
    • Gaussian Filter:
    • Equivalent of an unsharp masking where two spatially filtered version of the images are subtracted. The operation consists of a filtered image with a sigma of .5 minus a blurred version of the image
  • Flip horizontally: Mirrors the moving image
  • Invert colors: Invert colors of both images
  • Fixed aspect ratio: Unckeck this box to scale X or Y axes independently
  • Display result as:
    • FalseColor: Composite of green (reference) and magenta (moving)
    • Reference: Displays reference image
    • Moving: Displays moving image
    • Difference: Shows the difference of the moving and reference images
    • Alternate view: Alternates between the reference and moving images

Fine tuning

Click on the Fine tuning button to show/hide the panel.
Here, one can set custom steps and move the misaligned frame incrementally by clicking on the up/down arrows. This is useful to perform small movements otherwise challenging with the mouse cursor.

Align

Applies the coregistration to the misaligned .dat file.

A tform.mat file will also be saved in the .dat file's directory containing the geometric transformation affine2d object.

Save geometric transformation object:

Important
This section is disabled for when the app is deployed as executable.


  • Save to a .mat file: Saves the geometric transformation object (tform) to a .mat file
  • workspace: Saves the tform to the Matlab's base workspace

Saves the affine2d object with the geometric transformation to a .mat file.

Using from DataViewer

Follow these steps for aligning data open in the DataViewer app.

  1. Open the image to be aligned in DataViewer.

    dataviewer_manual_alignment_fig1


  2. Then go to Utilities → Manual Coregistration to launch the tool. Note that a frame from the current data is set as the Misaligned file (in magenta)

    dataviewer_manual_alignment_fig2


  3. Select the reference file/frame (in green). Here, one can use an image from Matlab's workspace or directly from a .dat file.

    dataviewer_manual_alignment_fig3

  4. Once the reference and the misaligned images are loaded, the options panel becomes visible and one can use the mouse cursor to align the frame (in magenta). See the Options section for a description of the available options to help with the coregistration.

    Tip
    Use the fine tuning panel to perform small and precise adjustments to the coregistration. In the panel, select the movement, the step resolution and click on the up/down arrows to move the image.

  5. Once the moving image (magenta) is placed in the optimal position, click on the Align button to apply to the misaligned data.

Using as standalone


Important
This section does not apply to app deployed as executable.

This tool can also be used as a standalone in Matlab. In this mode, one can use either .dat files or images from Matlab's workspace. Here are the different ways of launching the app as standalone from Matlab command window:

  • manualAlignFrames(); Launches the inteface. Use the Loading options in the app to load the reference and misaligned data.
  • manualAlignFrames('refFile.dat','movFile.dat'); Opens the reference and misaligned .dat files. In this case, type the full path to the .dat files.
  • manualAlignFrames(img1,img2); Opens the images stored in the variables img1 and img2. When using variables as input for the misaligned data, the "Align" button is not available.

Here is an example of a custom function that uses the manual image registration tool as standalone to generate the geometric transformation object (tform) and apply the coregistration to an image:

function [alignedImage, tform] = alignImage(fixImg,movImg)
  % This function calls the manualAlignFrames tool to manually coregister
  % the image "movImg" to the reference image "fixImg" and outputs the
  % registered image and the geometric transformation object.

  % Launch the tool:
  h = manualAlignFrames(fixImg,movImg);
  % Inside the app, align the movImg and save the geometric transformation
  % object to Matlab's base workpace to a variable named "tform" and close
  % the app.
  waitfor(h);
  % Copy the variable "tform" from the base workspace:
  tform = evalin('base','tform');
  % Apply the geometric transformation to the misaligned image:
  alignedImage = imwarp(movImg,tform,'nearest','OutputView',imref2d(size(fixImg)));
end
      

Back to top

Copyright © LabeoTech 2023. This work is licensed under the GNU General Public License, Version 3.0.