prep_for_imshow#
- prep_for_imshow(im, mask=None, axis=0, slice=None)[source]#
Adjusts the range of greyscale values in an image to improve visualization by
matplotlib.pyplot.imshow
- Parameters:
im (ndimage) – The image to show. If
im
includes+inf
or-inf
values, they are converted to 1 above or below the minimum and maximum finite values inim
, respectively.mask (ndimage, optional) – An image of the porous material with
True
indicating voxels of interest. TheFalse
voxels are excluded from thevmax
andvmin
calculation.axis (int, optional) – If the image is 3D, a 2D image is returned with the specified
slice
taken along this axis (default = 0). IfNone
then a 3D image is returned. If the image is 2D this is ignored.slice (int, optional) – If
im
is 3D, a 2D image is be returned showing this slice along the givenaxis
. IfNone
, then a slice at the mid-point of the axis is returned. Ifaxis
isNone
or the image is 2D this is ignored.
- Returns:
kwargs – A python dicionary designed to be passed directly to
matplotlib.pyplot.imshow
using the “**kwargs” features (i.e.plt.imshow(\*\*data)
). It contains the following key-value pairs:key
value
’X’
The adjusted image with
+inf
replaced byvmax + 1
, and all solid voxels replacd bynp.nan
to show as white inimshow
’vmax’
The maximum of
values
not including+inf
or values inFalse
voxels inmask
.’vmin’
The minimum of
values
not including-inf
or values inFalse
voxels inmask
.’interpolation’
Set to ‘none’ to avoid artifacts in
imshow
’origin’
Set to ‘lower’ to put (0, 0) on the bottom-left corner
- Return type:
dict
Notes
If any of the extra items are unwanted they can be removed with
del data['interpolation']
ordata.pop('interpolation')
.Examples
Click here to view online example.