Ask Your Question

Revision history [back]

Taking a quick look at the imgcodes module code, looks like it only writes out the TIFFTAG_SAMPLEFORMAT for 32-bit floating point sample types. Otherwise it's not set, in which case Tiff reader implementations interpret the sample format as value 1 (sample format = unsigned number).

If you know some C++ and don't mind hacking the source a little, you can probably add a couple lines in this function in the source: https://github.com/opencv/opencv/blob/master/modules/imgcodecs/src/grfmt_tiff.cpp#L727 to get it to write out the TIFFTAG_SAMPLEFORMAT based on the data type that's being used.

However I suggest creating a feature request on OpenCV's Github (https://github.com/opencv/opencv/issues) if you believe this is a standard tag and should be standard.

As a sidenote, isn't TIFFTAG_SAMPLEFORMAT is an extension tag and not a baseline one? I'm not a Tiff genius but it seems like this tag should be standard, although it's not a baseline Tiff tag.

Taking a quick look at the imgcodes module code, looks like it only writes out the TIFFTAG_SAMPLEFORMAT for 32-bit floating point sample types. Otherwise it's not set, in which case an external Tiff reader implementations implementation would interpret the sample format as value 1 (sample format = unsigned number).number) if it follows the standard.

If you know some C++ and don't mind hacking the source a little, you can probably add a couple lines in this function in the source: https://github.com/opencv/opencv/blob/master/modules/imgcodecs/src/grfmt_tiff.cpp#L727 to get it to write out the TIFFTAG_SAMPLEFORMAT based on the data type that's being used.

However I suggest creating a feature request on OpenCV's Github (https://github.com/opencv/opencv/issues) if you believe this is a standard tag and should be standard.

As a sidenote, isn't TIFFTAG_SAMPLEFORMAT is an extension tag and not a baseline one? I'm not a Tiff genius but it seems like this tag should be standard, although it's not a baseline Tiff tag.