imshow#
- fcp.imshow(**kwargs)#
Image show plotting function.
- Parameters:
df –
- Single image only:
2D numpy array of pixel data
OR a 2D pd.DataFrame of pixel data
- Multiple images:
pd.DataFrame with 1 row per image
row index value must match a key in the kwargs[‘imgs’] dict
other columns in this DataFrame are grouping columns
- Keyword Arguments:
imgs –
- Single image only:
Not defined or used
- Multiple images:
dict of the actual image data; dict key must match a row index value in kwargs[‘df’]
cfa (str) – Color-filter array pattern that is used to split data from a Bayer image into separate color planes. Defaults to None. More details
cmap (bool) – Name of a color map to apply to the plot. Defaults to gray. More details
imshow_interp|interp (str) – imshow interpolation scheme [see matplotlib docs for more details]. Defaults to ‘none’.
stretch (float|list) – Calculate “stretch” times the standard deviation above and below the mean to set new z-limits. Can be a single value used as +/- limits or a two-value list for the lower/upper multiplier values. Defaults to None. More details
Examples
Basic:
>>> import fivecentplots as fcp >>> from pathlib import Path >>> import pandas as pd >>> import imageio.v3 as imageio >>> # Read an image from the world-wide web >>> url = 'https://imagesvc.meredithcorp.io/v3/mm/image?q=85&c=sc&rect=0%2C214%2C2000%2C1214&' >>> + 'poi=%5B920%2C546%5D&w=2000&h=1000&url=https%3A%2F%2Fstatic.onecms.io%2Fwp-content%2Fuploads' >>> + '%2Fsites%2F47%2F2020%2F10%2F07%2Fcat-in-pirate-costume-380541532-2000.jpg' >>> imgr = imageio.imread(url) >>> # Convert to grayscale >>> img = fcp.utilities.img_grayscale(imgr) >>> fcp.imshow(img, ax_size=[600, 600])
With +/- 3 sigma contrast stretching:
>>> uu = img.stack().mean() >>> ss = img.stack().std() >>> fcp.imshow(img, cmap='inferno', cbar=True, ax_size=[600, 600], zmin=uu-3*ss, zmax=uu+3*ss)