Image saving

Image saving#

These are saving related functions that are usually called by :class:marsimage.MarsImage

Various functions to save images.

marsimage.save.save_tiff(img, whitelevel, save_path, scale_factor=1.0, gamma: float = 1.0, dtype=<class 'numpy.uint16'>)[source]#

Write the image array as a tiff file.

The brightness will be normalize between 0 and the whitelevel. A gamma correction is applied if specified.

Parameters:
  • img (ndarray) – The image array to save.

  • whitelevel (int) – The whitelevel of the image.

  • save_path (str | Path) – The path to save the image to.

  • scale_factor (float, optional) – The brightness scale factor to apply to the image. Default is 1.0.

  • gamma (float, optional) – The gamma correction to apply to the image. Default is 1.0.

  • dtype (numpy.dtype, optional) – The data type to save the image as. Default is np.uint16. Can be np.uint8 or np.uint16.

Returns:

The path to the saved TIFF image.

Return type:

str

Module that handles dng metadata and saving to the dng format.

marsimage.dng.save_dng(marsimage, save_path, compress=False, pp3=False, rawtherapee_convert=False, remove_dng=False)[source]#

Save a marsimage object as a calibrated DNG file.

Optionally converts the DNG to a TIFF file using RawTherapee.

Parameters:
  • marsimage (MarsImage) – The MarsImage object containing image data and metadata.

  • save_path (str | Path) – The path where the DNG file will be saved.

  • compress (bool, optional) – Whether to compress the DNG file lossless, by default False.

  • rawtherapee_convert (bool, optional) – Whether to convert the DNG to a TIFF file in place using RawTherapee, by default False. Ensure that the RAWTHERAPEE_CLI environment variable is set to the path of the RawTherapee CLI executable.

  • pp3 (bool, optional) – Whether to write a pp3 processing profile for RawTherapee, by default False.

  • remove_dng (bool, optional) – Whether to remove the DNG and pp3 file after conversion to TIFF, by default False

Returns:

The path to the saved DNG file.

Return type:

str