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.

 採用された回答

Walter Roberson
Walter Roberson 2018 年 1 月 29 日

0 投票

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 件のコメント

SHOBA MOHAN
SHOBA MOHAN 2018 年 1 月 29 日
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 2018 年 1 月 29 日
編集済み: Walter Roberson 2018 年 1 月 29 日
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 2018 年 1 月 30 日
Thanks Walter. I will try with your inputs.
Image Analyst
Image Analyst 2018 年 1 月 30 日
Or you could sum the image vertically to find the gaps between the symbols.

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by