Grow lines along path
1 回表示 (過去 30 日間)
古いコメントを表示
Here is a black image with some white lines. I would like to grow these lines to be a single connected component that hits the boundary and is as thin as possible. I have tried 'imdilate' but then when I try to thin or skeletonize it with 'bwmorph' it disconnects from the boundary. So alternatively, I just need a skeletonization/thinning code that doesn't remove boundary points.
Any ideas? Thank you!
0 件のコメント
回答 (1 件)
darova
2019 年 5 月 10 日
clc,clear
I = imread('bw.jpg');
I1 = im2bw(rgb2gray(I));
% crop black rectangle first
[i1, j1] = find(~I1,1,'first');
[i2, j2] = find(~I1,1,'last');
I2 = I1(i1:i2,j1:j2);
I3 = imdilate(I2,true(7,7));
I4 = bwmorph(I3,'skel',inf);
I5 = bwmorph(I4,'spur',inf);
I1(i1:i2,j1:j2) = I5;
imshow(I1)
Don't know how to get rid of those spurs now
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!