Borrar filtros
Borrar filtros

How to calculate the maximum width of object in binary image?

11 visualizaciones (últimos 30 días)
Here is the binary image and I want to get the maximum width of the object(the gap between the right and left edges). Currently I used minboundrect function to get this max distance on a rectangular bound.
I am thinking is there any function that can tell you the direction vector anywhere along the right edge, and determine tangent and normal vector at each edge, then extend it in each direction until it hits the edge of the left edge.
Appreciate any thoughts and helps on this. Thanks!

Respuesta aceptada

Image Analyst
Image Analyst el 13 de Abr. de 2017
Use bwdist():
edtImage = bwdist(binaryImage);
maxDiam = 2 * max(edtImage(:)); % Max() will give the radius.
  12 comentarios
Muhammad Usman khan
Muhammad Usman khan el 11 de Jun. de 2017
Hey, Thanks everyone. I am still hoping to get automatically line(Not circle) coordinates(i.e P1,P2 in the image) of the maximum width of an object of any orientation in the image.
Image Analyst
Image Analyst el 11 de Jun. de 2017
I don't have any code for that now, so you can write it. I'd just look at all the pixels within +/- radius from the center row and column, and send a line out from the center to any pixel that is the radius away from the center. There should only be a few pixels that are that exact distance away. It's a brute force method but it's intuitive, easy, and fast (because there aren't that many pixels to examine). It's not hard, trust me. I want you to try it and then share the final code once you've got it working.

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by