![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/172186/image.png)
Remove the spurious edge of skeleton
12 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hong
il 26 Set 2013
Commentato: Lukas Pollmann
il 6 Mag 2020
Recently, I've had an object to get it's skeleton,and then simplified the skeleton
but my problem is how to remove the edge of the skeleton for simplified the skeleton
here is my few steps:
First,I've got the skeleton from my object with bwmorph(ima,'skel',Inf)
here is the object which has been filled and the skeleton below:
filling the object:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/150082/image.jpeg)
the skeleton:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/150083/image.jpeg)
Second,for the skeleton, I've mark the branch points and end points
to mark the branch points and end points,I use bwmorph(skel, 'branchpoints') and
bwmorph(skel, 'endpoints');
here is the figure that I marked the points below:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/150085/image.jpeg)
the reds are branch points
the blues are end points
and the last step,
from the above figure, I want to remove the edges between branch point and end point (here I call the edge is spurious edge)
here is the resulting figure that I want
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/150086/image.jpeg)
my problem is how can I remove the spurious edges
I've referenced this article
and the suggestions are set the threshold of the distance
but in my situation,the lengths of the spurious edges may have too long or too short...
0 Commenti
Risposta accettata
Teja Muppirala
il 26 Set 2013
I think there must be a more efficient way to do it, but this at least works. BWDISTGEODESIC starts at a given point, and then calculates the distance as you travel along the path. Start at a endpoint, start walking and find all pixels that are closer than the nearest branchpoint. Then remove those pixels.
skel= bwmorph(ima,'skel',Inf);
B = bwmorph(skel, 'branchpoints');
E = bwmorph(skel, 'endpoints');
[y,x] = find(E);
B_loc = find(B);
Dmask = false(size(skel));
for k = 1:numel(x)
D = bwdistgeodesic(skel,x(k),y(k));
distanceToBranchPt = min(D(B_loc));
Dmask(D < distanceToBranchPt) =true;
end
skelD = skel - Dmask;
imshow(skelD);
hold all;
[y,x] = find(B); plot(x,y,'ro')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/172186/image.png)
2 Commenti
moahaimen talib
il 6 Mar 2017
bwmorph(I3, 'spur', 7); is that pruning and is there is pruning instruction in matlab?
Lukas Pollmann
il 6 Mag 2020
Più risposte (2)
Liana Norazmi
il 7 Mag 2015
May i know how to remove the lines of this image
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/176637/image.jpeg)
become like this?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/176638/image.jpeg)
1 Commento
Karthick Jayaraman
il 29 Ago 2019
Is there any possibility yo do this in 3D logical array. I guess bwdistgeodesic doest work well in 3D. Any suggestions would be helful!?
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!