フィルターのクリア

how to find connected component in an image

9 ビュー (過去 30 日間)
deeksha h r
deeksha h r 2016 年 9 月 22 日
コメント済み: Image Analyst 2016 年 9 月 23 日
i'm doing a project to recognize kannada text,the first step says find connected components from a binarynimage.i tried doing it using bwconncomp but i'm not able to display the image.soo can u please help me with dis.

回答 (2 件)

Walter Roberson
Walter Roberson 2016 年 9 月 22 日
bwconncomp should work, or you could use bwlabel, or you could use regionprops
bwconncomp has an example where it reconstructs the binary image with one of the components missing.
For the moment I suggest you use bwlabel() and imshow() the result, as then the different components should come out in different colors.

Image Analyst
Image Analyst 2016 年 9 月 22 日
In short
% Do connected components labeling:
labeledImage = bwlabel(binaryImage);
% Let's assign each blob a different color to visually show the user the distinct blobs.
coloredLabels = label2rgb (labeledImage, 'hsv', 'k', 'shuffle'); % pseudo random color labels
% coloredLabels is an RGB image. We could have applied a colormap instead (but only with R2014b and later)
imshow(coloredLabels);
  4 件のコメント
Walter Roberson
Walter Roberson 2016 年 9 月 23 日
your binaryImage needs to be 2 dimensional. Watch out that your original image might be RGB when you are expecting it to be grayscale . In particular, if it is a JPEG image then even if it looks gray, it is much much more likely that it is RGB in which all of the colors happen to be shades of gray.
Image Analyst
Image Analyst 2016 年 9 月 23 日
try this possible fix
if ndims(binaryImage) > 2
% It's color
binaryImage = binaryImage(:,:,2) > 128;
else
% It's gray scale, but maybe not 0 and 1.
% Make sure it's logical, not 0 and 255 or something.
binaryImage = binaryImage > 0;
end

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

Community Treasure Hunt

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

Start Hunting!

Translated by