2010.09.08 20:45 "Re: [Tiff] broken interface for TIFFTAG_SMINSAMPLEVALUE", by Olivier Paquet
On Wed, Sep 8, 2010 at 4:13 PM, Bob Friesenhahn <email@example.com> wrote:
Ok. Out of curiosity, do you have a use for which a single value for all channels is fine? Are you dealing with single channel images?
These tags are just a usage 'hint'. there are three channels, then I If simply specify values which represent the maximum range (e.g. 0.0 to 1.0) when considering all three channels. values set are not evaluated by The
I considered something like this... but it breaks down when I have to deal with an alpha channel. I either have to lie (not consider the alpha channel) or end up with the range pretty much always being [0,1]. Besides, I could also have a real need for per channel values if the "color" image is really 3 independent values crammed into a single "image". And I can imagine uses for knowing the actual range of the alpha too.
finding the actual max/min of the data. for scientific applications, Except knowing the normal range of the data may be more useful than knowing the actual range since usually the channels are related to each other.
Depends a lot on the application. This isn't something libtiff should have decided though. But it's too late to change that :)
Perhaps it is better to add new functions which support access to channel-specific tags?
A channel parameter seems best.
So we'd have something like:
extern int TIFFGetFieldSample(TIFF* tif, uint32 tag, uint32 sample, ...); extern int TIFFVGetFieldSample(TIFF* tif, uint32 tag, uint32 sample, va_list ap);
extern int TIFFSetFieldSample(TIFF* tif, uint32 tag, uint32 sample, ...); extern int TIFFVSetFieldSample(TIFF* tif, uint32 tag, uint32 sample, va_list ap);
In the more hackish category, we could also have a flag which we'd or with the tag number to tell libtiff we want it per-channel. Something like TIFFGetField( tif, TIFFTAG_SMINSAMPLEVALUE,... ) for the old behavior and TIFFGetField( tif, TIFFTAG_SMINSAMPLEVALUE | TIFFTAG_PERSAMPLE,... ) to get the tag as an array of SamplesPerPixel values. This would seem to be the least disruptive option but it introduces a new meaning for the tag parameter (we have tags and pseudo tags but nothing which gets or'ed together AFAIK).
This may be least disruptive for existing users, but perhaps not in libtiff.
Either solution will require the directory structure to store all the values (it currently holds only one). This implies changing the old code in TIFFGetField/TIFFSetField (probably "fixing" it to return the min/max of all channels). The only difference is adding new API entry points vs adding two cases in a switch.
Note that specifying per channel values won't make them available to the 99.999% of the world which won't expect or use them.
99.99% of the world will already not be able to get to the image anyway (multiple directories, tiled, often 16-bit int or 32-bit float). Anyone who might end up caring about that metadata will either figure it out or ask us.