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.

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 29 Jan. 2018

0 Stimmen

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 Kommentare

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 am 29 Jan. 2018
Bearbeitet: Walter Roberson am 29 Jan. 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 am 30 Jan. 2018
Thanks Walter. I will try with your inputs.
Image Analyst
Image Analyst am 30 Jan. 2018
Or you could sum the image vertically to find the gaps between the symbols.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by