How do I separate connected objects on a binary image?

11 visualizaciones (últimos 30 días)
My task is to separate the black objects in this photo and calculate their surfice area. I have tried applying erosion and watersheds, but I didn't get to an adequate solution.
  2 comentarios
Rik
Rik el 6 de Feb. de 2023
You need to somehow make use of the property that all objects are convex, although I don't have a ready-made solution for you.
Sarvesh Kale
Sarvesh Kale el 6 de Feb. de 2023
you have to calculate the area of each blob or all the black blobs after their separation ?

Iniciar sesión para comentar.

Respuesta aceptada

Sarvesh Kale
Sarvesh Kale el 6 de Feb. de 2023
Here is my attempt at doing the separation of black blobs and calculating their surface area, I have used erosion followed by dilation by two different structuring elements, this operation is also known as opening in image morphology but the structuring element is kept the same in most cases, following is my code snippet
clear ;
i=imread('image.jpeg');
i = i >150 ; % threshold image ;
subplot 121
imshow(i) % show thresholded image
i = ~ i ; % invert image for morphological op
se1 = strel('disk',9);
ie=imerode(i,se1); % do image erosion with se1
subplot 122
se2 = strel('disk',5);
io=imdilate(ie,se2); % do image dilation with se2
blobs = regionprops(io);
io=~io; % invert again to bring back to original
imshow(io);
b1=blobs(1) % ouptut info of blob 1
rectangle('Position',b1.BoundingBox,'EdgeColor','r','LineWidth',1.5); % draw rectangle on the first blob
you can get help on imdilate and imerode by heading to the following documentation page
you can get additional imformation on regionprops by heading to the following documentation page
You can also try to experiment with different structuring elements to see which combination gives the best separation and do your own experiments.
I hope this answers all your queries, please accept the answer if queries answered. Thank you

Más respuestas (0)

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by