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()
[01:57:00] ERROR    PARDISO solver not installed, run `pip install pypardiso`. Otherwise,          _workspace.py:56
                    simulations will be slow. Apple M chips not supported.                                         

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/2d5c60092998aed14e1a205b566fa84cd0e02b1a8f3da60888d0369159c9d189.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/d557b70b6731367a08a9b203b8878d77947e6dfcfd63add04f656b01e028b833.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/98d228d19df4d39901871074c8be70c24a67119d591a2cae38b5c54375e48f27.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/613cffea7172d17b357531c976090d3a1040dd613d86e1570f49ee242aef3234.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/85a16c02d4434c8754028d29a29b08be74e558d9821cbc9a66e4096704218686.png