distance_transform_lin

Import packages

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

Create image and variables

[2]:
im = ps.generators.blobs(shape=[500, 500])
plt.figure(figsize=[7,7])
plt.axis(False)
plt.imshow(im);

#default values:
axis=0
mode = "both"
../../../_images/examples_filters_howtos_distance_transform_lin_4_0.png

Apply filter function

axis

[3]:
x = ps.filters.distance_transform_lin(im=im, axis=axis, mode=mode)
xx = ps.filters.distance_transform_lin(im=im, axis=1, mode=mode)
fig, ax = plt.subplots(1, 2, figsize=[20, 20]);
ax[0].imshow(x);
ax[0].axis(False)
ax[1].imshow(xx);
ax[1].axis(False)
ax[0].set_title('axis = 0')
ax[1].set_title('axis = 1');
../../../_images/examples_filters_howtos_distance_transform_lin_7_0.png

mode

[4]:
xx = ps.filters.distance_transform_lin(im=im, axis=axis, mode="forward")
xxx = ps.filters.distance_transform_lin(im=im, axis=axis, mode="reverse")
fig, ax = plt.subplots(1, 3, figsize=[20, 20]);
ax[0].imshow(x);
ax[0].axis(False)
ax[1].imshow(xx);
ax[1].axis(False)
ax[2].imshow(xxx);
ax[2].axis(False)
ax[0].set_title('mode = both')
ax[1].set_title('mode = forward')
ax[2].set_title('mode = reverse');
../../../_images/examples_filters_howtos_distance_transform_lin_9_0.png