This example shows how to use the Registration Estimator app to align a pair of images. The Registration Estimator offers several registration techniques using feature-based, intensity-based, and nonrigid registration algorithms. The following example shows one possible path to registering images with the app.
Create two misaligned images in the workspace. In this example,
the moving image
J is generated by rotating the
I clockwise 30 degrees.
I = imread('cameraman.tif'); J = imrotate(I,-30);
Open the Registration Estimator app. From the MATLAB® Toolstrip, open the Apps tab and under Image Processing and Computer Vision, click Registration Estimator . You can also open the Registration Estimator from the command line:
Load the images into the Registration Estimator app. Click Load
Images, and select the
Load from Workspace option.
In the Moving Image dialog box, select the image to transform. In
the Fixed Image dialog box, select the image with the target orientation.
There is no spatial referencing information or initial transformation
object for the images in this example. To continue, click Start.
For more information, see Load Images into Registration Estimator App.
The app displays an overlay of the images. The default Green-Magenta color scheme shows the fixed image in green and the moving image in magenta. The overlay looks gray in areas where the two images have similar intensity. You can explore additional overlay styles to help you visualize the results of the registration.
Three registration trials are preloaded in the history list:
Feature: MSER, and
SURF. When you click a feature-based technique in the history
list, the app displays a set of red and green dots connected by yellow
lines. These points are the matched features used to align the images.
Run the registration trials with default settings. Click each preloaded trial in the history list, then click Register Images.
After the registration finishes, the image overlay is updated
with the new results. It shows a quality metric and computation time
for each trial in the history list. The quality metric, based loosely
ssim, provides an overall
estimate of registration quality. Different registration techniques
and settings can yield similar quality scores but show error in different
regions of the image. Visual inspection can confirm which registration
technique is the most acceptable.
Due to randomness in the registration optimizer, the quality metric, registered image, and geometric transformation can vary slightly between trials despite identical registration settings.
To use a different registration technique, select it from the Technique menu. For more information, see Techniques Supported by Registration Estimator App.
Now that you have an initial registration estimate, adjust registration settings to improve the quality of the alignment. For more information on available settings, see Tune Registration Settings in Registration Estimator App.
Continuing with this example, adjust the settings of the MSER trial. Try increasing the number of detected features and the quality of matched features independently to see if either improves the quality of the registration.
To increase the number of detected features, click the
MSER trial, numbered 2, in the history list. In the right
panel, move the Number of Detected Features slider
to the right to increase the number of features. Observe that these
new settings generate a trial draft numbered 2.1 in the history list.
The image overlay also shows more matched features, as expected.
To run the registration with these settings, cick Register Images.
In the updated overlay, notice how there is less error along the edge of the image than there was for the MSER trial with default settings. There is less of a magenta tint to the overall image using the new settings. The quality metric has also improved.
To see the effect of increasing the quality of matched features, click the Feature: MSER trial 2 (not 2.1) in the history list. In the right panel, move the Quality of Matched Features slider to the right to increase the quality. Another trial draft, numbered 2.2, appears in the history list. The image overlay shows a smaller number of high quality matched points.
To see the registration with these settings, click Register Images.
Compared to the other MSER trials, this trial has more error along the left side of the head and arm, but less error along the edge of the image. Although the quality metric has increased with these new settings, you can use subjective analysis to determine which settings are more appropriate for your application.
Explore different combinations of number of detected features and quality of matched pairs. If you know the conditions under which the images were obtained, then you can select a different transformation type or clear the Has Rotation option. Post-processing using nonrigid transformations is available for advanced workflows.
When you find an acceptable registration, export the registered image and the geometric transformation to the workspace.
In this example, trial 2.1 has the highest quality and no severe regions of misalignment, so select this trial to export. Click trial 2.1 in the history list, then click Export and select Export Images. In the Export to Workspace dialog box, assign a name to the registration output. The output is a structure that contains the final registered image and the geometric transformation.
You can use the registration results to apply a similar registration to multiple frames in an image sequence. To learn more, see Export the Results from Registration Estimator App.