pseudo_electrostatic_packing#
- pseudo_electrostatic_packing(im, r, sites=None, clearance=0, protrusion=0, edges='extended', maxiter=1000, seed=None)[source]#
Iterativley inserts spheres as close to the given sites as possible.
- Parameters:
im (ndarray) – Image with
True
values indicating the phase where spheres should be inserted.r (int) – Radius of spheres to insert.
sites (ndarray (optional)) – An image with
True
values indicating the electrostatic attraction points. If this is not given then the peaks in the distance transform are used.clearance (int (optional, default=0)) – The amount of space to put between each sphere. Negative values are acceptable to create overlaps, but
abs(clearance) < r
.protrusion (int (optional, default=0)) – The amount that spheres are allowed to protrude beyond the active phase.
maxiter (int (optional, default=1000)) – The maximum number of spheres to insert.
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:
im – An image with inserted spheres indicated by
True
- Return type:
ndarray
Examples
Click here to view online example.