prune_branches

Import packages

[1]:
import numpy as np
import porespy as ps
import scipy.ndimage as spim
import matplotlib.pyplot as plt
import skimage
np.random.seed(0)

ps.visualization.set_mpl_style()

Generate images

[2]:
im = ps.generators.blobs(shape=[250, 250], blobiness=1, porosity=0.6)

plt.figure(figsize=[4, 4])
plt.axis(False)
plt.imshow(im);
../../../_images/examples_filters_howtos_prune_branches_4_0.svg

Apply filter function

iterations

[3]:
skel = skimage.morphology.skeletonize(im)
x = ps.filters.prune_branches(skel=skel, iterations=1)
xx = ps.filters.prune_branches(skel=skel, iterations=10)

fig, ax = plt.subplots(1, 3, figsize=[10, 4])
ax[0].imshow(skel/im)
ax[0].axis(False)
ax[0].axis(False)
ax[0].set_title('Original skeleton')
ax[1].imshow(x/im)
ax[1].axis(False)
ax[1].axis(False)
ax[1].set_title('After 1 iteration')
ax[2].imshow(xx/im)
ax[2].axis(False)
ax[2].axis(False)
ax[2].set_title('After 10 iterations');
../../../_images/examples_filters_howtos_prune_branches_7_0.svg