flood#

Floods each region with a specific value based on a specified statistical operation performed on values in that region.

Import packages#

import numpy as np
import porespy as ps
import scipy.ndimage as spim
import matplotlib.pyplot as plt
import skimage
from edt import edt
ps.visualization.set_mpl_style()
/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/openpnm/algorithms/_invasion_percolation.py:358: NumbaDeprecationWarning: The 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details.
  def _find_trapped_pores(inv_seq, indices, indptr, outlets):  # pragma: no cover

im#

The distance transform can have statistical calculations performed

im = ps.generators.blobs(shape=[200, 200])
dt = edt(im)

plt.figure(figsize=[6, 6])
plt.imshow(dt/im)
plt.axis(False);
../../../_images/cbb9b63ec2ddb82e73f621b8682d471e9f469bdec9d79f055ba2fde426d439fc.png

labels#

snow_partitioning can be used to create regions

regions = ps.filters.snow_partitioning(im, r_max=4, sigma=0.4)
labels = regions.regions

plt.figure(figsize=[6, 6])
plt.imshow(labels/im)
plt.axis(False);
../../../_images/b83ae91aea5448eea63c38fbf83a1a96674d352cddec134c7384f9f2340d0d96.png

mode#

Various functions in scipy.ndimage.measurements are called to perform statistical calculation. The mode indicates which function to call.

x1 = ps.filters.flood(im=dt, labels=labels, mode='max')
x2 = ps.filters.flood(im=dt, labels=labels, mode='mean')
x3 = ps.filters.flood(im=dt, labels=labels, mode='sum')

fig, ax = plt.subplots(1, 3, figsize=[18, 18])
ax[0].imshow(x1)
ax[0].axis(False)
ax[0].set_title('mode = max')
ax[1].imshow(x2)
ax[1].axis(False)
ax[1].set_title('mode = mean')
ax[2].imshow(x3)
ax[2].axis(False)
ax[2].set_title('mode = sum');
../../../_images/9c67cca557247e62795ba84478b13fe182d90b5404ad478e0feae3dd926dde9f.png