From: Michael on
I have an image matrix and know the world coordinates (e.g. in the UTM system) of its corner pixels - or any other pixels, if necessary. Now, I want to georeference that image, so that it is transformed from the (row,col) coordinate system to that world coordinate system, i.e. every pixel is associated with an individual northing and easting coordinate.

I have already looked at makerefmat of the Mapping Toolbox, but that seems only suitable for data aligned in parallel to the meridians.

Also, I tried to use cp2tform and imtransform, which produces reasonable results concerning the rectified projection, but nonetheless still shows the image with (row,col) axes. Maybe the use of XData and YData might help, but I have not figured out the proper way yet. And in the end this solution seems like some kind of workaround, especially having the Mapping Toolbox available.

So, does anybody know how to georeference arbitrarily oriented images in MATLAB properly?
From: Michael on
OK, no answers so far. In the meantime I went on with the imtransform approach.

This is how it worked out for me:

tform = cp2tform(input_points,base_points,'affine');
[imageRectified,XData,YData] = imtransform(image,tform,'FillValues',255);
figure, imagesc(imageRectified,'XData',XData,'YData',YData);
axis equal, axis xy;

Now, I guess, it's possible to use makerefmat and worldfilewrite to construct a GeoTIFF worldfile. Although I've not yet managed to get that working properly. Also it seems not possible to create a full GeoTIFF file directly from MATLAB (so that it can be included in GI systems or Google Earth or so)?
From: Wolfgang Schwanghart on
Hi,

I don't have the mapping toolbox, so I can't say much about refmats. Writing GeoTIFFs with Matlab built in functions is not possible. Yet, there are functions on the FEX that do it by calling the GDAL library.

http://www.mathworks.com/matlabcentral/fileexchange/26135-makegeotiff
http://www.mathworks.com/matlabcentral/fileexchange/6010-mexgdal

I've never tried them since I always preferred a more pedestrian way using ESRI ASCII grids. Yet, this might not work for multiple band rasters without exporting band by band. Hence, give it a try.

Best regards,
Wolfgang


"Michael " <michael.schmittNOSPAM(a)bv.tum.de> wrote in message <hofvv0$sf8$1(a)fred.mathworks.com>...
> OK, no answers so far. In the meantime I went on with the imtransform approach.
>
> This is how it worked out for me:
>
> tform = cp2tform(input_points,base_points,'affine');
> [imageRectified,XData,YData] = imtransform(image,tform,'FillValues',255);
> figure, imagesc(imageRectified,'XData',XData,'YData',YData);
> axis equal, axis xy;
>
> Now, I guess, it's possible to use makerefmat and worldfilewrite to construct a GeoTIFF worldfile. Although I've not yet managed to get that working properly. Also it seems not possible to create a full GeoTIFF file directly from MATLAB (so that it can be included in GI systems or Google Earth or so)?