Skip to content

Apply hue and sat corrections for some DNG files - #22503

Draft
jenshannoschwalm wants to merge 2 commits into
darktable-org:masterfrom
jenshannoschwalm:forward_get_look
Draft

jenshannoschwalm wants to merge 2 commits into
darktable-org:masterfrom
jenshannoschwalm:forward_get_look

Conversation

@jenshannoschwalm

@jenshannoschwalm jenshannoschwalm commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Complete forward matrix support of DNG images and apply the saturation and hue correction as suggested by the DNG exif tags and support these corrections also if no forward matrix is provided.


Introduce a hidden dng_look module that makes use of the dng exif data provided via ProfileHueSatMapData and corrects hue and saturation accordingly.
As we use tonemappers like agx or sigmoid we do not apply any value/brightness correction here. (For the same reason we do not use ProfileToneCurve)

No changes to old edits (before the late forward matrix PR) no defaults changed.

Referenced issue

None specific

Checklist

  • I have read CONTRIBUTING.md and the coding style.
  • I have not merged master into the topic branch.
  • The pull request is one logical change, and every commit compiles on its own.
  • I ran src/tests/integration/ - all good with no diffs.
  • New user-visible strings use _()
  • A RELEASE_NOTES.md entry was added

Test instructions

Use any of the images here and check colorin profile

  1. DJI_0384.7z.txt has no forward matrix but profile data for sat and hue (used 7z to stay in 25MB limit :-)
  2. PXL_20241213_131157874.zip has forward matrix.

AI assistance

Not assisted but almost everything was written by claude sonnet

@jenshannoschwalm jenshannoschwalm added this to the 5.8 milestone Oct 3, 2026
@jenshannoschwalm jenshannoschwalm added feature: new new features to add scope: image processing correcting pixels documentation: pending a documentation work is required ai:generated Release note provided A release note is either provided in this PR or not required labels Oct 3, 2026
Copilot AI and others added 2 commits October 4, 2026 02:03
(1) exif: store embedded DNG look metadata in the image
Read the illuminant-selected HueSatMap and profile tone curve into
owned image fields. Validate table dimensions and element counts before
allocating, and retain illuminant selection without a forward matrix.
Initialize and release the tables with the image cache. Detach borrowed
pointers during full-size loading, transfer successful loads, and free
failed loads so metadata ownership stays with the current cache record.

(2) iop: apply the DNG look after colorin
Add a hidden look module enabled only when a valid forward matrix is
selected as the input profile. Respect module filters and recorded
history, and lock cache-owned metadata while copying it into the pipe.
Blend the embedded tone curve and retain final clipping.
Register the module after colorin and add focused unit coverage for
interpolation, mixing, scale caps, profile gating, and cache snapshots.

(3) colorin: consolidate DNG look profiles and synchronize enablement
Keep embedded looks active with a valid selected DNG forward matrix,
and offer an opt-in embedded-look profile for D65 images without one.
Reuse the embedded matrix fallback chain while preserving the new type
and propagate both camera matrices into the pipe profile information.

Request full synchronization when profile selection crosses into or out
of the look-capable set, so top-history edits update the look on every
pipe. Cover availability, fallback matrices, processing, and repeated
profile switches with unit tests.

Co-authored-by: jenshannoschwalm <50982232+jenshannoschwalm@users.noreply.github.com>

tests: align DNG look tests with required working profiles

Co-authored-by: jenshannoschwalm <50982232+jenshannoschwalm@users.noreply.github.com>
Summary: Introduce a hidden dng_look module that makes use of the dng exif data provided via
`ProfileHueSatMapData` and corrects hue and saturation accordingly.
As we use tonemappers like agx or sigmoid we do not apply any value/brightness correction here.
(For the same reason we do not use `ProfileToneCurve`)

Some images have no forward matrix but offer `ProfileHueSatMapData`, those images use the embedded
D65 coeffs but may use the dng_look if the special color profile `DNG embedded look` is used in
colorin module.

Design decisions:
1. Not worth to implement an OpenCL codepath to maintain.
2. All things done in dng_look could also be done in colorin processing but that
   would have blown up that module even more.

Minor code optimizing - without a working profile it doesn't make sense to use this module ...
@jenshannoschwalm
jenshannoschwalm marked this pull request as draft October 4, 2026 07:13
@jenshannoschwalm

Copy link
Copy Markdown
Collaborator Author

Marking this as draft for now - reinvestigating if the correction should be done in colorin module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai:generated documentation: pending a documentation work is required feature: new new features to add Release note provided A release note is either provided in this PR or not required scope: image processing correcting pixels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants