How to calculate diameter from side view?

Hi!
Imagine we have a side view of a circular object such as a coin. How can I accurately calculate the diameter of an object from side view image?
The simple thing is that the user determines the two sides (left and right) of the object as the diameter, but is there another way that MATLAB can detect it automatically and accurately?
Thanks!
Steven

3 comentarios

Walter Roberson
Walter Roberson el 6 de En. de 2014
Could you post a couple of sample images?
Jan
Jan el 6 de En. de 2014
To calculate the diameter accurately, you need the parameter of the optical system and the distance also, when you want the real extent.
Steven
Steven el 7 de En. de 2014
Thanks all. The sample is posted here.

Iniciar sesión para comentar.

 Respuesta aceptada

Image Analyst
Image Analyst el 6 de En. de 2014

1 voto

I don't know what you mean by side view. Do you mean like front side and back side (head side and tail side), or do you mean like an "edge-on" view, so that it looks like a rod or stick? Either way, you need to get a binary image of the object and then use regionprops to get the length or diameter of it. Post an image so we can see it. regionprops gives the answer in pixels. If you need real world units, like Jan brought up, then see my attached spatial calibration demo, below in blue text.

6 comentarios

Steven
Steven el 7 de En. de 2014
Editada: Steven el 7 de En. de 2014
Thanks all. What I meant was something like this. Imagine this is a spreading case and I want to find the area of circle and so the diameter.
What I want is the length of red line (diameter). How can I get it? I mean even the pixel numbers?
One more question: I drew this line by plot and the user determines the two ends of the circle. If I find the pixel numbers between these two points (red line length) in grayscale image, is it right or I have to do so in binary image? [I got the pixel numbers by just decreasing x2 -x1]
Thanks
Steven
Image Analyst
Image Analyst el 7 de En. de 2014
You can have the user do it by calling imdistline() or improfile().
Steven
Steven el 7 de En. de 2014
1. Is there a way that Matlab can find the length, since it is more accurate?
2. So this x2 -x1 in grayscale image is right? No need to use binary image? Right?
Thanks!
Steven
Image Analyst
Image Analyst el 7 de En. de 2014
It can if you can get the tilted disk by itself. For example you can ask regionprops to get the majoraxislength. Can you improve your image capture at all so it's not blurry and dark? Can you make it so that the disk is surrounded by a solid black border?
Steven
Steven el 7 de En. de 2014
I am afraid I can't. Maybe I just crop it and adjust the contrast to do so.
Image Analyst
Image Analyst el 7 de En. de 2014
How can you crop if you don't know what size it is yet? Anyway, adjusting contrast by a linear stretch like imadjust() or non-linearly with histeq() won't help at all. You'd need more sophisticated things, like morphological filters like imopen().

Iniciar sesión para comentar.

Más respuestas (0)

Preguntada:

el 6 de En. de 2014

Editada:

el 7 de En. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by