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
[03:04:32] 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/c6bfe97d168d6e4bf0e95a65d8b4d260c7edcc89ef45d13a9bf03b9d83b59659.png](../../../_images/c6bfe97d168d6e4bf0e95a65d8b4d260c7edcc89ef45d13a9bf03b9d83b59659.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/541947341dab5388bc3ce69c415cb937d7a2f9a1b67ed0e04af0b01d337d4cd2.png](../../../_images/541947341dab5388bc3ce69c415cb937d7a2f9a1b67ed0e04af0b01d337d4cd2.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/b6806ed389f3863f6f009a70710d4a9c76edc76a3046823d8e3a4e5e4fe5defc.png](../../../_images/b6806ed389f3863f6f009a70710d4a9c76edc76a3046823d8e3a4e5e4fe5defc.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/b2b974aa5a6858e35b37d25d4a609aa298415e4753cc0b101d26e82259022d67.png](../../../_images/b2b974aa5a6858e35b37d25d4a609aa298415e4753cc0b101d26e82259022d67.png)
Using random_spheres
to insert non-overlapping spheres into blobs
¶
Another way is to use random_spheres
to insert spheres into the foreground of another image. Let’s use blobs
to define the superstructure, the perforate it with holes. Note that we invert the image (~
) before passing it to random_spheres
so that the holes are added to the solid phase, then the result is inverted back.
im1 = ps.generators.blobs([300, 300], blobiness=0.5, porosity=0.6)
im2 = ~ps.generators.random_spheres(im=~im1, r=10, clearance=-2)
fig, ax = plt.subplots(1, 1, figsize=[6, 6])
ax.imshow(im2, interpolation='none')
ax.axis(False);
![../../../_images/7883d2c57934b451178bef69f034b0a9178b3f528ab4ef2955dd5a731eca4021.png](../../../_images/7883d2c57934b451178bef69f034b0a9178b3f528ab4ef2955dd5a731eca4021.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.