필터 지우기
필터 지우기

How to find connected components ?

조회 수: 2 (최근 30일)
ezhil K
ezhil K 2019년 2월 6일
댓글: Shunichi Kusano 2019년 2월 6일
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);

채택된 답변

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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by