βοΈ Insight Toolkit (ITK)ΒΆ
Interoperability is available with the Insight Toolkit (ITK).
Bidirectional type conversion that preserves spatial metadata is available with
itk_image_to_ngff_image and ngff_image_to_itk_image.
Once represented as an NgffImage, a multiscale representation can be generated
with to_multiscales. And an OME-Zarr can be generated from the multiscales
with to_ngff_zarr. For more information, see the
Python interface documentation.
ITK PythonΒΆ
An example with ITK Python:
>>> import itk
>>> import ngff_zarr as nz
>>>
>>> itk_image = itk.imread('cthead1.png')
>>>
>>> ngff_image = nz.itk_image_to_ngff_image(itk_image)
>>>
>>> # Back again
>>> itk_image = nz.ngff_image_to_itk_image(ngff_image)
ITK-Wasm PythonΒΆ
An example with ITK-Wasm. ITK-Wasmβs Image is a simple
Python dataclass like NgffImage.
>>> from itkwasm_image_io import imread
>>> import ngff_zarr as nz
>>>
>>> itk_wasm_image = imread('cthead1.png')
>>>
>>> ngff_image = nz.itk_image_to_ngff_image(itk_wasm_image)
>>>
>>> # Back again
>>> itk_wasm_image = nz.ngff_image_to_itk_image(ngff_image, wasm=True)