Effacer les filtres
Effacer les filtres

How to find connected components ?

2 vues (au cours des 30 derniers jours)
ezhil K
ezhil K le 6 Fév 2019
Commenté : Shunichi Kusano le 6 Fév 2019
I am using bwconncomp() to find the connected components in an image.But,I get error.What can I do to rectify it?
Error:
Error using imageDisplayValidateParams
Expected input number 1, I, to be one of these types:
double, single, uint8, uint16, uint32, uint64, int8, int16, int32, int64, logical
Instead its type was struct.
Error in images.internal.imageDisplayValidateParams (line 11)
validateattributes(common_args.CData, {'numeric','logical'},...
Error in images.internal.imageDisplayParseInputs (line 78)
common_args = images.internal.imageDisplayValidateParams(common_args);
Error in imshow (line 245)
images.internal.imageDisplayParseInputs({'Parent','Border','Reduce'},preparsed_varargin{:});
Error in shitomashi1 (line 70)
figure,imshow(cc);
bwim1=adaptivethreshold(I,11,0.03,0);
figure,imshow(bwim1);
cc=bwconncomp(bwim1);
figure,imshow(cc);

Réponse acceptée

Shunichi Kusano
Shunichi Kusano le 6 Fév 2019
The error seems to come from "imshow" function, since cc is not an image, but a structure.
You need to convert cc to labelimage by "labelmatrix", then show it by "imshow".
The following URL is helpful:
  2 commentaires
ezhil K
ezhil K le 6 Fév 2019
How should I use the code in the link.I don't understand.Can u please help me?
Shunichi Kusano
Shunichi Kusano le 6 Fév 2019
This is one example:
labeled_image = labelmatrix(cc); % labeling each compoent
RGB_label = label2rgb(labeled,'spring','c','shuffle'); % colorization
imshow(RGB_label) % visualization
To see one of the connected component, please command like this:
A = false(size(bw)); % zero image
grain(cc.PixelIdxList{1}) = true; % input one to the area of the 1st component
imshow(grain) % visualization
hope this works.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Images dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by