error in detecting components using bwlabel

I used bwlabel for detecting connected components but i got error output i.e 3 objects are detected instead of 8. I am attaching input image. Expecting your suggestion.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 29 de En. de 2018

0 votos

bwlabel assumes that the white pixels are where the data is and that the black pixels are holes. When you have black text on a white background you need to invert the image.

4 comentarios

Thanks Walter. After using imcomplement it detects all the objects. but the output seems blurred one. How can i make exact detection of objects i am using the below code.
ImgPlate=imread('ImgPlate.jpg');
ImgPlate=im2bw(ImgPlate);
% ImgPlate=bwareaopen(ImgPlate,4);
ImgPlate=imcomplement(ImgPlate);
figure,imshow(ImgPlate);
[L,Ne]=bwlabel(ImgPlate);
for n=1:Ne
[r,c] = find(L==n);
n1=picture(min(r):max(r),min(c):max(c)); %picture command crops nth object from L
n1=imresize(n1,[42,24]); %in database size is 42,24 so it is resized so that we can match it with the database
figure,imshow(n1);
end
Walter Roberson
Walter Roberson el 29 de En. de 2018
Editada: Walter Roberson el 29 de En. de 2018
I would suggest that you do a bwclose() before doing the labeling, in order to join together sections that are close together such as the two parts of the accessibility symbol.
You are starting with a JPEG image, so you have to live with blurring. JPEG in the default lossless mode always blurs straight edges.
SHOBA MOHAN
SHOBA MOHAN el 30 de En. de 2018
Thanks Walter. I will try with your inputs.
Image Analyst
Image Analyst el 30 de En. de 2018
Or you could sum the image vertically to find the gaps between the symbols.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Preguntada:

el 29 de En. de 2018

Comentada:

el 30 de En. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by