Calculates the porosity of the image as a function subdomain size. This function extracts a specified number of subdomains of random size, then finds their porosity.
im (ND-array) – The image of the porous material
npoints (int) – The number of randomly located and sized boxes to sample. The default is 1000.
result – A tuple containing the volume and porosity of each subdomain tested in arrays
npointslong. They can be accessed as attributes of the tuple. They can be conveniently plotted by passing the tuple to matplotlib’s
plotfunction using the * notation:
plt.plot(*result, 'b.'). The resulting plot is similar to the sketch given by Bachmat and Bear 
- Return type
This function is frustratingly slow. Profiling indicates that all the time is spent on scipy’s
sumfunction which is needed to sum the number of void voxels (1’s) in each subdomain.
Also, this function is a prime target for parallelization since the
npointsare calculated independenlty.
 Bachmat and Bear. On the Concept and Size of a Representative Elementary Volume (Rev), Advances in Transport Phenomena in Porous Media (1987)
Click here to view online example.