Saving an OMNI Image

omni.Image.save_metadata() can be used to save a new .omni metadata file. omni.Image.save_pixels() can be used to save the raw pixels file of an OMNI image. omni.Image.save_all() can be used to save the metadata and the raw pixels.

For example Lucid.Core.Threshold creates a new .omni metadata file for the raw pixels file created by LUPO:

import pathlib

import lupoutil
import omni
from typing import Optional


def thres_image(
        image: omni.Image,
        min: Optional[float],
        max: Optional[float],
        result_omni_path: pathlib.Path,
        result_raw_path: pathlib.Path,
        temp_folder_path: pathlib.Path) -> omni.Image:
    """Threshold Segmentation"""

    input_raw_path = lupoutil.get_or_extract_raw_pixels_file(image, temp_folder_path)

    lupoutil.run_lupo([
        "threshold",
        str(input_raw_path),
        str(result_raw_path),
        "0",
        str(image.size_3d[0]),
        str(image.size_3d[1]),
        str(image.size_3d[2]),
        image.pixel_type,
        str(min) if min is not None else '-inf',
        str(max) if max is not None else 'inf',
        "1",
    ])

    result_segments = image.save_derived_segments(result_omni_path, result_raw_path)
    return result_segments

See Saving output in a task type for how to save an OMNI provided as an output parameter.

See also Import external data / Export Data.