Remove everything outside of largest circle found by regionProps
3 次查看(过去 30 天)
显示 更早的评论
Hello!
So I followed this example here: RegionProps and I was wanting to take the largest circle found and to segment out / clear everything else from the image.
Is there a straight forward way to do this, or rather a Matlab method of doing it?
Many thanks for any help!
0 个评论
回答(2 个)
Walter Roberson
2017-2-4
YourRGBImage = .... original image
ROI = .... after threshholding
props = regionprops(ROI, 'Area, 'PixelIdxList');
[~, idx] = max([props.Area]);
this_region = props(idx).PixelIdxList;
mask = zeros(size(ROI), class(YourRGBImage));
mask(this_region{:}) = 1;
mask = mask(:,:,[1 1 1]); %replicate to 3D
masked_Image = YourRGBImage .* mask;
0 个评论
Image Analyst
2017-2-4
Before you call regionprops, simply call bwareafilt() on bw:
bw = bwareafilt(bw, 1); % Extract largest blob.
This will keep (segment out) only the largest circle in the image.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!