How can we filter the binary objects from image based on custom properties?

5 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

Image Analyst
Image Analyst el 12 de En. de 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.

Más respuestas (1)

Deependra Mishra
Deependra Mishra el 14 de En. de 2019
I have attached a test image here. In the above solution we are filtering by pixel values and pixel values is just the no. of pixels in the ring. It does not necessarily mean the thickness of the ring. My thought was to calculate the thickness of the ring and then associated that thickness with the ring object and then filter it.
Ring could be of irregular shaped, so I believe calculting the average thickness would be a better idea. Please let me know if you have any other better ideas.
Thank you in advance.

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by