Import Packages#

import numpy as np
import porespy as ps
import scipy.ndimage as spim
import matplotlib.pyplot as plt
import skimage
/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

Generate Image for Testing#

im = ps.generators.blobs([100, 100, 100])

Apply tool and visualize#

This tool is useful for extracting a cylindrical core from an otherwise cubic image. This might be helpful if a cylindrical domain is needed, or to test a workflow on a tomogram that has has not been cropped yet.

cyl = ps.tools.extract_cylinder(im=im, r=40, axis=2)

fig, ax = plt.subplots(1, 2, figsize=[8, 4]);
ax[0].imshow(im[..., 50]);
ax[1].imshow(cyl[..., 50]);