Filter löschen
Filter löschen

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

8 Ansichten (letzte 30 Tage)
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!

Akzeptierte Antwort

Image Analyst
Image Analyst am 13 Apr. 2017
Use bwdist():
edtImage = bwdist(binaryImage);
maxDiam = 2 * max(edtImage(:)); % Max() will give the radius.
  12 Kommentare
Muhammad Usman khan
Muhammad Usman khan am 11 Jun. 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 am 11 Jun. 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Images 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