Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

Convert an image pixel coordinate to physical coordinate

Asked by AP

AP

on 14 Oct 2012
Accepted Answer by Image Analyst

Image Analyst

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

0 Comments

AP

AP

Products

No products are associated with this question.

2 Answers

Answer by Image Analyst

Image Analyst

on 14 Oct 2012
Edited by Image Analyst

Image Analyst

on 14 Oct 2012
Accepted answer

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.

0 Comments

Image Analyst

Image Analyst

Answer by Matt J

Matt J

on 14 Oct 2012
Edited by Matt J

Matt J

on 14 Oct 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

0 Comments

Matt J

Matt J

Contact us