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()
[03:27: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');
../../../_images/98804ef8d826ac226ddcc0ca06293e1c5a07a64d86871b2521a8c88221436f8c.png

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);
../../../_images/fed33c0391409bf66cf26567b01c3ac94a2da02c392abddba75bd10d1dbfeb10.png