Geoscience Reference
In-Depth Information
dy = (basepoints(2,2)+basepoints(4,2))/2- ...
(basepoints(1,2)+basepoints(3,2))/2
which yields
dx =
347.1386
dy =
221.9109
We therefore choose
inputpoints(1,:) = [0 0];
inputpoints(2,:) = [0 dy];
inputpoints(3,:) = [dx 0];
inputpoints(4,:) = [dx dy];
h e function
fitgeotrans
now takes the pairs of control points,
inputpoints
and
basepoints
, and uses them to infer a spatial transformation matrix
tform
using the transformation type
projective
.
tform = fitgeotrans(inputpoints,basepoints,'projective');
We next need to estimate the spatial limits for the output,
XBounds
and
YBounds
, corresponding to the projective transformation
tform
, and a set of
spatial limits for the input
xLimitsIn
and
yLimitsIn
.
xLimitsIn = 0.5 + [0 size(I1,2)]
yLimitsIn = 0.5 + [0 size(I1,1)]
[XBounds,YBounds] = outputLimits(tform,xLimitsIn,yLimitsIn)
h en we use
imref2d
to reference the image to world coordinates.
Rout = imref2d(size(I1),XBounds,YBounds)
An
imref2d
object
Rout
encapsulates the relationship between the intrinsic
coordinates anchored to the rows and columns of the image and the spatial
location of the same row and column locations in a world coordinate system.
Finally, the projective transformation can be applied to the original RGB
composite
I1
in order to obtain a rectii ed version of the image (
I10
).
I10 = imwarp(I1,tform,'OutputView',Rout);
We now compare the original image
I1
with the rectii ed version
I10
.
subplot(2,1,1), imshow(I1), title('Original Image')
subplot(2,1,2), imshow(I10), title('Rectified Image')