- RSA(im_or_shape: numpy.array, r: int, volume_fraction: int = 1, clearance: int = 0, n_max: int = 100000, mode: str = 'contained', return_spheres: bool = False, smooth: bool = True)¶
Generates a sphere or disk packing using Random Sequential Addition
im_or_shape (ndarray or list) – To provide flexibility, this argument accepts either an image into which the spheres are inserted, or a shape which is used to create an empty image. In both cases the spheres are added as
Truevalues to the background. Since
Trueis considered the pore space, then the added spheres represent holes.
r (int) – The radius of the disk or sphere to insert.
volume_fraction (scalar (default is 1.0)) – The fraction of the image that should be filled with spheres. The spheres are added as
True’s, so each sphere addition increases the
volume_fractionuntil the specified limit is reached. Note that if
n_maxis reached first, then
volume_fractionwill not be acheived. Also,
volume_fractionis not counted correctly if the
clearance (int (optional, default = 0)) – The amount of space to put between each sphere. Negative values are acceptable to create overlaps, so long as
abs(clearance) < r.
n_max (int (default is 100,000)) – The maximum number of spheres to add. Using a low value may halt the addition process prior to reaching the specified
Noneis given, then no limit is used.
mode (string (default is 'contained')) –
Controls how the edges of the image are handled. Options are:
Spheres are all completely within the image
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.
return_spheres (bool) – If
Truethen an image containing only the spheres is returned rather than the input image with the spheres added, which is the default behavior.
smooth (bool) – Indicates whether balls should have smooth faces (
True) or should include the bumps on the extremities (
image – An image with spheres of specified radius added to the background.
- Return type
This algorithm ensures that spheres do not overlap but does not guarantee they are tightly packed.
This function adds spheres to the background of the received
im, which allows iteratively adding spheres of different radii to the unfilled space by repeatedly passing in the result of previous calls to RSA.
 Random Heterogeneous Materials, S. Torquato (2001)
Click here to view online example.