필터 지우기
필터 지우기

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