martin-marek / hdr-plus-swift

📸Night mode on any camera. Based on HDR+.
https://burst.photo
GNU General Public License v3.0
208 stars 11 forks source link

Re-adding black level on output #37

Open Alex-Vasile opened 12 months ago

Alex-Vasile commented 12 months ago

Currently, when we import an image we subtract the black level from the image and clip to >=0, but when re-exporting the images we re-add the original black level to the images. E.g. if the black level was 512 (as it is for Sony images) then the minimum value in the DNG will be 512 (so the bottom 9 bits of the image range will be unused).

I believe we should not be doing this, and instead be setting a black level of the output back to that of the input (i.e. 512) we should be setting a black level of 0 and let the image use that full range.

chris-rank commented 12 months ago

When experimenting with the output DNG, I found that manipulating the black level of the DNG always caused very strong incompatibilities (very strong color cast) with my RAW converter (DxO Photolab). Although I changed both the RAW values and the black level metadata, PhotoLab seems to extract the black level from a different entry in the metadata. In addition, I see not so much of improvement with getting additional 512 integer values. As 16 bit integer output is already supported, you gain less than 1% of values. In contrast, for 16 bit float output, the gain would be significant as each power of two contains 1024 values, so the precision from 0 to 512 is much higher than above 512. However, 16 bit float is also 16 bit precision. So while you gain precision in the shadows, but you loose it in the highlights.