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()
[17:43:17] 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/553d7f713f54973280e5bcbdcbc7d41de836213c35095a734bda3e6b4133f8fc.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/c2f4ab1e950f34e7ff1b1cdd4e3c9f5df19dcac3440e4c76479fe790a821ff89.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/7ca1f100393fd87330f8e8f652bca28a649b9462edd8db2ac7f757af0e8b5e99.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/4ca8c6e2feb99ec1f447e7647e7bd9ef0942d3e77e6f1da136d19f40bd7a8501.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/63cb697b8af9edd028bb350a273b24226eeff8a2e83c6b76cfc634a4254c0da2.png