2018.05.09 03:45 "[Tiff] Question about transfer function", by Larry Gritz

2018.05.09 03:45 "[Tiff] Question about transfer function", by Larry Gritz

I'm embarrassed to say that today I stumbled on a statement in the TIFF 6.0 spec that had somehow eluded me previously in nearly 30 years of dealing with TIFF files. To wit:

"Be aware that the PhotometricInterpretation value of 0 or 1 (grayscale) implies linear data because no gamma is specified. The PhotometricInterpretation value of 2 (RGB data) specifies the NTSC gamma of 2.2 as a default. If data is written as something other than the default, then a GrayResponseCurve field or a TransferFunction field must be present to define the deviation. For grayscale data, be sure that the densities in the GrayResponseCurve are consistent with the PhotometricInterpretation field and the HalftoneHints field."

Oy. In the world of 3D graphics, I've never encountered a TIFF file that has GreyResponseCurve, TransferFunction, or HalftoneHints. I also would say that it's by no means standard to assume that TIFF files are storing NTSC gamma 2.2 for all PhotometricInterpretation=RGB images or are always linear for grayscale PhotometricInterpretation=ZeroIsBlack or ZeroIsWhite images. Figuring out whether an image is linear or sRGB has always been a hit-or-miss challenge and I've never seen consistent metadata.

So what should I do with this knowledge?

Should I modify my software to write sRGB values to RGB TIFF files, unless intended to be linear, in which case output TransferFunction tags that probably no reading software will know to look for? And to interpret all TIFF RGB files as sRGB values unless they have transfer functions that probably no writer uses? (Aside, if I want to write TIFF image that's 3 channel x 16-bit of linear values, it seems extremely wasteful to output a 65536 x 3 x 2 byte transfer table just to communicate that it's linear.)

Or should I just say, water under the bridge, in the real world nobody uses these hints so you just have no idea if a TIFF file is meant to represent linear or sRGB values unless the author tells you or you know they are following some convention (which may differ by user, company, or industry)?

Larry Gritz