Skip to content

originlake/DSE-skeleton-pruning

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DSE

Python implementation of discrete skeleton evolution, a skeleton pruning algorithm http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.79.8377&rep=rep1&type=pdf

Setup

pip install -e .

Example This algorithm filters out branches by evalutating their reconstruction weights. Original paper measures the weights by calculating the ratio of reconstruction pixel loss to whole reconstruction pixel, here the weights are simply the reconstruction pixel loss.

from dsepruning import skel_pruning_DSE
import numpy as np
from skimage.io import imread
from skimage.morphology import medial_axis, skeletonize
from scipy.ndimage import distance_transform_edt
import matplotlib
import matplotlib.pyplot as plt
matplotlib.rcParams['figure.figsize'] = [10, 10]
mask = imread('img/skel.png')
mask = mask > 0
plt.imshow(mask)
plt.show()

png

skel = skeletonize(mask)
print("Show skeleton by skeletonize:")
plt.imshow(skel);plt.show()
dist = distance_transform_edt(mask, return_indices=False, return_distances=True)
print("Show distance map:")
plt.imshow(dist);plt.show()
new_skel = skel_pruning_DSE(skel, dist, 100)
print("Show pruned skeleton")
plt.imshow(new_skel);plt.show()
Show skeleton by skeletonize:

png

Show distance map:

png

Show pruned skeleton

png

skel, dist = medial_axis(mask, return_distance=True)
print("Show skeleton by skeletonize:")
plt.imshow(skel);plt.show()
print("Show distance map:")
plt.imshow(dist);plt.show()
new_skel = skel_pruning_DSE(skel, dist, 100)
print("Show pruned skeleton")
plt.imshow(new_skel);plt.show()
Show skeleton by medial_axis:

png

Show distance map:

png

Show pruned skeleton

png

About

Python implementation of discrete skeleton evolution

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published