subdivide
#
Import packages#
import numpy as np
import porespy as ps
import scipy.ndimage as spim
import matplotlib.pyplot as plt
import skimage
np.random.rand(0)
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
Create image and variables#
im = ps.generators.blobs([500, 500])
fig, ax = plt.subplots(1, 1, figsize=[4, 4])
ax.axis(False)
ax.imshow(im, origin='lower');

Apply tool#
slice
objects are returned:
slices = ps.tools.subdivide(im=im, divs=2, overlap=20)
print(slices)
[(slice(0, 270, None), slice(0, 270, None)), (slice(0, 270, None), slice(230, 500, None)), (slice(230, 500, None), slice(0, 270, None)), (slice(230, 500, None), slice(230, 500, None))]
fig, ax = plt.subplots(1, 4, figsize=[8, 2])
for i, s in enumerate(slices):
ax[i].imshow(im[s], origin='lower')
ax[i].axis(False);
