필터 지우기
필터 지우기

How do I combine regions of regionprops

조회 수: 7 (최근 30일)
Andreas
Andreas 2016년 11월 28일
댓글: Image Analyst 2016년 12월 7일
Hello, I use regionprops to get different regions within an image.
Obj = regionprops(~bw,{'Area','Extrema','Boundingbox','MajorAxisLength','MinorAxisLength','ConvexHull','Centroid'});
According to some assumptions I would like to recombine some Objs of the struct
For example I would like to combine 2 objects where the y-coordinate of the centroid is quite similar. This means, that the some values, Area, Centroid, Bounding Box have to be recalculated. What would be the correct way to do that?
Thanks

채택된 답변

Image Analyst
Image Analyst 2016년 11월 28일
I believe you can set the label to be the same. For example, make blob 3 have a label of 2 and then blob 2 will now be the old blob 2 and the old blob 3
labeledImage(labeledImage == 3) = 2; % Merge blob 3 into blob 2.
Now call regionprops
props = regionprops(labeledImage, .........
  댓글 수: 2
Andreas
Andreas 2016년 12월 6일
Thank you for this hint, I did not realize that I can directly use labeledImages for regionprops.
Unfortunately, it seems that I've to use 'FilledImage' for getting the image? Or can I use 'PixelIdxList' to create a 2D-image?
Image Analyst
Image Analyst 2016년 12월 7일
regionprops() preferred way is to use either a connected components object generated from bwconncomp() or a labeled matrix generated from bwlabel.
I don't know what FilledImage is because you have not shown your code, at least not shown it here. You can use PixelIdxList to create a binary image of the blob(s), though there may be better ways.

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by