Registering an Image

Overview

Image registration is the process of aligning two or more images of the same scene. Typically, one image, called the base image or reference image, is considered the reference to which the other images, called input images, are compared. The object of image registration is to bring the input image into alignment with the base image by applying a spatial transformation to the input image. The differences between the input image and the output image might have occurred as a result of terrain relief and other changes in perspective when imaging the same scene from different viewpoints. Lens and other internal sensor distortions, or differences between sensors and sensor types, can also cause distortion.

A spatial transformation maps locations in one image to new locations in another image. (For more details, see Spatial Transformations) Determining the parameters of the spatial transformation needed to bring the images into alignment is key to the image registration process.

Image registration is often used as a preliminary step in other image processing applications. For example, you can use image registration to align satellite images of the earth's surface or images created by different medical diagnostic modalities (MRI and SPECT). After registration, you can compare features in the images to see how a river has migrated, how an area is flooded, or to see if a tumor is visible in an MRI or SPECT image.

Back to Top

Point Mapping

The Image Processing Toolbox software provides tools to support point mapping to determine the parameters of the transformation required to bring an image into alignment with another image. In point mapping, you pick points in a pair of images that identify the same feature or landmark in the images. Then, a spatial mapping is inferred from the positions of these control points.

The following figure provides a graphic illustration of this process. This process is best understood by looking at an example. See Example: Registering to a Digital Orthophoto for an extended example.

Back to Top

Using cpselect in a Script

If you need to perform the same kind of registration for many images, you automate the process by putting all the steps in a script. For example, you could create a script that launches the Control Point Selection Tool with an input and a base image. The script could then use the control points selected to create a TFORM structure and pass the TFORM and the input image to the imtransform function, outputting the registered image.

To do this, specify the 'Wait' option when you call cpselect to launch the Control Point Selection Tool. With the 'Wait' option, cpselect blocks the MATLAB command line until control points have been selected and returns the sets of control points selected in the input image and the base image as a return values. If you do not use the 'Wait' option, cpselect returns control immediately and your script will continue without allowing time for control point selection. In addition, without the 'Wait' option, cpselect does not return the control points as return values. For an example, see the cpselect reference page.

Back to Top

Example: Registering to a Digital Orthophoto

This example illustrates the steps involved in performing image registration using point mapping. These steps include:

Step 1: Read the Images

In this example, the base image is westconcordorthophoto.png, the MassGIS georegistered orthophoto. It is a panchromatic (grayscale) image, supplied by the Massachusetts Geographic Information System (MassGIS), that has been orthorectified to remove camera, perspective, and relief distortions (via a specialized image transformation process). The orthophoto is also georegistered (and geocoded) — the columns and rows of the digital orthophoto image are aligned to the axes of the Massachusetts State Plane coordinate system. In the orthophoto, each pixel center corresponds to a definite geographic location, and every pixel is 1 meter square in map units.

The image to be registered is westconcordaerial.png, a digital aerial photograph supplied by mPower3/Emerge, and is a visible-color RGB image. The aerial image is geometrically uncorrected: it includes camera perspective, terrain and building relief, internal (lens) distortions, and it does not have any particular alignment or registration with respect to the earth.

The following example reads both images into the MATLAB workspace and displays them using

orthophoto = imread('westconcordorthophoto.png');
figure, imshow(orthophoto)
unregistered = imread('westconcordaerial.png');
figure, imshow(unregistered)

You do not have to read the images into the MATLAB workspace. The cpselect function accepts file specifications for grayscale images. However, if you want to use cross-correlation to tune your control point positioning, the images must be in the workspace.

Step 2: Choose Control Points in the Images

The toolbox provides an interactive tool, called the Control Point Selection Tool, that you can use to pick pairs of corresponding control points in both images. Control points are landmarks that you can find in both images, like a road intersection, or a natural feature.

To start this tool, enter cpselect at the MATLAB prompt, specifying as arguments the input and base images.

cpselect(unregistered, orthophoto)

The Control Point Selection Tool displays two views of both the input image and the base image in which you can pick control points by pointing and clicking. For more information, see Selecting Control Points. This figure shows the Control Point Selection Tool with four pairs of control points selected. The number of control point pairs you pick is at least partially determined by the type of transformation you want to perform (specified in Step 5). See Transformation Types for information about the minimum number of points required by each transformation.

Step 3: Save the Control Point Pairs to the MATLAB Workspace

In the Control Point Selection Tool, click the File menu and choose the Export Points to Workspace option. See Exporting Control Points to the Workspace for more information.

For example, the following set of control points in the input image represent spatial coordinates; the left column lists x-coordinates, the right column lists y-coordinates.

input_points =

  118.0000   96.0000
  304.0000   87.0000
  358.0000  281.0000
  127.0000  292.0000

Step 4: Fine-Tune the Control Point Pair Placement (Optional)

This is an optional step that uses cross-correlation to adjust the position of the control points you selected with cpselect. To use cross-correlation, features in the two images must be at the same scale and have the same orientation. They cannot be rotated relative to each other. Because the Concord image is rotated in relation to the base image, cpcorr cannot tune the control points. See Using Correlation to Improve Control Points for more information.

Step 5: Specify the Type of Transformation and Infer Its Parameters

In this step, you pass the control points to the cp2tform function that determines the parameters of the transformation needed to bring the image into alignment. cp2tform is a data-fitting function that determines the transformation based on the geometric relationship of the control points. cp2tform returns the parameters in a geometric transformation structure, called a TFORM structure.

When you use cp2tform, you must specify the type of transformation you want to perform. The cp2tform function can infer the parameters for five types of transformations. You must choose which transformation will correct the type of distortion present in the input image. See Transformation Types for more information. Images can contain more than one type of distortion.

The predominant distortion in the aerial image of West Concord (the input image) results from the camera perspective. Ignoring terrain relief, which is minor in this area, image registration can correct for camera perspective distortion by using a projective transformation. The projective transformation also rotates the image into alignment with the map coordinate system underlying the base digital orthophoto image. (Given sufficient information about the terrain and camera, you could correct these other distortions at the same time by creating a composite transformation with maketform. See Performing General 2-D Spatial Transformations for more information.)

mytform = cp2tform(input_points, base_points, 'projective');

Step 6: Transform the Unregistered Image

As the final step in image registration, transform the input image to bring it into alignment with the base image. You use imtransform to perform the transformation, passing it the input image and the TFORM structure, which defines the transformation. imtransform returns the transformed image. For more information about using imtransform, see Spatial Transformations

registered = imtransform(unregistered, mytform);

The following figure shows the transformed image transparently overlaid on the base image to show the results of the registration. (To see how this is done, see Example: Performing Image Registration.


Maintained by John Loomis, last updated 9 April 2010