polydisperse_spheres(shape: List[int], porosity: float, dist, nbins: int = 5, r_min: int = 5)[source]

Create an image of randomly place, overlapping spheres with a distribution of radii.

  • shape (list) – The size of the image to generate in [Nx, Ny, Nz] where Ni is the number of voxels in each direction. If shape is only 2D, then an image of polydisperse disks is returns

  • porosity (scalar) – The porosity of the image, defined as the number of void voxels divided by the number of voxels in the image. The specified value is only matched approximately, so it’s suggested to check this value after the image is generated.

  • dist (scipy.stats distribution object) – This should be an initialized distribution chosen from the large number of options in the scipy.stats submodule. For instance, a normal distribution with a mean of 20 and a standard deviation of 10 can be obtained with dist = scipy.stats.norm(loc=20, scale=10)

  • nbins (scalar) – The number of discrete sphere sizes that will be used to generate the image. This function generates nbins images of monodisperse spheres that span 0.05 and 0.95 of the possible values produced by the provided distribution, then overlays them to get polydispersivity.


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

Return type



Click here to view online example.