apply_chords#

Adds chords to the void space in the specified direction

import matplotlib.pyplot as plt

import porespy as ps

ps.visualization.set_mpl_style()

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/6c426f166bd2f9d7630970128c9ae11fd2eecf470187069a08b8e1e3f8fa1036.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/f34874aa790d283fcef3ff468461a9ebfb82d076c2f40d06e6a2c416a3ae3e49.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/d5e9e51665ebb3afc5770be01489ecc6330c801cd696a7529a4f9f024930ade2.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/356f4a89c8f81d5b1a15f99a9c5e99a7cc8630a244f26dc75bb9dc6688bc5b11.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/f5af70728a6a19055fa524c930df8e86fb1899365dc985cfa458b4380808768c.png