Skip to content

Improve DNG output quality using new frame metadata from libcamera - #928

Open
kunzmi wants to merge 1 commit into
raspberrypi:mainfrom
kunzmi:improveDNGOutput
Open

Improve DNG output quality using new frame metadata from libcamera#928
kunzmi wants to merge 1 commit into
raspberrypi:mainfrom
kunzmi:improveDNGOutput

Conversation

@kunzmi

@kunzmi kunzmi commented Aug 18, 2026

Copy link
Copy Markdown

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:
colors

The DNG converted with dng_validate from the same image:
colorsDNG

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...

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant