This example shows how to use control point mapping to perform image registration.
Read the sample images and display them.
orthophoto = imread('westconcordorthophoto.png'); figure, imshow(orthophoto) unregistered = imread('westconcordaerial.png'); figure, imshow(unregistered)
In this example, the fixed image is
the MassGIS georegistered orthophoto. It is a panchromatic (grayscale)
image, supplied by the Massachusetts Geographic Information System
(MassGIS). The image has been orthorectified to remove camera, perspective,
and relief distortions via a specialized image transformation process.
The image 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. Each pixel center corresponds to a
definite geographic location, and every pixel is 1 meter square in
The moving image is
a digital aerial photograph supplied by mPower3/Emerge. It is a visible-color
RGB image. The image is geometrically uncorrected: it includes camera
perspective, terrain and building relief, internal (lens) distortions,
and it does not have any particular alignment with the earth.
The example reads both images into the workspace. The
cpselect function accepts images from the workspace or character vectors
specifying the file path for the images.
Select pairs of corresponding control points in both images,
using the Control Point Selection tool. Control points are landmarks
that you can find in both images, like a road intersection, or a natural
feature. To start this tool, enter
as arguments the moving and fixed images.
Save the control point pairs to the workspace. In the Control Point Selection Tool, click the File menu and choose the Export Points to Workspace option.
For example, the following set of control points in the moving image represent spatial coordinates. The left column lists x-coordinates and the right column lists y-coordinates.
moving_points = 118.0000 96.0000 304.0000 87.0000 358.0000 281.0000 127.0000 292.0000
You can optionally fine-tune the control point pair placement
To use cross-correlation, the images must be in the workspace, and
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 fixed image,
tune the control points.
Specify the type of transformation and infer its parameters,
a data-fitting function that determines the transformation that brings
the image into alignment, based on the geometric relationship of the
fitgeotrans returns the parameters
in a geometric transformation object.
mytform = fitgeotrans(movingPoints, fixedPoints, 'projective');
mytform = projective2d with properties: T: [3x3 double] Dimensionality: 2
When you use
fitgeotrans, you must specify
the type of transformation you want to perform. The
can infer the parameters for several types of transformations. Choose
which transformation is suitable for the type of distortion present
in the moving image. Images can contain more than one type of distortion.
The predominant distortion in the aerial image of West Concord (the moving 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 fixed digital orthophoto image.
Transform the moving image (
to bring it into alignment with the fixed image. You use
perform the transformation, passing it the moving image and the geometric
transformation object returned by
the transformed image.
registered = imwarp(unregistered, mytform);
The following figure shows the transformed image transparently overlaid on the fixed image to show the results of the registration.