Grow lines along path
Afficher commentaires plus anciens
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!
Réponses (1)
darova
le 10 Mai 2019
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

1 commentaire
Victor Churchill
le 11 Mai 2019
Catégories
En savoir plus sur Morphological Operations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!