Repository navigation
LOOK-FIT-1: fit the camera look on the share of the lens's vignetting correction the camera JPEG shows - #1279
Merged
Conversation
… 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
approved these changes
Nov 18, 2026
emmertex
left a comment
Owner
There was a problem hiding this comment.
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.
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.
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^shareand keeps the share whose 32equal-count bins spread the JPEG's brightness least. Flat, edge and clipped pixels are left out. The sensor proxy
then gets
gain^share.correction, as before. CR3s are not measured yet (their framing step comes later).
docs/camera-preview-colour.mdexplains 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 correctionitself is unchanged.
How it was checked
cargo xtask ci --quickon 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/mainb3e8846 onthe 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), sothey are not this change. All 94
camera_previewtests pass. Run after:cargo xtask parity,layers,assetsand the wasm32 check of lcc-engine pass.the_share_of_the_vignetting_correction_a_jpeg_shows_is_measured(a JPEGshowing 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 vignettinggets the same tone curve with and without the lens, within 0.005 at 0.25, for the tone-only and the colour fit).
One 6D frame with no lens vignetting data is unchanged.
Merging
camera_preview.rsand takesLOOK_VERSION23; itdoes 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 thatfunction.
showing less than 90 % of it) changes. Per
docs/process-versions.mdthis is a change of the source (the cameracolour 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.
LOOK_VERSION28 (main 22; Upstream intake 2026-11-17: 15 PRs, 0 commits #1260 takes 23; 23-27 skipped because builds of forks usedthem for this change and others, so a stale cached look can't be mistaken for this one),
RENDER_CACHE_VERSION93(main 81; same reason, 82-92 skipped).
material, no lens profiles.
unsafe, build scripts, network access, spawned processes, deleted files, CI orxtaskgatechanges: none.
Checklist
proxies)🤖 Generated with Claude Code