AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2004.01.15 17:16 "[Tiff] How to determine number of colors in the colormap", by Bill Cassanova
2004.01.15 18:44 "Re: [Tiff] How to determine number of colors in the colormap", by Joris
2004.01.15 18:59 "Re: [Tiff] How to determine number of colors in the colormap", by Bill Cassanova
2004.01.15 19:50 "Re: [Tiff] How to determine number of colors in the colormap", by Joris
2004.01.15 20:14 "Re: [Tiff] How to determine number of colors in the colormap", by Bill Cassanova
2004.01.15 21:32 "Re: [Tiff] How to determine number of colors in the colormap", by Joris

2004.01.15 18:44 "Re: [Tiff] How to determine number of colors in the colormap", by Joris

I have an 8-bit tiff image which I have been able to confirm has only 18 colors. Is there some tag within the tiff itself that says how many colors are actually present?

No, there isn't. That is only possible to deduct with code that actually counts the colors used. This counting is not a codec's responsability, either, it is an imaging operation instead of an encoding/decoding operation.

An extreme example of how these two are different and complement each other: a codec is and should be perfectly happy to encode a black and white image in 16bits per channel full color RGB. But of course the imaging library on top of the codec is either completely braindead, or provides the application level with a way to easily detect and improve encoder options that produce such garbadge, which may internally result in transcoding the image library's image object into another object that is 1bit per pixel.

Or at least, that's how I see it.

The value that is being returned when I have ( 2**bits_per_sample ) or from another example I saw (( 1 << bitspersample ) -1 ) is 255 which is the number of colors that I would expect are possible although not necessarily present.

Why the -1? (2**bits_per_sample) = (1<< bits_per_sample) = maximum number of entries in palette. The -1 can be used to derive the index of the last entry in the palette.

Joris Van Damme
info@awaresystems.be
http://www.awaresystems.be