Register Images with Projection Distortion Using Control Points
This example shows how to register two images by selecting control points common to both images and inferring a geometric transformation that aligns the control points.
Read the image
westconcordorthophoto.png into the workspace. This image is an orthophoto that has already been registered to the ground.
ortho = imread('westconcordorthophoto.png'); imshow(ortho) text(size(ortho,2),size(ortho,1)+15, ... 'Image courtesy of Massachusetts Executive Office of Environmental Affairs', ... 'FontSize',7,'HorizontalAlignment','right');
Read the image
westconcordaerial.png into the workspace. This image was taken from an airplane and is distorted relative to the orthophoto. Because the unregistered image was taken from a distance and the topography is relatively flat, it is likely that most of the distortion is projective.
unregistered = imread('westconcordaerial.png'); imshow(unregistered) text(size(unregistered,2),size(unregistered,1)+15, ... 'Image courtesy of mPower3/Emerge', ... 'FontSize',7,'HorizontalAlignment','right');
Select Control Point Pairs
To select control points interactively, open the Control Point Selection tool by using the
cpselect function. Control points are landmarks that you can find in both images, such as a road intersection or a natural feature. Select at least four pairs of control points so that
cpselect can fit a projective transformation to the control points. After you have selected corresponding moving and fixed points, close the tool to return to the workspace.
[mp,fp] = cpselect(unregistered,ortho,'Wait',true);
Infer Geometric Transformation
Find the parameters of the projective transformation that best aligns the moving and fixed points by using the
t = fitgeotrans(mp,fp,'projective');
Transform Unregistered Image
To apply the transformation to the unregistered aerial image, use the
imwarp function. Specify that the size and position of the transformed image match the size and position of the ortho image by using the '
OutputView' name-value pair argument.
Rfixed = imref2d(size(ortho)); registered = imwarp(unregistered,t,'OutputView',Rfixed);
See the result of the registration by overlaying the transformed image over the original orthophoto.