satn_to_movie#

Produces a movie of the invasion sequence from ibip filter. This method can be applied for visualizing image-based invasion percolation algorithm.

import matplotlib.pyplot as plt
import numpy as np
import porespy as ps
import inspect
from IPython.display import HTML
ps.visualization.set_mpl_style()
inspect.signature(ps.visualization.satn_to_movie)
<Signature (im, satn, cmap='viridis', c_under='grey', c_over='white', v_under=0.001, v_over=1.0, fps=10, repeat=True)>

im#

The input image is a Boolean image True values indicating the void voxels and False for solid. Let’s create a test image:

np.random.seed(10)
im = ps.generators.blobs(shape=[100,100], blobiness=1)
fig, ax = plt.subplots()
ax.imshow(im, origin='lower', interpolation='none')
ax.axis(False);
../../../_images/cb02213da6971dcdb8e0bca6b6fb2b3a87ad1285231d0c80552e5add7acb204f.svg

satn#

The saturation image can be generated from ibip data using seq_to_satn method. The satn is the image of porous material where each voxel indicates the global saturation at which it was invaded. Voxels with 0 values indicate solid and and -1 indicate uninvaded.

bd = np.zeros_like(im, dtype=bool)
bd[:, 0] = 1
bd *= im
out = ps.filters.ibip(im=im, inlets=bd)
inv_seq, inv_size = out.inv_sequence, out.inv_sizes
satn = ps.filters.seq_to_satn(seq=inv_seq)

Now we can create an animation of the invasion sequence using satn_to_movie: (To save animation as a file and for visualizing use animation.save)

mov = ps.visualization.satn_to_movie(im=im, satn=satn)
mov_image_based_ip = mov.to_html5_video()
HTML(mov_image_based_ip)

cmap#

The Colormap used to map invasion sequence values to colors. By default the cmap is ‘viridis’.

mov = ps.visualization.satn_to_movie(im=im, satn=satn, cmap='plasma')
image_based_ip_cmap = mov.to_html5_video()
                                                                                                                        
../../../_images/f02032bd77aca8b2b532adccfa305462ef42e46b648639b1047eaff600d40b3b.svg
HTML(image_based_ip_cmap)

c_under#

Colormap to be assigned to the lowest color bound (under color) in the color map. The voxeled colored by c_under are the uninvaded void space. The default under color is grey.

mov = ps.visualization.satn_to_movie(im=im, satn=satn, c_under='green')
image_based_ip_c_under = mov.to_html5_video()
                                                                                                                        
../../../_images/bdf105101d09319b2e039d8cf6753ac9a103b54ddbb7903873aa8d4c170c1882.svg
HTML(image_based_ip_c_under)

c_over#

Colormap to be assigned to the highest color bound (over color) in the color map. The voxeled colored by c_overer are the solid phase. The default over color is white.

mov = ps.visualization.satn_to_movie(im=im, satn=satn, c_over='yellow')
image_based_ip_c_over = mov.to_html5_video()
                                                                                                                        
../../../_images/5e2c94db83cd9a3e2c631beceec07d2f2b9e851e84a55a3383a15b7034bae33f.svg
HTML(image_based_ip_c_over)

v_under#

This is the lowest bound of satn data range that the colormap covers. By default, the v_under is 0.001.

mov = ps.visualization.satn_to_movie(im=im, satn=satn, v_under=0.2)
image_based_ip_v_under = mov.to_html5_video()
                                                                                                                        
../../../_images/44471b2c1976fdf5c0f656d9eaf10905ff29024ffc5e8e08eb36fea4db796314.svg
HTML(image_based_ip_v_under)

v_over#

This is the highest bound of satn data range that the colormap covers. By default, the v_over is 1.

mov = ps.visualization.satn_to_movie(im=im, satn=satn, v_over=0.5)
image_based_ip_v_over = mov.to_html5_video()
                                                                                                                        
../../../_images/174a029a91eb0c6340d0a4bb2a1b8d0623f7295b89d9a193e5859ea592f73b68.svg
HTML(image_based_ip_v_over)

fps#

This is the frames per second that the animation will be saved at. The default value is 10.

mov = ps.visualization.satn_to_movie(im=im, satn=satn, fps=5)
image_based_ip_fps = mov.to_html5_video()
                                                                                                                        
../../../_images/793b1cb212e4c129524265392b5045d852fc787880cf5cd93cfe82b80dbf0279.svg
HTML(image_based_ip_fps)

repeat#

This variable indicates whether the animation repeats when the sequence of frames is completed. By default repeat=True.

mov = ps.visualization.satn_to_movie(im=im, satn=satn, repeat=False)
image_based_ip_repeat = mov.to_html5_video()
                                                                                                                        
../../../_images/9b2cabeae817c90912320cf9a3494af60461359c9540d17f7d717baaba443dc0.svg
HTML(image_based_ip_repeat)