Align an image based on a reference image
- Last UpdatedFeb 12, 2024
- 5 minute read
Use Align Image blocks to align the input images based on a reference image.
To configure an Align Image block
-
On the Block Definitions toolbar, select Pre-Processing.
The Pre-Processing list expands.
-
Drag an Align Image block onto the Canvas.

-
Connect the block to other blocks on the Canvas as needed.
-
Select the Align Image block on the Canvas.
-
Right-click the block, and then select Properties.

The Properties side sheet appears on the right side of the screen.

-
Select Select Image (
).
The Good image dataset appears in an adjacent pane.
-
Select an image with the desired alignment, and then select Select Image.
The selected image serves as the reference image as well as the block preview on the Canvas.
-
In the Align Algorithm section, select one of the following:
-
ECC – Maximize the enhanced correlation coefficient (ECC). The ECC is a measure of similarity that does not vary based on differences in contrast or brightness. This is the most reliable option for aligning the image. However, this method is time-consuming. You can reduce the time the alignment takes by scaling down the image.
-
Optical Flow – Backtrack any motion in the image frame in comparison to a reference image. This method is very fast but may not produce reliable results if there are significant changes between the reference image and the aligned image.
-
Feature Based – Select a region that you want to align the image to. This method only shifts and rotates the image.
-
-
If you selected ECC, in the Transformation type list, select one of the following:
-
Affine – Shift, rotate, scale up or down, and shear the image.
-
Euclidean – Shift and rotate the image.
-
Homography – The same as Affine, but includes 3D changes.
-
Translation – Shift the image to the left, to the right, up, or down.

-
-
If you selected Optical Flow or Feature Based, do the following:
-
In the Max number of features box, enter the maximum number of features (such as bends and edges) that the software can identify in the image.
You can also use the increase button (
) and decrease button (
) on the same row to change the Max number of features value.
-
In the Selected feature of interest area, select one of the following to specify the region of interest (ROI) that contains the feature that you want to use for the alignment:
-
Optional: Select the expand button (
) to expand the Selected feature of interest area.
This enlarges the images so that you can more easily define the ROI.
You can select the collapse button (
) to return to the previous menu.
-
Optional: On the enlarged image, use the zoom tools to zoom in (
) and out (
) of the image.
-
Select the image to create a connection point for the ROI at that position.
-
Optional: Select Clear to delete the defined ROI and start over.
-
Optional: Turn on the Manual Override toggle to view a list of the x-coordinates and y-coordinates for each connection point for the ROI.
You can manually change the x and y values to shift the positions of the vertices.
-
Optional: If you turned on the Manual Override toggle, select Add Coordinate to add another connection point to the ROI.
The new, blank connection point appears in the list of x-coordinates and y-coordinates so that you can enter the position of the connection point on the image.
If you are specifying the ROI as a rectangle, you cannot manually add more connection points to the list after the first two that specify the opposite corners of the rectangle.
-
-
In the Scale image box, enter the scaling for the image.
You can set this value between 0 and 100.
You can also use the slider or the increase button (
) and decrease button (
) on the same row to change the Scale image value.
-
In the Acceptable time align can take in milliseconds box, enter the maximum time in milliseconds that the software can take to process and align each image in the image dataset.
You can also use the slider or the increase button (
) and decrease button (
) on the same row to change the Acceptable time align can take in milliseconds value.
-
Select Apply Changes.
The preview image for the block updates on both the Properties side sheet and the Canvas.