I would like to find the equation of a line that passes through the centroid of a blob so that I can divide the blob into half. How can I achieve this after I get the centroid from regionprops() ?

댓글 수: 5

Guillaume
Guillaume 2015년 6월 3일
Apart maybe for your ellipsoid, there's an infinity of line dividing the blobs into halves of equal area. Any line going through the centroid will do.
Image Analyst
Image Analyst 2015년 6월 3일
Why do you want to do this? Give us some context.
Hg
Hg 2015년 6월 5일
I want to divide the blob into half w.r.t its major axis. I found a way but not sure whether there's a better way to do this.
% Find the centroid of the blob and the direction of the major axis of its corresponding ellipse
s = regionprops(blob, 'centroid', 'orientation');
% Find the gradient of the line perpendicular to the major axis
m = tan( pi * (s(1,1).Orientation + 90 )/180 );
y = - m *( x - s(1,1).Centroid(1) ) + s(1,1).Centroid(2);
Image Analyst
Image Analyst 2015년 6월 5일
Like I asked before (and you didn't answer)...Why do you want to do this? Give us some context. Like Guillaume said, you could pick any angle.
Hg
Hg 2015년 6월 7일
I'm cropping an image and one of the criteria is to reduce the size of a "long" blob by removing half of it.

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

 채택된 답변

Image Analyst
Image Analyst 2015년 6월 8일

0 개 추천

Hg says the real need is for "cropping an image and one of the criteria is to reduce the size of a "long" blob by removing half of it." You can do that with imerode. But I asked for the context and you still haven't provided that. Why would you want to reduce the size of your segmented blobs by half? What is the point in doing that?

댓글 수: 7

Hg
Hg 2015년 6월 8일
About the context, I just want to remove half of the length of the arm from the image.
Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh 2015년 6월 8일
You don't even need to find the centroid for this purpose. Like Image analyst said, erode them until you get to half of the current area. Which makes it easy.
Hg
Hg 2015년 6월 8일
In my case, the other end of the arm is the hand, so I don't think I can erode them.
Image Analyst
Image Analyst 2015년 6월 8일
I know it sounds dumb, but one way to do it is to ask regionprops for the centroid and PixelList. Then, for each blob, run through the PixelList coordinates with a for loop, and if the x coordinate is more than the x coordinate of the centroid, set that pixel of the binary image to false. This will erase the right half of every blob. This will meet all your criteria that you have given to us so far.
Hg
Hg 2015년 6월 9일
@Image Analyst, thanks for the helpful trick! It's easier than finding the equation!
Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh 2015년 6월 9일
Guys, what's PixelList? Is it the perimeter of the blob?
Image Analyst
Image Analyst 2015년 6월 9일
PixelList is a list of the (x,y) coordinates of all the pixels in each blob. Perimeter is a separate measurement that you can ask for.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기

태그

질문:

Hg
2015년 6월 3일

댓글:

2015년 6월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by