slmsuite.holography.analysis.files.save_image#

save_image(file_path, images, cmap=False, lut=None, normalize=True, border=None, **kwargs)[source]#

Save a grayscale image or stacks of grayscale images as a filetype supported by imageio. Handles matplotlib colormapping. Negative values are truncated to zero. np.nan values are set to transparent.

Parameters:
  • file_path (str) – Full path to the file to save the data in.

  • images (numpy.ndarray) – A 2D matrix (image formats) or stack of 2D matrices (video formats).

  • cmap (str OR bool OR None) – If str, the matplotlib colormap under this name is used. If None or False, the images are directly saved as grayscale 8-bit images. If True, the default colormap is used.

  • lut (int OR None) – Size of the lookup table for the colormap. This determines the number of colors the resulting image has. This can be larger than 256 values because RGB data can realize more colors than grayscale. If None`, Defaults to ``mpl.rcParams['image.lut'] (if the image is floating point) or the maximum of the image (if the image )

  • normalize (bool) – If True, the maximum of the image is taken as the image maximum. If False and using integer data, the data is unchanged. If False and using floating point data, 1 is taken to be the maximum, and this is scaled to the lut.

  • **kwargs – Passed to imageio.imsave() or imageio.mimsave(). Useful for choosing a plugin or format.