Skip to content

LOOK-FIT-1: fit the camera look on the share of the lens's vignetting correction the camera JPEG shows - #1279

Merged
emmertex merged 3 commits into
emmertex:mainfrom
RAD-Films:fix/look-fit-undershoot
Nov 18, 2026
Merged

emmertex merged 3 commits into
emmertex:mainfrom
RAD-Films:fix/look-fit-undershoot

Conversation

@OneSlips

Copy link
Copy Markdown
Collaborator

Problem

Raws whose camera JPEG kept the lens's dark corners came out 5 to 11 L* darker than that JPEG. On a wedding day that is
a whole body's worth of frames: Canon EOS 6D portraits on an EF 50 mm f/1.8 STM and an EF 70-200 mm f/2.8L II opened
visibly darker than the camera showed them, so every frame from that body needed an exposure push before culling could
even judge it, and the push had to be guessed per lens.

The cause is in the per-file camera look, which is fitted to the embedded camera JPEG. Since upstream #3402 (LOOK 21)
the fit's sensor proxy gets the lens's full vignetting correction, on the premise that the camera JPEG had it applied.
That holds for a RAF's own correction. It often fails for a correction from the lens database: the 6D portraits show
none of it, and chart frames on an EF 24-70 mm f/2.8L II and a 5D Mark IV at 16 mm show about half to two thirds. The
fit then pairs corners lifted by up to 1.6 EV with the JPEG's dark corners and lowers the whole tone curve to match.

Change

  • proxies() (crates/engine/src/camera_preview.rs) measures the share of the correction the JPEG shows
    (vignetting_shown), in the geometry it finally chose (after the warp choice) and in working space: for shares 0,
    0.05, ..., 1 it orders the usable pixels by sensor brightness times gain^share and keeps the share whose 32
    equal-count bins spread the JPEG's brightness least. Flat, edge and clipped pixels are left out. The sensor proxy
    then gets gain^share.
  • A share of 0.9 or more, too few usable pixels, or a correction weaker than 0.03 in log gain keeps the full
    correction, as before. CR3s are not measured yet (their framing step comes later).
  • docs/camera-preview-colour.md explains it; changelog and what's-new entries added.

Not in this PR: CR3 files; the DNG tone fit (fit_dng_tone, issue #1174, is separate work); lens correction
itself is unchanged.

How it was checked

  • cargo xtask ci --quick on the branch merged up to main b3e8846 (Windows, 18 Nov; main has since merged Raw: decode Nikon NEFX (merged pixel shift) #1267, which merges with this branch without conflicts and was not re-run): fmt, brand, quarantine, docs,
    notes, i18n and clippy pass; lcc-engine 2516 pass, 2 fail. Both also fail on plain origin/main b3e8846 on
    the same machine (device_sync::tests::immich_albums_are_collections_each_device_takes_as_it_chose,
    tests_face_recognize::unnamed_faces_come_with_look_alikes_together_and_the_name_the_named_ones_suggest), so
    they are not this change. All 94 camera_preview tests pass. Run after: cargo xtask parity, layers,
    assets and the wasm32 check of lcc-engine pass.
  • Tests that fail without the change: the_share_of_the_vignetting_correction_a_jpeg_shows_is_measured (a JPEG
    showing none, half or all of the correction through a camera curve is measured within 0.1 of 0, 0.5 and 1; no
    vignetting at all gives the whole, no-op correction), and
    a_jpeg_that_keeps_the_vignetting_is_fitted_on_the_recorded_sensor (a JPEG that keeps the sensor's vignetting
    gets the same tone curve with and without the lens, within 0.005 at 0.25, for the tone-only and the colour fit).
  • Renders: median dL* against the camera JPEG, lens correction off.
set before after
six Canon EOS 6D portraits (EF 50 f/1.8 STM, EF 70-200 f/2.8L II) -6.0 .. -11.8 L* -0.5 .. -1.0 L*
four 6D chart frames (EF 24-70 f/2.8L II) -5.3 .. -7.2 L* -2.9 .. -4.3 L*
R5 C, Z 6III, G9 (calibration file) bit-identical
Z 8 (no vignetting data) unchanged

One 6D frame with no lens vignetting data is unchanged.

Merging

  • Overlap: Upstream intake 2026-11-17: 15 PRs, 0 commits #1260 (upstream intake 2026-11-17) also changes camera_preview.rs and takes LOOK_VERSION 23; it
    does not touch proxies(). Issue Lightroom-converted Adobe Standard DNGs (no ProfileToneCurve) render ~0.3 EV too dark via the DNG tone fit #1174 work (fit_dng_tone) is on another branch; this PR doesn't touch that
    function.
  • Existing edits and libraries: the camera look of affected raws (lens-database vignetting correction, camera JPEG
    showing less than 90 % of it) changes. Per docs/process-versions.md this is a change of the source (the camera
    colour a file gets), not of how settings are interpreted, so it goes through LOOK_VERSION, not a process version.
    Photos with a calibration file or no vignetting data render the same.
  • Shared numbers taken: LOOK_VERSION 28 (main 22; Upstream intake 2026-11-17: 15 PRs, 0 commits #1260 takes 23; 23-27 skipped because builds of forks used
    them for this change and others, so a stale cached look can't be mistaken for this one), RENDER_CACHE_VERSION 93
    (main 81; same reason, 82-92 skipped).
  • Where it came from: own measurements on the contributor's own Canon raws and their embedded JPEGs. No Adobe
    material, no lens profiles.
  • New dependencies, unsafe, build scripts, network access, spawned processes, deleted files, CI or xtask gate
    changes:
    none.

Checklist

  • No new panic path in non-test code
  • No new text on screen
  • Changelog and what's-new entries
  • New code has a caller (proxies)
  • No assets added

🤖 Generated with Claude Code

OneSlips and others added 3 commits November 12, 2026 10:21
… correction the camera JPEG shows

The per-file look fit gave its sensor proxy the lens's full vignetting
correction, assuming the camera JPEG had it applied. For lens-database
corrections that is often false: Canon EOS 6D portraits (EF 50 f/1.8 STM,
EF 70-200 f/2.8L II) show none of it, chart frames on an EF 24-70 II and a
5D Mark IV at 16 mm about half to two thirds. The fit paired corners lifted
by up to 1.6 EV with the JPEG's dark corners and lowered the whole tone
curve, so those 6D frames rendered 5-11 L* under their JPEGs.

proxies() now measures the share the JPEG shows (vignetting_shown), in the
geometry it finally chose and in working space, and applies gain^share.
A share >= 0.9, too few usable pixels or a weak correction keeps the full
correction. CR3 is not measured. LOOK_VERSION 22 -> 23,
RENDER_CACHE_VERSION 80 -> 81.

Measured, lens correction off, median dL* against the camera JPEG: six 6D
portraits -6.0..-11.8 -> -0.5..-1.0; four 6D chart frames -5.3..-7.2 ->
-2.9..-4.3. R5 C, Z 6III and G9 renders are bit-identical; Z 8 unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…main (main 22/81)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@emmertex emmertex left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed: the look fit now measures how much of the lens vignetting correction the camera JPEG shows and fits on that share. Math is bounded (finite checks, minimum pixel count, spread threshold falls back to the previous full correction), no panics paths, LOOK_VERSION/RENDER_CACHE_VERSION bumped, tests for both the fit and the measurement, docs/changelog/whats-new present. CI green.

@emmertex
emmertex merged commit 84ba749 into emmertex:main Nov 18, 2026
5 checks passed
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.

2 participants