In MATLAB for image processing, the general use of the image local coordinates, in the upper left corner (at the beginning). When processing is complete, if you want to display the results in a remote sensing image with geographic coordinates, or if you need to output a SHP file, you need to involve conversion of local coordinates and geographic coordinates, and we can use the Pix2map function to implement this function.
Clc;clear;close All; [pic, R]= Geotiffread ('boston.tif'); %read the TIF image figure (1), Imshow (pic);
% pic is a local image, the following local image Operation Gray=rgb2gray (pic); BW=IM2BW (Gray,0.1); %threshold Split BW=1-BW;BW1= Bwareaopen (BW,500000); %Delete an area less than 500000 bw2=imfill (BW1,'Holes'); %fill hole figure (2), Imshow (BW2); BW3=bwboundaries (BW2); %Get edge Contour Data=bw3{1,1}; % get Contour line coordinates, one nmatrix of 2, which is the local image coordinate [lonx,laty]=pix2map (R,data (:,1), data (:,2)); %converts local image coordinates to geographic coordinates figure (3), Axis off;mapshow ('boston.tif'); %displays a remote sensing image with geographical coordinates mapshow (Lonx,laty,'Color','R'); % display outlines on remote sensing imagery
To convert the geographic coordinates of remote sensing imagery in MATLAB