apply_chords

Import packages

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

ps.visualization.set_mpl_style()

Generate image for testing

[2]:
im = ps.generators.blobs(shape=[100, 100], porosity=0.7)
plt.figure(figsize=[4, 4])
plt.axis(False)
plt.imshow(im)

spacing = 1
axis = 0
trim_edges = True
label = False
../../../_images/examples_filters_howtos_apply_chords_4_0.svg

Apply filter function

spacing

[3]:
x = ps.filters.apply_chords(im=im,
                            spacing=spacing,
                            axis=axis,
                            trim_edges=trim_edges,
                            label=label)
xx = ps.filters.apply_chords(im=im,
                             spacing=3,
                             axis=axis,
                             trim_edges=trim_edges,
                             label=label)

fig, ax = plt.subplots(1, 2, figsize=[8, 4])
ax[0].imshow(x)
ax[1].imshow(xx)
ax[0].axis(False)
ax[1].axis(False)
ax[0].set_title('spacing = 1')
ax[1].set_title('spacing = 3');
../../../_images/examples_filters_howtos_apply_chords_7_0.svg

axis

[4]:
xx = ps.filters.apply_chords(im=im,
                             spacing=spacing,
                             axis=1,
                             trim_edges=trim_edges,
                             label=label)

fig, ax = plt.subplots(1, 2, figsize=[8, 4])
ax[0].imshow(x)
ax[1].imshow(xx)
ax[0].axis(False)
ax[1].axis(False)
ax[0].set_title('axis = 0')
ax[1].set_title('axis = 1');
../../../_images/examples_filters_howtos_apply_chords_9_0.svg

trim_edges

[5]:
xx = ps.filters.apply_chords(im=im,
                             spacing=spacing,
                             axis=axis,
                             trim_edges=False,
                             label=label)

fig, ax = plt.subplots(1, 2, figsize=[8, 4])
ax[0].imshow(x)
ax[1].imshow(xx)
ax[0].axis(False)
ax[1].axis(False)
ax[0].set_title('trim_edges = True')
ax[1].set_title('trim_edges = False');
../../../_images/examples_filters_howtos_apply_chords_11_0.svg

label

[6]:
xx = ps.filters.apply_chords(im=im,
                             spacing=spacing,
                             axis=axis,
                             trim_edges=trim_edges,
                             label=True)

fig, ax = plt.subplots(1, 2, figsize=[8, 4])
ax[0].imshow(x)
ax[1].imshow(xx)
ax[0].axis(False)
ax[1].axis(False)
ax[0].set_title('label = False')
ax[1].set_title('label = True');
../../../_images/examples_filters_howtos_apply_chords_13_0.svg