Creating Multiscale Images#

Sometimes it is useful or necessary to study processes across multiple scales. It is possible to generate artificial images with 2 scales of porosity fairly easily.

import porespy as ps
import matplotlib.pyplot as plt
[12:38:20] ERROR    PARDISO solver not installed, run `pip install pypardiso`. Otherwise,          _workspace.py:56
                    simulations will be slow. Apple M chips not supported.                                         

Using blobs of different blobiness#

Start by creating one image at a large scale. Let’s use blobs to define the large scale ‘super-structure’:

im1 = ps.generators.blobs([500, 500], blobiness=0.5, porosity=0.6)
fig, ax = plt.subplots(1, 1, figsize=[6, 6])
ax.imshow(im1, interpolation='none')
ax.axis(False);
../../../_images/a42f24a81855d79c18d556872d81b2a305ca3951ab2a3cf6e0bf531c353d625a.png

Now we’ll can create a second image of blobs, but with a different scale. These will represent the ‘sub-structure’:

im2 = ps.generators.blobs([500, 500], blobiness=2.5, porosity=0.5)
fig, ax = plt.subplots(1, 1, figsize=[6, 6])
ax.imshow(im2, interpolation='none')
ax.axis(False);
../../../_images/9e1902d56d767a03ebe40494402b6741b8c9682ebe28033898c62f77759ea27e.png

Finally, we can multiply these two image (i.e. arrays) together, which will have the effect of perforating the foreground phase of im1 with holes defined by the background phase of im2. Note the inverting of the image to ensure the foreground and background are maintained:

im3 = ~(~im1*im2)
fig, ax = plt.subplots(1, 1, figsize=[6, 6])
ax.imshow(im3, interpolation='none')
ax.axis(False);
../../../_images/4f66f63decb12333ba3337e154a6b274d445b54029a12d9daf28125b7f8b2557.png

The pore sizes can be analyzed using local_thickess, to confirm a bi-modal pore size distribution:

lt = ps.filters.local_thickness(im3)
psd = ps.metrics.pore_size_distribution(lt)
ps.visualization.bar(psd);
../../../_images/2487da663ef05fe0d9a3257143e3485a3fb8ca73474c0474edaeef5e402e1f68.png

Using rsa to insert non-overlapping spheres into blobs#

Another way is to use rsa to insert spheres into the background of another image. Let’s use blobs to define the superstructure, the perforate it with holes:

im4 = ps.generators.rsa(im1, r=10, clearance=-2)
fig, ax = plt.subplots(1, 1, figsize=[6, 6])
ax.imshow(im4, interpolation='none')
ax.axis(False);
/tmp/ipykernel_7401/1658317612.py:1: DeprecationWarning: Call to deprecated function (or staticmethod) rsa. (This function will be renamed random_spheres in a future version)
  im4 = ps.generators.rsa(im1, r=10, clearance=-2)
../../../_images/09a7d465ae2ee6ce407be53b968348e7150755fac1871de9ebb480522d43b09d.png

Summary#

The concept of generate multiple images and different scales then superimposing them is a very easy to make some simple multiscale images for prototyping and testing workflows that require multiscale images.