pseudo_gravity_packing#
- pseudo_gravity_packing(im, r, clearance=0, axis=0, maxiter=1000, edges='contained', seed=None)[source]#
Iteratively inserts spheres at the lowest accessible point in an image, mimicking a gravity packing.
- Parameters:
im (ndarray) – Image with
True
values indicating the phase where spheres should be inserted. A common option would be a cylindrical plug which would result in a tube filled with beads.r (int) – The radius of the spheres to be added
clearance (int (default is 0)) – The amount space to add between neighboring spheres. The value can be negative for overlapping spheres, but
abs(clearance) > r
.axis (int (default is 0)) – The axis along which gravity acts.
maxiter (int (default is 1000)) – The maximum number of spheres to add
edges (string (default is 'contained')) –
Controls how spheres at the edges of the image are handled. Options are:
edges
description
’contained’
Spheres are all completely within the image
’extended’
Spheres are allowed to extend beyond the edge of the image. In this mode the volume fraction will be less that requested since some spheres extend beyond the image, but their entire volume is counted as added for computational efficiency.
seed (int, optional, default = None) – The seed to supply to the random number generator. Because this function uses
numba
for speed, calling the normalnumpy.random.seed(<seed>)
has no effect. To get a repeatable image, the seed must be passed to the function so it can be initialized the waynumba
requires. The default isNone
, which means each call will produce a new realization.
- Returns:
spheres – An image the same size as
im
with spheres indicated byTrue
. The spheres are only inserted at locations that are accessible from the top of the image.- Return type:
ndarray
Examples
Click here to view online example.