Borrar filtros
Borrar filtros

How to find connected components ?

2 visualizaciones (últimos 30 días)
ezhil K
ezhil K el 6 de Feb. de 2019
Comentada: Shunichi Kusano el 6 de Feb. de 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);

Respuesta aceptada

Shunichi Kusano
Shunichi Kusano el 6 de Feb. de 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 comentarios
ezhil K
ezhil K el 6 de Feb. de 2019
How should I use the code in the link.I don't understand.Can u please help me?
Shunichi Kusano
Shunichi Kusano el 6 de Feb. de 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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Images en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by