Number of Object in binary image
Mostrar comentarios más antiguos
Hi, im trying to get the number of objects in an binary image but it return the wrong answer (it should be 6 but it return 31). here is the code and the image:
I=imread('2.jpg');
I_BW=im2bw(I,0.87);
I1=imcomplement(I_BW);
[L,n]=bwlabel(I1);

Respuesta aceptada
Más respuestas (1)
KALYAN ACHARJYA
el 15 de Dic. de 2019
Editada: KALYAN ACHARJYA
el 15 de Dic. de 2019
1 voto
Yes, the correct answer is 31, not 6. Actually it counts the all white pixels, blobs (having 1 white pixel with sourounding by black pixels also), there are so many blobs in 4th objects.
If you are looking for 6 answer only, then you have to remove all those tiny small blobs and apply same (using morphological operation, imdilate or imerode).
May it helps!
1 comentario
Sadeq Ebrahimi
el 15 de Dic. de 2019
Categorías
Más información sobre Morphological Operations en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!