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 (ND-array) – 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 ND-array containing sets of slice objects for indexing into
imthat extract subdivisions of an image. If
True, then this array is flat, suitable for iterating. If
Falsethen the slice objects must be accessed by row, col, layer indices. An ND-array is the preferred container since it’s 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], flatten=True) >>> print(len(s)) 4
Click here to view online example.