overlapping_spheres¶
- overlapping_spheres(shape: List[int], r: int = 5, porosity: float = 0.5, maxiter: int = 10, tol: float = 0.01, seed: int = None)[source]¶
Generate a packing of overlapping mono-disperse spheres
- Parameters:
shape (list) – The size of the image to generate in [Nx, Ny, Nz] where Ni is the number of voxels in the i-th direction.
r (scalar) – The radius of spheres in the packing.
porosity (scalar) – The porosity of the final image, accurate to the given tolerance.
maxiter (int) – Maximum number of iterations for the iterative algorithm that improves the porosity of the final image to match the given value.
tol (float) – Tolerance for porosity of the final image compared to the given value.
seed (int, optional, default = None) – Initializes numpy’s random number generator to the specified state. If not provided, the current global value is used. This means calls to
np.random.state(seed)
prior to calling this function will be respected.
- Returns:
image – A boolean array with
True
values denoting the pore space- Return type:
ndarray
Notes
This method can also be used to generate a dispersion of hollows by treating
porosity
as solid volume fraction and inverting the returned image.Examples
Click here to view online example.