2011.03.21 19:22 "[Tiff] Lab based colormaps", by Steve Underwood
RGB colormaps in TIFF files are specified as being the order min red -> max red, min green -> max green, and min blue->max blue. Getting the TIFFTAG_COLORMAP tag in libtiff returns a set of three pointers to the those red, green and blue sequences, and all seems well where I have tried this.
Right now I am working with the test files for TIFF-FX (RFC2301). One of these files, l04x_02x.tif, contains an indexed T.43 compressed image. The "indexed" tag (346) is set, and the photometric is set to ITULAB. Therefore the colormap should be in Lab format, with the ITU gamut. I am getting basically the right image after decompression, but with the colours scrambled. Obviously libtiff doesn't understand the T.43 compressed data right now. I am using libtiff to read it raw, and using a separate JBIG decoder to recover the decompressed indexed image. I'm pretty confident that part is OK, because if I reinterpret the colour map I can get a sane looking picture.Here is the oddity.....
If I use libtiff to read the colormap it gives me three arrays, each 256 elements long, just as would happen for an RGB colour map. If I try to interpret these as the L, a, and b arrays, I get crazy colours. If, however, I reorder the data as if the TIFF file contains the colour table in the order L, a, b, L, a, b, etc. the resulting image looks OK. I can't see in the TIFF spec, or the extension specs, where the order of Lab colormap data is defined. However, it would seem bizarre if it is not in the same order as RGB data.
Has anyone had similar experiences? The test files are supposed to have been used for interworking tests with several FAX makers, so I would have expected anything as blatantly wrong as this to have been caught and fixed.