prep_for_imshow#
This function returns a dictionary that can be passed to matplotlib’s imshow function, with all the necessary keyword arguments holding values to make the output look nice.
from copy import copy
import matplotlib.pyplot as plt
from edt import edt
import porespy as ps
ps.visualization.set_mpl_style()
import inspect
inspect.signature(ps.visualization.prep_for_imshow)
<Signature (im, mask=None, axis=0, slice=None)>
im = ps.generators.blobs([50, 50, 50], porosity=0.6)
dt = edt(im)
im#
The im is usually greyscale values, but boolean also works.
The returned dict is passable to imshow as keyword arguments, with all the useful values set
print(kw.keys())
dict_keys(['X', 'vmin', 'vmax', 'interpolation', 'origin'])
Xis the array to show. Theimwas 3D, but the function extracts a 2D slice which is necessary forimshow.vminandvmaxare minimum and maximum values inim, while any negative and positive infinities are set tovmin - 1andvmax - 1respectively. You can adjust adjust a colormap to show suitable colors for over and under values.interpolationis set tononewhich prevents artifacts, especially in boolean images.originis set tolowerso that [0, 0] is in the bottom-left where it belongs.
We can show the solid phase as grey, and also use the plasma colormap:
mask#
The mask is a boolean array indicating the voxels of interest when computing vmin and vmax. This would typically be the image of the pore phase, but could be something more creative:
axis#
The direction normal to which the slice should be taken.  The default is 0, which means a y-z slice looking in the x direction.
slice#
The postion along axis where the 2D section should be taken from.  If not provided (and the image is 3D) then a slice is taken from the midpoint of the given axis.