find endpoint coordinates(x,y) of connected components using pixelidxlist
4 ビュー (過去 30 日間)
古いコメントを表示
raw_image:
*
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/165054/image.png)
*
CC = bwconncomp(zz_out);
numPixels = cellfun(@numel,CC.PixelIdxList);
figure, imshow(zz_out);
[smallest,idx] = min(numPixels);
zz_out(CC.PixelIdxList{idx}) = 0;
- I have an image which has some concurrent connected components, say as: line segments.Now i want to extract all the endpoint's coordinates(x,y) of those lines using pixelidlist.*
0 件のコメント
回答 (1 件)
Walter Roberson
2017 年 6 月 11 日
bwmorph() and ask for 'endpoints'
3 件のコメント
Walter Roberson
2017 年 6 月 11 日
[L, Num] = bwlabel(zz_out);
for K = 1 : Num
[epr{K}, epc{K}] = find( bwmorph(L == K, 'endpoints') );
end
Now epr{K} is the list of row indices of all of the endpoints of component #K, and epc{K} is the corresponding list of column indices. Any component that is not an isolated pixel should have at least two endpoints, and could have more if there are branches in it. (Note, though: I do not know how endpoint detection works if there are loops in the component.)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!