extract_subsection
#
Import packages#
import numpy as np
import porespy as ps
import scipy.ndimage as spim
import matplotlib.pyplot as plt
import skimage
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
Generate image for testing#
im = np.random.rand(100, 100)
fig, ax = plt.subplots(figsize=[4, 4])
ax.axis(False)
ax.imshow(im)
<matplotlib.image.AxesImage at 0x7f994c6fe880>

Demonstration#
This tool was designed to ‘uppad’ an image that has had an equal amount of padding applied to all sides. The arguments assume that you know the original size of the image and wish to retrieve it back:
im2 = np.pad(im, pad_width=20, constant_values=0)
im = ps.tools.extract_subsection(im=im2, shape=im.shape)
fig, ax = plt.subplots(1, 2, figsize=[8, 4])
ax[0].axis(False)
ax[0].imshow(im2);
ax[1].axis(False)
ax[1].imshow(im);
