Page 213 - MATLAB Recipes for Earth Sciences
P. 213

208                                                 8 Image Processing

            The four corners of the image correspond to the pixels in the four corners of
            the image that we store in a variable named basepoints.

               basepoints(1,:) = [1,4200];
               basepoints(2,:)= [1,1];
               basepoints(3,:)= [4100,4200];
               basepoints(4,:)= [4100,1];

            The function cp2tform now takes the pairs of control points  input-
            points and basepoints and uses them to infer a spatial transformation
            matrix tform.

               tform = cp2tform(inputpoints,basepoints,'affine');
            This transformation can be applied to the original RGB composite naiva-
            sha_rgb in order to obtain a georeferenced version of the satellite image
            newnaivasha_rgb.

               [newnaivasha_rgb,x,y]=imtransform(naivasha_rgb,tform);

            Subsequently, an appropriate grid for the image may be computed. The grid
            is typically defined by the minimum and maximum values for the longitude

            and the latitude. The vector increments are then obtained by dividing the
            longitude and latitude range by the array dimension and by subtracting one
            from the result.

               X = 36.096003 : (36.770406-36.096003)/8569 : 36.770406;
               Y = 0.319922 : (0.958743-0.319922)/8400: 0.958743;

            Hence, both images can be displayed for comparison (Fig. 8.4 and 8.5).
               iptsetpref('ImshowAxesVisibl','On')
               imshow(naivasha_rgb), title('Original ASTER Image')
               figure
               imshow(newnaivasha_rgb,'XData',X,'YData',Y);
               xlabel('Longitude'), ylabel('Latitude')
               title('Georeferenced ASTER Image')
               grid on
            The command iptsetpref makes the axis of the image visible. Exporting
            the results is possible in many ways, such as

                 print -djpeg70 -r600 naivasha_georef.jpg
            as JPEG fi le naivasha_georef.jpg compressed at 70% and at a resolution
            of 600 dpi.
   208   209   210   211   212   213   214   215   216   217   218