Dear Matlab community, I am given the number of pixels as 768 by 768 for a TIFF image and I am required to convert it to x and y geographical coordinates

조회 수: 2 (최근 30일)
Rukundo Wellen 2022년 12월 26일
답변: Nadia Shaik 2023년 3월 10일
댓글 수: 2없음 표시없음 숨기기
Voss 2022년 12월 26일
Please upload (using the button with the paperclip icon on it) your image and the code you have tried so far.
Rukundo Wellen 2022년 12월 27일
info = imfinfo('xp.tiff');
height = info.Height; % image height in pixels
width = info.Width; % image width in pixels
[H,W] = meshgrid(1:height,1:width);
R = georefcells([-90 90],[0 360],2,2,'ColumnsStartFrom','north')
[x,y] = pix2map(info.R, H, W); % the pixel coordiantes are transfeered to the intirinsic coordiantes
[lat,lon] = projinv(info,x,y); %to transfer intirinsic to geographical coordiantes.

댓글을 달려면 로그인하십시오.

답변 (1개)

Hi Rukundo,
I understand that you wish to convert the pixel coordinates to geographic coordinates. Below are a few changes you can consider:
• when you use "meshgrid", the first input should be the width (i.e., the number of columns) and the second input should be the height (i.e., the number of rows):
[W, H] = meshgrid(1:width, 1:height);
• You can use the "geotiffread" function instead of "imread" to read in the "TIFF" file. This will give you both the image data (I) and the R structure, which contains the georeferencing information.
Hope this helps!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Map Customization에 대해 자세히 알아보기

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by