cgohlke/imagecodecs

Which codecs work with 3D or even N-Dimensional images?

Karol-G opened this issue · 4 comments

Hi,

I have a lot of 3D medical and non-medical images and am currently experimenting with different compression codecs. However, I find it difficult to find information on which of the codecs also work for 3D or even ND images. I believe all or most codecs provided in the Numcodecs library work with ND images.
Do you know which of the other codecs provided in your library also work with 3D or ND images (e.g. JpegXL, Avif, and others)?

Best
Karol

Assuming reasonable input sizes, all the general compression codecs working on byte inputs (zlib/deflate, zstd, lzma, blosc, etc) should work. Depending on dimension sizes, data types, and color spaces: ZFP and LERC can handle up to 4 dimensions. GIF, APNG, JPEG XL, AVIF, and HEIF can store sequences of images. It is common to chunk large, high-dimensional data into smaller dimensional pieces. Those smaller chunks is what imagecodecs is meant to handle.

Thanks for the clarification!

It is common to chunk large, high-dimensional data into smaller dimensional pieces. Those smaller chunks is what imagecodecs is meant to handle.

Yes, I want to use the codecs for the chunk compression in Zarr arrays :)

GIF, APNG, JPEG XL, AVIF, and HEIF can store sequences of images.

With sequences of images you mean sequences of 2D images right? Assuming a 3D image/chunk, is the compression for such sequences of 2D images/chunks performed isolated or is the 3D image/chunk compressed as a whole, utilizing the voxel correlation across the third dimension?

With sequences of images you mean sequences of 2D images right?

Yes. They are handled by imagecodecs as 3D arrays (4D with color samples).

is the compression for such sequences of 2D images/chunks performed isolated or is the 3D image/chunk compressed as a whole

That depends on the implementation. I think AVIF and HEIF use video compression codecs on frames. AFAIK, XPEG XL currently compresses frames (and planar samples?) independently, but that may change when the implementation matures. GIF and APNG are for "web animations" but imagecodecs makes no effort to optimize the frames. There are other formats, e.g., Motion JPEG and WebM, that imagecodecs does not support.

Thanks a lot! These informations have been really helpful to me :)