- subdivide(im, divs=2, overlap=0)#
Returns slices into an image describing the specified number of sub-arrays.
This function is useful for performing operations on smaller images for memory or speed. Note that for most typical operations this will NOT work, since the image borders would cause artifacts (e.g.
im (ndarray) – The image of the porous media
divs (scalar or array_like) – The number of sub-divisions to create in each axis of the image. If a scalar is given it is assumed this value applies in all dimensions.
overlap (scalar or array_like) – The amount of overlap to use when dividing along each axis. If a scalar is given it is assumed this value applies in all dimensions.
slices – An ndarray containing sets of slice objects for indexing into
imthat extract subdivisions of an image. If
True, then this array is suitable for iterating. If
Falsethen the slice objects must be accessed by row, col, layer indices. An ndarray is the preferred container since its shape can be easily queried.
- Return type:
>>> import porespy as ps >>> import matplotlib.pyplot as plt >>> im = ps.generators.blobs(shape=[200, 200]) >>> s = ps.tools.subdivide(im, divs=[2, 2]) >>> print(len(s)) 4
Click here to view online example.