I am experimenting with adding support for flat field correction using embedded DNG GainMaps to darktable. This can be quite important; for some phones the colors will be way off if the GainMap is not applied, for example see the image in this thread from a Xiaomi Poco X2.
I am not trying to make something that’s fully conforming to the Adobe DNG spec - the “opcode list processing” that includes the GainMap is flexible and complex and doesn’t really fit well into the darktable pipeline model. I am just trying to efficiently support the typical GainMaps that commonly appear in smartphone DNGs for lens shading correction. So I’m looking for some samples to figure out what needs to be supported. I have a Pixel 4a with the Google Camera app and I found a few other samples on RPU, but would like to see some more from different brands and apps. I have also found a couple (Samsung Galaxy s20 Ultra, and a Huawei) that contain a no-op GainMap that should be ignored.
The GainMap is embedded in the exif tag “Exif.Image.OpcodeList2” or “Exif.SubImage1.OpcodeList2”, depending on whether or not there is also an embedded jpeg preview.
I am looking for any dng containing the OpcodeList2 tag, for which the exiftool command shows:
Thanks! I have been using the ART implementation as an example.
The Galaxy Note 20 file only contains a 1x1 GainMap that does nothing and can be ignored. So maybe that camera doesn’t need the correction, or the correction has already been applied by the hardware or app before writing the raw dng.
It looks like that the GoPro Raw files (GPR) from https://raw.pixls.us/ have GainMaps inside. My Firefox changed the file ending to tif. You need to change it back to “.gpr”.
I used the command line tool from GoPro to extract the meta data:
When you said it got changed to a tiff I suspected they were really DNG and GoPro just was using their own extension…Well seems I am sort of correct…likely converting to a real DNG would be the best way to work with them in DT ART and RT…
This one is different than the other files I have seen so far… instead of handling all of the vignetting correction with the GainMap like the smartphone dngs, there are two separate opcodes in OpcodeList3:
FixVignetteRadial is a simple vignetting correction that just affects brightness and is applied equally to all color channels, and then the GainMap is only used to correct uneven color cast.
Having the GainMap in OpcodeList3 instead of OpcodeList2 means that it’s supposed to be applied after demosaic instead of before, but I would assume that applying it before demosaic (as if it had been in OpcodeList2) would have the same effect.
The FixVignetteRadial opcode also appears in iPhone DNGs. I haven’t tested it but it looks like ART supports it, but not RawTherapee or darktable.
The Huawei P10 Plus image contains a no-op GainMap (all gains are 1 so it has no effect). So there is no need to apply any correction. Probably just an oversight in their camera app including it when it’s not needed…
The lens correction in DT for the P10 does a nice job if your dng have strong vignette. I used it on my pixel images and it worked fantastic even though it is not the same camera…it was actually hard to tell it from the gain mapped conversion…just some differences in extreme highlights I did notice…
On my OnePlus Nord, the standard camera app does not add a GainMap; GCam does, but I wonder if it’s reliable at all (I assume since it’s a hack, it’ll probably just have an empty or incorrect GainMap).