Add new comment

And if data is scaled to 8

And if data is scaled to 8 bit somewhere, your result looks correct.

coloir.maximum is in RAW data domain, so for 14-bit camera it is about 16000.
imgdata.image[], after processing, is in 0..64k range.
your luminocity calculation, in first assumption, is in same range as imdata.image, so 64k.

So your jpeg generation code will show upper two stops of image as 'overflow'

-- Alex Tutubalin