Improve DNG output quality using new frame metadata from libcamera - #928
Open
kunzmi wants to merge 1 commit into
Open
Improve DNG output quality using new frame metadata from libcamera#928kunzmi wants to merge 1 commit into
kunzmi wants to merge 1 commit into
Conversation
kunzmi
pushed a commit
to kunzmi/libcamera
that referenced
this pull request
Aug 20, 2026
…s metadata Having the LensShadingCorrection maps and ToneCurves available in frame metadata allows creating a DNG file with all necessary information so that the DNG matches the JPEG image without colour casts. I opened a PR in raspberrypi/rpicam-apps (raspberrypi/rpicam-apps#928) improving the colour accuracy of said DNG files created by these apps. The information needed is currently not provided by libcamera in the frame metadata. This patch intends to add LensShadingCorrection maps and ToneCurve to the controls metadata in libcamera, so that DNG files can be written with correct colours. Signed-off-by: Michael Kunz <mkunz@articimaging.eu>
When using the LensShadingCorrectionMaps and the ToneCurve added to libcamera as frame metadata and also fixing the colour conversion matrices, one can produce DNGs without wrong colours compared to the JPEG output. With these changes, a DNG opened in Photoshop or converted with dng_validate produces nearly ideantical images as the JPEG output. Signed-off-by: Michael Kunz <mkunz@articimaging.eu>
kunzmi
force-pushed
the
improveDNGOutput
branch
from
August 20, 2026 20:50
d24a976 to
83d30f2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When using the LensShadingCorrectionMaps and the ToneCurve added to libcamera as frame metadata and also fixing the colour conversion matrices, one can produce DNGs without wrong colours compared to the JPEG output.
PR for libcamera: raspberrypi/libcamera#356
With these changes, a DNG opened in Photoshop or converted with dng_validate produces nearly identical images as the JPEG output.
Signed-off-by:
One could add even more information to the DNG, e.g. the noise model parameters, but I'm not always sure how to convert the data into DNG compatible format. For the time being, getting rid of the colour casts should be a good start :)
A Jpeg recorded on a camera module 3 with

apps/rpicam-still --raw -o colors.jpg:The DNG converted with dng_validate from the same image:

Some minor colour differences are still there, mainly due to applying the tone curve in rpicam-apps in linear raw colour space, whereas DNG uses ProPhoto RGB colour space and likely more other subtle differences here and there...