incorrect results from bwconncomp
이전 댓글 표시
I would like to understand how to correctly use the bwconncomp function, as the results I get do not make sense. Here is my problem. I have a binary image of edges like so:

It has been preprocessed to remove all vertices. I want to identify all the edges individually, so I ran the code:
CC1 = bwconncomp(E1);
It says there are only 13 objects, which looks highly suspect, so I pull up the first object like this:
%create cell array of edge matrices
numPixels1 = length(CC1.PixelIdxList);
edges1 = cell(num_1,1);
for ii = 1:num_1
pix = CC1.PixelIdxList{ii};
[rows,cols] = ind2sub(size(E1),pix);
r = max(rows)-min(rows)+1;
c = max(cols)-min(cols)+1;
mat = zeros(r,c);
rows = rows - min(rows)+1;
cols = cols - min(cols)+1;
inds = sub2ind([r,c],rows,cols);
mat(inds) = 1;
edges1{ii} = mat;
end
%show first element
figure;imshow(edges1{1})
And I get this:

I don't understand how counting connected components would actually connect those components before counting, it seems precisely in oppposition to the goal. Please help to clarify the use of this function.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Images에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!