overlapping_spheres(shape: List[int], r: int, porosity: float, maxiter: int = 10, tol: float = 0.01)[source]#

Generate a packing of overlapping mono-disperse spheres

  • 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.


image – A boolean array with True values denoting the pore space

Return type:



This method can also be used to generate a dispersion of hollows by treating porosity as solid volume fraction and inverting the returned image.


Click here to view online example.