필터 지우기
필터 지우기

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

조회 수: 11 (최근 30일)
hyz
hyz 2017년 4월 13일
댓글: Image Analyst 2017년 6월 11일
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!

채택된 답변

Image Analyst
Image Analyst 2017년 4월 13일
Use bwdist():
edtImage = bwdist(binaryImage);
maxDiam = 2 * max(edtImage(:)); % Max() will give the radius.
  댓글 수: 12
Muhammad Usman khan
Muhammad Usman khan 2017년 6월 11일
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 2017년 6월 11일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by