How can we filter the binary objects from image based on custom properties?
2 次查看(过去 30 天)
显示 更早的评论
Let say I have a binary image with many rings of different thickness. Now if I want to filter out the image based on the thickness of the ring? How can I do that? I know we can filter out the image by area, perimeter etc using bwpropfilt.
0 个评论
采纳的回答
Image Analyst
2019-1-12
You forgot to attach your image. Usually when people ask for image processing advice, they attach an image.
I would compute the Euclidean Distance Transform for the binary image with bwdist().
edtImage = bwdist(binaryImage);
Then ask regionprops for the pixel values of the EDT image.
labeledImage = bwlabel(binaryImage);
props = regionprops(labeledImage, edtImage, 'PixelValues');
If the max pixel value for that ring is acceptable, store that index.
numRings = length(props)
keepers = false(1, numRings)
for k = 1 : numRings
if max(props(k).PixelValues) > someValue
% This ring is thick enough. So keep it.
keepers(k) = true;
end
end
Then use ismember(mask, indexes) to extract just the rings that meet your criteria.
filteredBinaryImage = ismember(labeledImage, find(keepers));
The code is just off the top of my head - untested, so you may have to adapt it some. If you want the average thickness of the ring, then you'll have to call bwmorph() to skeletonize it and then multiply the skeleton image by the EDT image to get the thickness just along the centerlines. Then get the mean of all those pixels.
If you need more help, post your image and ring thickness criteria for keeping and excluding rings.
0 个评论
更多回答(1 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!