Skip to content

Black level is re-added to output, leading to inefficient use of representable dynamic range #216

@Entropy512

Description

@Entropy512

Approximately a year ago, I did some work with hdrmerge and originally got very poor results (banding in shadows). Back then, I just changed the output depth from float16 (default) to float32 and went on my merry way, not thinking much of it.

I recently was looking in more detail at the metadata of the resulting DNG for other purposes, and noticed that the black level was 512 (which is normal for a Sony camera, but abnormal for an image that has had the kind of processing hdrmerge performs).

The problem with this is that when the black level is 512 in the output, a large portion of the dynamic range that can be represented by a float16 number is unused - above 512, the interval between possible representable numbers is 0.5 - https://en.wikipedia.org/wiki/Half-precision_floating-point_format#Precision_limitations

The original black level of the camera is subtracted immediately on load at https://github.com/jcelaya/hdrmerge/blob/master/src/ImageIO.cpp#L272, and all further processing is performed with a black level of 0.

The black level is re-added on export at https://github.com/jcelaya/hdrmerge/blob/master/src/ImageStack.cpp#L467 , leading to significant truncation of precision in the shadows with the default output of float16 if the camera has a nonzero black level

Images should be export with a black level of 0 (e.g. do not re-add the original camera black level) to maximize use of the dynamic range that can be represented by float16

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions