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!