Skip to content

imwrite() to TIFF does not use COMPRESSION_SGILOG for 32FC1 (only 32FC3) #25246

@chacha21

Description

@chacha21

Describe the feature and motivation

The TIFF library supports COMPRESSION_SGILOG for float data.

Currently, in opencv (4.9)

  • a 32FC3 image written as TIFF is automatically using COMPRESSION_SGILOG + PHOTOMETRIC_LOGLUV (with a minor loss of accuracy)
  • a 32FC1 image written as TIFF does not use compression
  • a 32FC1 image can be articially made 32FC3 by duplicating channels to allow TIFF compression, resulting in minor loss of accuracy but pretty good compression rate

However, 32FC1 could be supported using COMPRESSION_SGILOG + PHOTOMETRIC_LOGL
I have already prepared a PR for that

  • the compression rate of 32FC1 is not better than the artificial 32FC3, but...
  • ...I checked that the compressed 32FC1 has a better accuracy than the 32FC1->32FC3 when re-reading the image and comparing it to the original uncompressed data

I could submit the PR but there is one red flag

  • while correctly generated and read back by OpenCV, the 32FC1 TIFF using COMPRESSION_SGILOG + PHOTOMETRIC_LOGL cannot be open by ImageJ.

So I wonder how legal such a TIFF is. Is it expected to fail ? Is this a lack of support from other softwares ? Did I forget anything for this compression scheme ?

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions