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()
[01:03:38] ERROR    PARDISO solver not installed, run `pip install pypardiso`. Otherwise,          _workspace.py:56
                    simulations will be slow. Apple M chips not supported.                                         

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, np.int64(270), None), slice(0, np.int64(270), None)), (slice(0, np.int64(270), None), slice(np.int64(230), np.int64(500), None)), (slice(np.int64(230), np.int64(500), None), slice(0, np.int64(270), None)), (slice(np.int64(230), np.int64(500), None), slice(np.int64(230), np.int64(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);