apply_chords_3D#

Adds chords to the void space in all three principle directions. The chords are seprated by 1 voxel plus the provided spacing. Chords in the X, Y and Z directions are labelled 1, 2 and 3 resepctively.

import numpy as np
import porespy as ps
import scipy.ndimage as spim
import matplotlib.pyplot as plt
ps.visualization.set_mpl_style()
[03:25:18] ERROR    PARDISO solver not installed, run `pip install pypardiso`. Otherwise,          _workspace.py:56
                    simulations will be slow. Apple M chips not supported.                                         
import inspect
print(inspect.signature(ps.filters.apply_chords_3D))
(im, spacing: int = 0, trim_edges: bool = True)

im#

The function takes a boolean image with True values indicating the void space, or phase of interest.

im = ps.generators.blobs(shape=[50, 50, 50])
chords = ps.filters.apply_chords_3D(im)

fig, ax = plt.subplots(1, 2, figsize=[12, 6])
ax[0].imshow(chords[20, ...] + ~im[20, ...]*4)
ax[0].axis(False)
ax[1].imshow(chords[22, ...] + ~im[22, ...]*4)
ax[1].axis(False);
../../../_images/b0ae1419f50cadd711bcf291aea2f52869d04e5d150e080635b916dfd999cc13.png

The chords in each direction are given different integer values so they can isolated by thresholding.

fig, ax = plt.subplots(1, 1, figsize=[6, 6])
ax.imshow(chords[20, ...] ==2)
ax.axis(False);
../../../_images/ea20c436088fec1f8393591d781a0788bff0a2c11a1329aaa51aaa073e3ab6c1.png

spacing#

By default the chords are drown with a spacing of 1 voxel between each orientation to provide the maximum number of chords. This can be adjusted to create few chords if the image is very large if needed.

c1 = ps.filters.apply_chords_3D(im, spacing=1)
c3 = ps.filters.apply_chords_3D(im, spacing=3)

fig, ax = plt.subplots(1, 2, figsize=[12, 6])
ax[0].imshow(c1[20, ...] + ~im[20, ...]*4)
ax[0].axis(False)
ax[1].imshow(c3[30, ...] + ~im[30, ...]*4)
ax[1].axis(False);
../../../_images/743266f3759ff49412d01fdc4cc96941110de1b69cbdca5d6645155d5915b956.png

trim_edges#

c1 = ps.filters.apply_chords_3D(im, trim_edges=False)
c2 = ps.filters.apply_chords_3D(im, trim_edges=True)

fig, ax = plt.subplots(1, 2, figsize=[12, 6])
ax[0].imshow(c1[20, ...] + ~im[20, ...]*4)
ax[0].axis(False)
ax[0].set_title('trim_edges = False')
ax[1].imshow(c2[20, ...] + ~im[20, ...]*4)
ax[1].axis(False)
ax[1].set_title('trim_edges = True');
../../../_images/6f3e0718a53fe5641e7c202d5d8ab8c77bb6608e4a8fd6c4b9c90d82a4d44b05.png