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.

 Risposta accettata

Walter Roberson
Walter Roberson il 29 Gen 2018
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 Commenti

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 il 29 Gen 2018
Modificato: Walter Roberson il 29 Gen 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.
Thanks Walter. I will try with your inputs.
Or you could sum the image vertically to find the gaps between the symbols.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by