Calculating perimeter/circumfrence of regions in a binary image through a different approach than regionprops(BW, 'perimeter') *UPDATED*
이전 댓글 표시
Suppose I have a binary image with many different regions in it. One region in the image may look like this:

Using regionprops and the 'perimeter' property, Matlab would calculate the green marked perimeter, which for this region would be 17.9460.
Now, what I want to calculate is a little bit different. It's basically the length of the lines forming the region (marked red in the image). Or in other words, the number of green marked "pixels" in the following image, although the blue marked pixles would have to be counted twice to get the length of the lines:

So this would get a length of all lines (or count of pixels) of 24.
Is there a way to do this using some build in Matlab functions in the Image Processing Toolbox?
Thanks in advance, Best Regards
댓글 수: 5
Amith Kamath
2015년 12월 10일
Philip: This is a very interesting question. Thanks for the helpful illustrations to show us what you are trying to achieve.
I'm however a little confused by this statement: "It's basically the length of the lines forming the region. Or in other words, the number of green marked "pixels"". Could you please elaborate on what you mean by 'length of lines forming the region'?
What happens at a corner, like in the second image, where a green pixel has a white pixel to it's north, north-east and east? There are two 'edges' this pixel is representing, but it will be counted only once in the scheme you mention. Should this not be counted twice, then?
Phillip Probst
2015년 12월 15일
편집: Phillip Probst
2015년 12월 15일
Phillip Probst
2015년 12월 15일
편집: Phillip Probst
2015년 12월 15일
Image Analyst
2015년 12월 17일
You have to be careful of your definitions. For example in this: [0 1 1 1 0], what is the "length" of the line? Is it 3 or is it 2? You could make an argument for either. If two pixels are on a diagonal, is the length 2 or sqrt(2)?
Phillip Probst
2015년 12월 21일
채택된 답변
추가 답변 (1개)
Image Analyst
2015년 12월 10일
1 개 추천
Try calling imdilate() followed by bwboundaries() or regionprops(). Let me know what you find out.
댓글 수: 1
Phillip Probst
2015년 12월 15일
편집: Phillip Probst
2015년 12월 15일
카테고리
도움말 센터 및 File Exchange에서 Region and Image Properties에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



