percolating_porosity#

This function computes the fraction of the entire image occupied by void space which percolates along a given axis or between specified inlets and outlets. The number of percolating void voxels is divided by the total number of voxels in the image, including solid voxels.

import porespy as ps
import numpy as np
import matplotlib.pyplot as plt

ps.visualization.set_mpl_style()

im#

The image of the void space to analyze

eps = np.linspace(0.01, 0.99, 25)
perc = []
for e in eps:
    im = ps.generators.blobs([100, 100], porosity=e, seed=2)
    tmp = ps.metrics.percolating_porosity(im)
    perc.append(tmp)
fig, ax = plt.subplots(figsize=[4, 4])
ax.plot(eps, perc, "b.-")
ax.set_xlabel("Total porosity")
ax.set_ylabel("Percolating porosity");
../../../_images/ceb9f2fbe38bc310b48d80404e741bdea69c648cafbf7fd678d4ed99b8e66520.png

axis vs inlets and outlets#

Since percolation is direction dependent it is necessary to specify the axis along which percolation should be checked. The default is axis=0, but this can be set to 1 or 2. Alternatively it is possible to specify inlets and outlets as a pair of boolean images with True values indicate the inlet and outlet pixels/voxels. For instance consider the following image which percolates from left to right, but not top to bottom:

im = ps.generators.blobs([100, 100], porosity=0.55, seed=5)
fig, ax = plt.subplots(figsize=[4, 4])
ax.imshow(im)
ax.axis(False);
../../../_images/9b8eb7113e04308c37c68dbf154efad002ba826c27f0ac6a275234acffef8a6a.png
eps_0 = ps.metrics.percolating_porosity(im, axis=0)
eps_1 = ps.metrics.percolating_porosity(im, axis=1)

print(f"The percolating porosity in the x and y directions is {eps_0} and {eps_1}")
The percolating porosity in the x and y directions is 0.0 and 0.2621

conn#

The conn argument can be set to min or max and controls how pixels must be connected when looking for percolation. For min this means 4 neighbors in 2D and 6 in 3D, while max means 8 neighbors in 2D and 26 in 3D.

im = ps.generators.blobs([100, 100], porosity=0.5, seed=4)
fig, ax = plt.subplots(figsize=[4, 4])
ax.imshow(im)
ax.axis(False);
../../../_images/a8ebefe8cb709fa6547981c616ff2c013f3832e0fa03ff0fe2e8da6809444911.png

The above image has a cluster on the left side which is only connected to the percolating cluster via corners, so the percolating porosity will differ depending on the conn argument.

eps_min = ps.metrics.percolating_porosity(im, axis=1, conn="min")
eps_max = ps.metrics.percolating_porosity(im, axis=1, conn="max")

print(f"The percolating porosity in the x and y directions is {eps_min} and {eps_max}")
The percolating porosity in the x and y directions is 0.2703 and 0.3013