## Converting pixel coordinates to latitude and longitude in decimal degrees for a binary image.

### Ushashi Podder (view profile)

on 22 Oct 2019
Latest activity Edited by Ushashi Podder

### Ushashi Podder (view profile)

on 25 Oct 2019
How can I convert the centroid of the pixel coordinates into latitude and longitude values in decimal degrees ?I have used several functions like Utm2deg and utm2ll for doing the same after converting the pixels coordinates to UTM but it does not give any result.I am attaching the code here.It will be helpful if someone can help me with it as I am a novice in matlab.
r = regionprops('table',l,'centroid',);
x_centroid= r.Centroid;
y_centroid= r.Centroid;
R=makerefmat(885698,1258968,200,200);
[lat, lon] = pix2latlon(R,x_centroid,y_centroid);

Show 1 older comment
darova

### darova (view profile)

on 22 Oct 2019
How to display it? Is it the image?
I see nothing
darova

### darova (view profile)

on 22 Oct 2019
What are boudaries of images (lat/long)?
Maybe this data can be used for scaling?
RasterExtentInWorldX: 20820
RasterExtentInWorldY: 17790
darova

### darova (view profile)

on 23 Oct 2019
You want to scale your data?
[m,n,~] = size(A); % size in pixels
xx = Left + (Right-Left)/n*x_centroid; % worlds coordinates
yy = Bottom + (Top-Bottom)/m*y_centroid;

### darova (view profile)

on 23 Oct 2019

You forgot about concantenating (cat) function
A(A>=0.99500)=0;
y = im2bw(A);
r = regionprops(y,'Centroid');
xy = cat(1,r.Centroid);
imshow(y)
hold on
plot(xy(:,1),xy(:,2),'or')
hold off
r.Centroid returns an asnwer as a structure not an array
>> r.Centroid
ans =
163.5000 235.0000
ans =
518.5882 368.7059

darova

### darova (view profile)

on 23 Oct 2019
What is connection between degrees and pixels?
darova

### darova (view profile)

on 23 Oct 2019
Did you try to express x and y?