Determining 'Correctness' of white level values


I am currently using libraw to read metadata from a number of different images, and have been trying to create automated tests for my code. I have seen some information on how libraw is returns Black Level values, and have been able to either use the output from exiftool, or the raw CFA data to confirm that it is returning data as expected. However, I have not seen much about how libraw gathers/calculates white-level values, and so I am uncertain on how to determine the expected WL values in my tests. Maybe I have missed this in the documentation, but any clarity on how the white-levels are read would be helpful.

Thanks in advance.


White level (data maximum) is

White level (data maximum) is not as easy as it should be.

LibRaw provides (estimated) data maximum in imgdata.color.maximum. This value is
- either hardcoded (this is derived from dcraw.c)
- or last item of linearization curve
- or determined using camera bit count

For many formats/vendors/settings it is correct, for others it is overestimated (for example, Panasonic low ISO w/ full-well limited sensor, also Canon's intermediate ISOs)

Also, there is imgdata.color.linear_max[]. If filled (nonzero) this value(s) represents vendor suggested white point parsed from metadata. This value is usually way too low (there are a lot of pixels above this threshold), but it is (yes) suggested by vendor.

Also, there are vendor-specific values in parsed metadata fields (e.g. canon.NormalWhiteLevel/canon.SpecularWhiteLevel)

-- Alex Tutubalin @LibRaw LLC