Matrices are just arrays of values and there is no inherent Cartesian coordinates associated with them. They have rows and columns, not x and y.
If you use imshow() or image() or imagesc() to display an image, then you have the option to control how rows and columns map into data units. The default is a 1:1 mapping. The default for all three functions is that X=1 Y=1 will correspond to the center of the bottom left pixel and that X=columns Y=rows maps to the center of the upper-right pixel. Because the center are being referred to, the image would cover from (1/2,1/2) to (columns+1/2, rows+1/2)
There are other possibilities, such as georefferencing through the Mapping Toolbox, which provides some flexibility as to what coordinates mean, possibly including nonlinear projections. In such cases the person who created the dataset should have documented the transformation.
It is common for people to get confused with images and think that there should be a way to convert pixels into real world coordinates. Sometimes there are ways, but unless you are using a calibrated device such as MRI or confocal microscope, even if image has the appropriate headers then the headers are typically pretty wrong.
2 Comments
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/477443-how-to-convert-matrix-indexes-to-cartesian-coordinates#comment_738644
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/477443-how-to-convert-matrix-indexes-to-cartesian-coordinates#comment_738644
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/477443-how-to-convert-matrix-indexes-to-cartesian-coordinates#comment_738782
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/477443-how-to-convert-matrix-indexes-to-cartesian-coordinates#comment_738782
Sign in to comment.