How can we filter the binary objects from image based on custom properties?
조회 수: 1 (최근 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!