Azzera filtri
Azzera filtri

how to find connected component in an image

9 visualizzazioni (ultimi 30 giorni)
deeksha h r
deeksha h r il 22 Set 2016
Commentato: Image Analyst il 23 Set 2016
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.

Risposte (2)

Walter Roberson
Walter Roberson il 22 Set 2016
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 il 22 Set 2016
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 Commenti
Walter Roberson
Walter Roberson il 23 Set 2016
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 il 23 Set 2016
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

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by