httomolib.misc.images#
Module for loading/saving images
- httomolib.misc.images.save_to_images(data: <np.ndarray>, out_dir: str | ~os.PathLike, subfolder_name: str = 'images', axis: int = 1, file_format: str = 'tif', jpeg_quality: int = 95, offset: int = 0, watermark_vals: tuple | None = None, asynchronous: bool = False)[source]#
Saves data as 2D tif, png or jpeg images. The images will be saved using the same data type as the input data, i.e., data rescaling of the input data is not performed. If the data rescaling is needed, please rescale using the rescale_to_int function, also available in this library.
- Parameters:
data (np.ndarray) – Required input NumPy ndarray.
out_dir (str) – The main output directory for images.
subfolder_name (str, optional) – Subfolder name within the main output directory. Defaults to ‘images’.
axis (int, optional) – Specify the axis to use to slice the data (if data is a 3D array).
file_format (str, optional) – Specify the file format to use, e.g. “png”, “jpeg”, or “tif”. Defaults to “tif”.
jpeg_quality (int, optional) – Specify the quality of the jpeg image.
offset (int, optional) – The offset to start file indexing from, e.g. if offset is 100, images will start at 00100.tif. This is used when executed in parallel context and only partial data is passed in this run.
watermark_vals (tuple, optional) – A tuple with the values that will be written in the image as watermarks. The tuple length must be of the same size as len(data[axis]).
asynchronous (bool, optional) – Perform write operations synchronously or asynchronously.