Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Measure distance on image

Status
Not open for further replies.

karper1986

Member level 2
Joined
Mar 13, 2009
Messages
49
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,715
Hi friends,

anyone can me say how can I mesure distance of image in millimeters between two points in matlab.

Best regards,
Karper.
 

You need to get the resolution of the image first. You can do that by using the function below and then getting the value from the corresponding field of the output structure.

info=imfinfo('x.jpg');
res = info.XResolution;
unit = info.ResolutionUnit;

If you can't see the Resolution fields in the output structure, you have to parse the resolution from the headers of your images manually.

Then you should find the size of a single pixel. For example, if your resolution unit is dpi, then the size of a pixel in millimeters is

p = 1/(res/25.4);

Then you just need to find the euclidean distance between two pixels and multiply it with p

distance = norm([x1 y1] - [x2 y2])*p;

I'm assuming that the vertical and horizontal resolutions are equal and the pixels are square.

Regards
 

    karper1986

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top