Convert an image pixel coordinate to physical coordinate

4 Ansichten (letzte 30 Tage)
AP
AP am 14 Okt. 2012
Dear All,
I have a 2D array over the range xmin<x<xmax and ymin<y<ymax which contains the color intensity of each point. It looks like a deformed donut. I needed to find the inner and outer boundary of the donut. In order to achieve this goal, I used image processing and found the boundaries by bwboundaries function. Now I have the boundaries. The boundaries are in rows and columns coordinate. I want to convert them back into physical x,y coordinates. How can I do it?
Thanks,
Ahmad

Akzeptierte Antwort

Image Analyst
Image Analyst am 14 Okt. 2012
Bearbeitet: Image Analyst am 14 Okt. 2012
Yes.
% Get the image size.
[rows columns numberOfColorChannels] = size(imageArray);
% Create the spatial calibration factors.
realWorldUnitsPerPixel_x = (xmax - xmin) / columns;
realWorldUnitsPerPixel_y = (ymax - ymin) / rows;
% Now let's say you had some pixel coordinate (column, row):
realWorldX = xmin + realWorldUnitsPerPixel_x * column;
realWorldY = ymin + realWorldUnitsPerPixel_y * row;
% Now realWorldX and realWorldY are in terms of real world units.

Weitere Antworten (1)

Matt J
Matt J am 14 Okt. 2012
Bearbeitet: Matt J am 14 Okt. 2012
You need to know the coordinates row0,col0 of the physical origin and the pixel sizes. With this, you do
physicalCoords = ([row,col]-[row0,col0]).*pixelsizes

Kategorien

Mehr zu Agriculture finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by