How can we filter the binary objects from image based on custom properties?
1 view (last 30 days)
Show older comments
Deependra Mishra
on 11 Jan 2019
Answered: Deependra Mishra
on 14 Jan 2019
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 Comments
Accepted Answer
Image Analyst
on 12 Jan 2019
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 Comments
More Answers (1)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!