apply_chords#

Adds chords to the void space in the specified direction

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()
/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/openpnm/algorithms/_invasion_percolation.py:358: NumbaDeprecationWarning: The 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details.
  def _find_trapped_pores(inv_seq, indices, indptr, outlets):  # pragma: no cover

shape#

shape = [200, 200]
im = ps.generators.blobs(shape=shape, porosity=0.4)
fig, ax = plt.subplots(1, 1, figsize=[4, 4])
ax.imshow(im, origin='lower', interpolation='none')
ax.axis(False);
../../../_images/4ce0803cf4795f5b626660547d88f37ad7e629858d60852bd12b9a60ac7b9eba.png

spacing#

Separation between chords. The default is 1 voxel. This can be decreased to 0, meaning that the chords all touch each other, which automatically sets to the label argument to True

x = ps.filters.apply_chords(im=im, spacing=1)
xx = ps.filters.apply_chords(im=im, spacing=3)


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/ba1cc7a3570d79920145bc19d6cd927a58d5056487817a2eb51a3163964dabf3.png

axis#

The axis along which the chords are drawn.

xx = ps.filters.apply_chords(im=im, axis=1)

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/6000be2954643cdf93fb8d0f447214cdaca73e0129e9e23f9c8b6a375a48a44d.png

trim_edges#

Whether or not to remove chords that touch the edges of the image. The default is True.

xx = ps.filters.apply_chords(im=im, trim_edges=False)

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/63387331561a23d0ce6957ce5493f10752294db29bd01086dc87938670d81ee2.png

label#

If True the chords in the returned image are each given a unique label, such that all voxels lying on the same chord have the same value. This is automatically set to True if spacing is 0, but is False otherwise.

xx = ps.filters.apply_chords(im=im, 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/20713018746f40871778dfaf9e0c6694107ce3d1e323789d8e9d18593b1b6193.png