subdivide

Import packages

[1]:
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()

Create image and variables

[2]:
im = ps.generators.blobs([500, 500])
fig, ax = plt.subplots(1, 1, figsize=[4, 4])
ax.axis(False)
ax.imshow(im, origin='lower');
../../../_images/examples_tools_howtos_subdivide_4_0.svg

Apply tool

slice objects are returned:

[3]:
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))]
[4]:
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/examples_tools_howtos_subdivide_7_0.svg