Merge pull request #3943 from Janiczek/fix/lensfun-vignetting-look-fit

LR-PROF-CAMERACOLOR: lensfun vignetting no longer darkens and skews a raw's camera look (#3941)
This commit is contained in:
FredApps authored and GitHub committed 2026-11-26 17:37:11 +01:00
commit 27b15e3430
8 files changed
+593 -24

No files matched your search

+6 -3
View File
@@ -36,8 +36,8 @@ use hue_sat::{MIN_LUMINANCE_KEPT, NO_LUMINANCE_KEPT, fit_hue_sat, hue_saturation
pub(crate) use look_fit::fit_preview;
#[cfg(test)]
use look_fit::{
FIT_PREVIEW_MAX_PIXELS, SENSOR_CLIP, at_most, clips_more, correct_vignetting, fit_look, fit_look_with, sony_dro_off_tone, with_dro_off_tone,
with_pooled_tone, with_profile_colour, without_clipped,
FIT_PREVIEW_MAX_PIXELS, ProxyFrame, SENSOR_CLIP, at_most, camera_vignetting_amount, clips_more, correct_vignetting, fit_dng_tone, fit_look,
fit_look_with, sony_dro_off_tone, vignetting_gains, with_dro_off_tone, with_pooled_tone, with_profile_colour, without_clipped,
};
#[cfg(test)]
use mono::{fit_dark_tone, fit_tone_only, monochrome, monochrome_look, to_prophoto};
@@ -91,7 +91,10 @@ use tone::{HighlightCheck, ToneFit, fit_tone, fit_tone_conditional, highlights};
/// 16: a camera profile's pooled tone curve continues a photo's own past what its JPEG showed.
/// 17: only a look with the profile's colour continues along its pooled tone curve.
/// 18: continuing a photo's curve keeps it as it was where its JPEG taught it (`thinned_knots`).
pub const LOOK_VERSION: u32 = 18;
/// 26: a lens database's vignetting correction reaches the sensor proxy only in the share the camera JPEG shows
/// (`camera_vignetting_amount`, ranked within chromaticity classes), not whole: JPEGs that show less of it fitted looks too
/// dark, with skewed colour. The same for a DNG's tone fit; a CR3 proxy gets the gain where its framed pixels come from.
pub const LOOK_VERSION: u32 = 26;
#[derive(Clone, Debug)]
pub(crate) struct CameraLook {
+184 -11
View File
@@ -1,7 +1,7 @@
use super::colour::{PROXY, file_local_look};
use super::mono::{fit_tone_only_with, monochrome};
use super::pairs::{Attempt, TONE_FITS, fit_attempt, fit_partial, search_ordered};
use super::proxy::{CLIP_TOLERANCE, LensGeometry, MIN_PREVIEW_FRACTION, extend_tone, proxies, structure_agrees};
use super::proxy::{CLIP_TOLERANCE, Cr3Framing, LensGeometry, MIN_PREVIEW_FRACTION, extend_tone, framed_proxies, proxies, structure_agrees};
use super::tone::{HighlightCheck, highlights};
use super::{CameraLook, CameraTone, CameraTransform, HsvTable, Mat3, RawImage, Rgb32f, ToneMap, luminance_2020};
@@ -257,10 +257,14 @@ pub(super) fn fit_dng_tone(
let gain = 2f32.powf(transform.baseline_exposure as f32);
sensor.map_in_place(|p| tables.apply(p.map(|v| v / gain), gain));
}
correct_vignetting(&mut sensor, lens, raw.orientation);
if (sensor.width, sensor.height) != (reference.width, reference.height) {
return refuse("preview");
}
// a lens database's correction in the share the camera JPEG shows, as for the other raws (`look_proxies`)
match lens.filter(|l| l.source == lightcraft_develop::LensSource::Database).and_then(|l| l.vignette) {
Some(vignette) => database_vignetting(&mut sensor, &reference, &clipped, &vignette, ProxyFrame::new(raw.orientation)),
None => correct_vignetting(&mut sensor, lens, raw.orientation),
}
if !structure_agrees(&sensor, &reference) {
return refuse("structure");
}
@@ -311,7 +315,183 @@ pub(super) fn look_proxies(
lens: Option<&LensGeometry>,
embedded: Option<&lightcraft_develop::EmbeddedLens>,
) -> Option<(Rgb32f, Rgb32f, Vec<bool>)> {
proxies(raw, bytes, transform, PROXY, 0.0, lens, embedded)
// The file's own vignetting data is what its camera applied to the JPEG. A lens database profile describes the
// lens, not what this camera did: an ILCE-7M3 JPEG with an FE 28mm F2 at f/2 (maker note: vignetting correction
// Auto) shows none of lensfun's correction relative to its raw (the A7CR's shading Auto JPEGs show no consistent
// peripheral brightening either, docs/sony-lens-corrections.md). With the whole profile on the sensor that fit
// learned corners the JPEG doesn't have: 0.062 held-out RMS instead of 0.027, a darker, orange render. So the share
// of the profile the JPEG shows is measured. (Only without a lens warp: the gain goes on the returned proxy, and a
// warped one no longer has each pixel at its source position. A warp comes from the file's own opcodes, and a file
// with its own correction never gets a database profile, `lens_profiles::for_raw`.)
let database = embedded.filter(|e| e.source == lightcraft_develop::LensSource::Database && lens.is_none());
let Some(vignette) = database.and_then(|e| e.vignette) else {
return proxies(raw, bytes, transform, PROXY, 0.0, lens, embedded);
};
// A CR3's framing (`estimate_cr3_framing`) is estimated here on the uncorrected sensor, not the corrected one as
// before: it compares edge directions, which a smooth vignetting gain hardly moves. On the 22 corpus CR3s with a
// database profile it came out the same both ways (21 unmoved, the R50 V at scale 0.986).
let (mut sensor, reference, clipped, framing) = framed_proxies(raw, bytes, transform, PROXY, 0.0, lens, None)?;
// CR3 proxies come back oriented like the JPEG (their framing aligned to it), the others in sensor orientation
let orientation = if raw.format == lightcraft_raw::RawFormat::Cr3 { lightcraft_geom::Orientation::Normal } else { raw.orientation };
database_vignetting(&mut sensor, &reference, &clipped, &vignette, ProxyFrame { orientation, framing });
Some((sensor, reference, clipped))
}
/// Multiply `sensor` by the share of a lens database's `vignette` correction that the camera JPEG `reference` shows
/// ([`camera_vignetting_amount`]).
fn database_vignetting(
sensor: &mut Rgb32f,
reference: &Rgb32f,
clipped: &[bool],
vignette: &lightcraft_develop::EmbeddedVignette,
frame: ProxyFrame,
) {
let amount = camera_vignetting_amount(sensor, reference, clipped, vignette, frame);
apply_vignetting(sensor, vignette, frame, amount);
if lightcraft_pipeline::profiling() {
eprintln!("[profile] camera look: the camera JPEG shows {:.0} % of the lens database's vignetting correction", amount * 100.0);
}
}
/// Where a sensor proxy's pixels sit in the oriented, cropped frame a lens's vignetting is in: `framing` (a CR3 proxy
/// moved to its camera JPEG's framing, [`framed_proxies`]) takes each pixel to the position it shows, and
/// `orientation` maps that position to the oriented frame.
#[derive(Clone, Copy, Debug)]
pub(super) struct ProxyFrame {
pub(super) orientation: lightcraft_geom::Orientation,
pub(super) framing: Option<Cr3Framing>,
}
impl ProxyFrame {
/// A proxy whose pixels are where they were sampled, in the frame `orientation` maps to the oriented one.
pub(super) fn new(orientation: lightcraft_geom::Orientation) -> Self {
Self { orientation, framing: None }
}
}
/// Steps between none and all of a lens database's vignetting correction that [`camera_vignetting_amount`] tries.
const VIGNETTING_STEPS: u32 = 20;
/// Fewest usable proxy pixels [`camera_vignetting_amount`] measures on; with fewer it keeps the whole correction.
const MIN_VIGNETTING_PIXELS: usize = 256;
/// Hue sectors of the sensor's chromaticity that [`camera_vignetting_amount`] ranks within, besides the near-neutral
/// class ([`NEUTRAL_CHROMA`]).
const HUE_SECTORS: usize = 8;
/// Distance from grey (in `r - g`, `(r + g) / 2 - b` of the sensor's rgb chromaticity) below which a pixel counts as
/// near-neutral in [`camera_vignetting_amount`].
const NEUTRAL_CHROMA: f64 = 0.03;
/// Fewest pixels a chromaticity class needs to take part in [`camera_vignetting_amount`].
const MIN_CLASS_PIXELS: usize = 32;
/// Camera JPEG level at or above which a channel counts as clipped in [`camera_vignetting_amount`], as for the colour
/// pairs (`pairs::colour_pair`): the JPEG's brightness no longer follows the scene there, whether or not the sensor
/// clipped too ([`SENSOR_CLIP`]).
const JPEG_CLIP: f32 = 0.98;
/// The chromaticity class of a sensor pixel in [`camera_vignetting_amount`]: 0 near-neutral, else 1 + its hue sector.
fn chromaticity_class(p: [f64; 3]) -> usize {
let p = p.map(|v| v.max(0.0));
let sum = p[0] + p[1] + p[2];
if sum.is_nan() || sum <= 0.0 {
return 0;
}
let [r, g, b] = p.map(|v| v / sum);
let (a, yb) = (r - g, (r + g) * 0.5 - b);
if a.hypot(yb) < NEUTRAL_CHROMA {
return 0;
}
let sector = ((yb.atan2(a) + std::f64::consts::PI) / std::f64::consts::TAU * HUE_SECTORS as f64) as usize;
1 + sector.min(HUE_SECTORS - 1)
}
/// The share (0..=1, as the Vignetting amount slider scales it: `1 + (gain - 1) · amount`) of `vignette` that the
/// camera JPEG `reference` shows relative to the uncorrected `sensor` proxy. The camera's tone curve is monotone, so
/// with the share the camera applied, the corrected sensor orders its pixels by brightness as the JPEG does: the
/// share with the highest rank correlation of luminance. A camera's rendering also brightens or darkens some hues
/// more than others, and where those hues gather toward the corners (a blue sky above, a darker foreground), the
/// ranks across hues would read that as vignetting: the correlation is taken within classes of similar sensor
/// chromaticity ([`chromaticity_class`]), averaged by their pixel counts. Within a class the camera's rendering is
/// taken as alike: two saturations of one hue that it renders differently, one gathered toward the corners, can still
/// read as vignetting. Pixels clipped on the sensor (`clipped`) or in the JPEG ([`JPEG_CLIP`]), black and non-finite
/// pixels are left out. Proxies of different sizes, or fewer than
/// [`MIN_VIGNETTING_PIXELS`] usable pixels, keep the whole correction.
pub(super) fn camera_vignetting_amount(
sensor: &Rgb32f,
reference: &Rgb32f,
clipped: &[bool],
vignette: &lightcraft_develop::EmbeddedVignette,
frame: ProxyFrame,
) -> f64 {
if sensor.data.len() != reference.data.len() {
return 1.0;
}
let gains = vignetting_gains(sensor, vignette, frame);
let usable = |p: &[f32; 3]| p.iter().all(|v| v.is_finite()) && luminance_2020(*p) > 0.0;
let mut classes: Vec<Vec<(f64, [f64; 3], [f64; 3])>> = vec![Vec::new(); HUE_SECTORS + 1];
for (i, ((s, r), g)) in sensor.data.iter().zip(&reference.data).zip(gains).enumerate() {
if clipped.get(i).copied().unwrap_or(false) || !usable(s) || !usable(r) || r.iter().any(|v| *v >= JPEG_CLIP) {
continue;
}
let s = s.map(f64::from);
if let Some(class) = classes.get_mut(chromaticity_class(s)) {
class.push((g, s, r.map(f64::from)));
}
}
classes.retain(|c| c.len() >= MIN_CLASS_PIXELS);
let total: usize = classes.iter().map(Vec::len).sum();
if total < MIN_VIGNETTING_PIXELS {
return 1.0;
}
let agreement = |amount: f64| {
let weighted: f64 = classes
.iter()
.map(|class| {
let pairs: Vec<([f64; 3], [f64; 3])> = class.iter().map(|(g, s, r)| (s.map(|v| v * (1.0 + (g - 1.0) * amount)), *r)).collect();
super::pairs::rank_correlation_ties(&pairs) * class.len() as f64
})
.sum();
weighted / total as f64
};
// ties keep the larger share, the correction a camera JPEG usually has (the file's own data always gets all of it)
(0..=VIGNETTING_STEPS)
.map(|s| f64::from(s) / f64::from(VIGNETTING_STEPS))
.map(|a| (a, agreement(a)))
.fold((1.0, f64::MIN), |best, (a, r)| if r > best.1 + 1e-9 || ((r - best.1).abs() <= 1e-9 && a > best.0) { (a, r) } else { best })
.0
}
/// The render's vignetting gain (`optics::embedded_vignette_gain`) at each pixel of `sensor`, at the position `frame`
/// gives it in the oriented, cropped frame `vignette` is in.
pub(super) fn vignetting_gains(sensor: &Rgb32f, vignette: &lightcraft_develop::EmbeddedVignette, frame: ProxyFrame) -> Vec<f64> {
let (w, h) = (sensor.width as f64, sensor.height as f64);
let (ow, oh) = if frame.orientation.swaps_axes() { (h, w) } else { (w, h) };
let width = sensor.width.max(1);
(0..sensor.data.len())
.map(|i| {
let (px, py) = ((i % width) as f64 + 0.5, (i / width) as f64 + 0.5);
let (px, py) = match frame.framing {
Some(framing) => {
let (x, y) = framing.source(px as f32, py as f32, sensor.width, sensor.height);
(f64::from(x), f64::from(y))
}
None => (px, py),
};
let (x, y) = frame.orientation.map(px, py, w, h);
lightcraft_pipeline::optics::embedded_vignette_gain(vignette, lightcraft_geom::Point::new(x, y), ow, oh)
})
.collect()
}
/// Multiply `sensor` by `amount` of `vignette`'s correction, as the Vignetting amount slider scales it.
fn apply_vignetting(sensor: &mut Rgb32f, vignette: &lightcraft_develop::EmbeddedVignette, frame: ProxyFrame, amount: f64) {
let gains = vignetting_gains(sensor, vignette, frame);
for (p, g) in sensor.data.iter_mut().zip(gains) {
let gain = (1.0 + (g - 1.0) * amount) as f32;
*p = p.map(|v| v * gain);
}
}
/// Multiply the sensor proxy (sensor orientation, default crop) by the embedded vignetting correction, the gain the
@@ -319,12 +499,5 @@ pub(super) fn look_proxies(
/// camera JPEG has it applied, so a tone fitted without it brightens the render's corners twice.
pub(super) fn correct_vignetting(sensor: &mut Rgb32f, lens: Option<&lightcraft_develop::EmbeddedLens>, orientation: lightcraft_geom::Orientation) {
let Some(vignette) = lens.and_then(|l| l.vignette) else { return };
let (w, h) = (sensor.width as f64, sensor.height as f64);
let (ow, oh) = if orientation.swaps_axes() { (h, w) } else { (w, h) };
let width = sensor.width.max(1);
for (i, p) in sensor.data.iter_mut().enumerate() {
let (x, y) = orientation.map((i % width) as f64 + 0.5, (i / width) as f64 + 0.5, w, h);
let gain = lightcraft_pipeline::optics::embedded_vignette_gain(&vignette, lightcraft_geom::Point::new(x, y), ow, oh) as f32;
*p = p.map(|v| v * gain);
}
apply_vignetting(sensor, &vignette, ProxyFrame::new(orientation), 1.0);
}
+22 -6
View File
@@ -95,6 +95,20 @@ pub(super) fn proxies(
lens: Option<&LensGeometry>,
embedded: Option<&lightcraft_develop::EmbeddedLens>,
) -> Option<(Rgb32f, Rgb32f, Vec<bool>)> {
framed_proxies(raw, bytes, transform, size, min_fraction, lens, embedded).map(|(sensor, reference, clipped, _)| (sensor, reference, clipped))
}
/// [`proxies`], and the CR3 framing the sensor proxy was moved to ([`estimate_cr3_framing`]; `None` when it was not
/// moved): a pixel of the returned CR3 sensor proxy shows the oriented sensor at `framing.source` of its position.
pub(super) fn framed_proxies(
raw: &RawImage,
bytes: &[u8],
transform: &CameraTransform,
size: usize,
min_fraction: f64,
lens: Option<&LensGeometry>,
embedded: Option<&lightcraft_develop::EmbeddedLens>,
) -> Option<(Rgb32f, Rgb32f, Vec<bool>, Option<Cr3Framing>)> {
let edge = (2 * size).max(384) as u32;
let decoded = crate::files::decode_raw_preview(
bytes,
@@ -129,6 +143,7 @@ pub(super) fn proxies(
let k = (crop.width.max(crop.height).div_ceil(edge as usize).max(2)).div_ceil(2) * 2;
let mut sensor = sensor_proxy(raw, k, edge as usize)?;
let mut clipped = clip_mask(&sensor);
let mut framing = None;
correct_vignetting(&mut sensor, embedded, raw.orientation);
// The camera may have corrected its JPEG with the lens warp the file carries (Nikon Z lenses always, at up to 9 %
// zoom; other cameras when their correction setting is on): the sensor moved into that geometry is a candidate,
@@ -146,7 +161,7 @@ pub(super) fn proxies(
sensor.map_in_place(to_working);
// Canon's JPEG can be cropped differently from the sensor. Estimate only that common
// framing from edge directions, independently of the subsequent colour fit.
(sensor, clipped) = align_cr3_framing(sensor, clipped, &reference);
(sensor, clipped, framing) = align_cr3_framing(sensor, clipped, &reference);
}
let mut sensor = fit(&sensor, size, size, Filter::Box);
let mut reference_small = reference_at(&reference, &sensor);
@@ -165,7 +180,7 @@ pub(super) fn proxies(
if raw.format != RawFormat::Cr3 {
sensor.map_in_place(to_working);
}
Some((sensor, reference, clipped))
Some((sensor, reference, clipped, framing))
}
/// The camera JPEG at exactly the sensor proxy's size, so the two pair pixel for pixel. Fitting it
@@ -301,9 +316,10 @@ pub(super) fn estimate_cr3_framing(sensor: &Rgb32f, reference: &Rgb32f) -> Optio
Some(best.1)
}
/// The sensor proxy and its clip mask (same size), both moved to the camera JPEG's framing.
fn align_cr3_framing(sensor: Rgb32f, clipped: Rgb32f, reference: &Rgb32f) -> (Rgb32f, Rgb32f) {
let Some(framing) = estimate_cr3_framing(&sensor, reference) else { return (sensor, clipped) };
/// The sensor proxy and its clip mask (same size), both moved to the camera JPEG's framing, and that framing (`None`
/// when they stay as they are).
fn align_cr3_framing(sensor: Rgb32f, clipped: Rgb32f, reference: &Rgb32f) -> (Rgb32f, Rgb32f, Option<Cr3Framing>) {
let Some(framing) = estimate_cr3_framing(&sensor, reference) else { return (sensor, clipped, None) };
let apply = |image: &Rgb32f| {
let (w, h) = (image.width, image.height);
let mut aligned = Rgb32f::new(w, h);
@@ -313,7 +329,7 @@ fn align_cr3_framing(sensor: Rgb32f, clipped: Rgb32f, reference: &Rgb32f) -> (Rg
}
aligned
};
(apply(&sensor), apply(&clipped))
(apply(&sensor), apply(&clipped), Some(framing))
}
/// What one photo contributes to a camera profile ([`profile_samples`]), in white-balanced camera RGB.
+342
View File
@@ -2196,6 +2196,58 @@ fn the_colour_look_is_fitted_on_the_vignetting_corrected_sensor() {
assert!(uncorrected > corrected + 0.03, "without the correction the curve brightens: {uncorrected} vs {corrected}");
}
/// A lens database profile reaches the fit only as far as the camera JPEG shows it. A camera that left its JPEG
/// uncorrected relative to its raw keeps the curve fitted without any correction: with the whole
/// profile on the sensor the curve darkened and the colour fit bent (an ILCE-7M3 with an FE 28mm F2 at f/2 rendered
/// darker and orange). A camera that corrected its JPEG fully gets the whole correction, as with the file's own data.
#[test]
fn a_lens_database_vignetting_reaches_the_fit_as_far_as_the_camera_jpeg_shows_it() {
use lightcraft_develop::{EmbeddedLens, EmbeddedVignette, LensSource};
let (w, h) = (192usize, 128usize);
let vignette = EmbeddedVignette { k: [1.0, 0.0, 0.0, 0.0, 0.0], center: lightcraft_geom::Point::new(0.5, 0.5), radius: 0.6 };
let gain = |x: usize, y: usize| {
let point = lightcraft_geom::Point::new(x as f64 + 0.5, y as f64 + 0.5);
lightcraft_pipeline::optics::embedded_vignette_gain(&vignette, point, w as f64, h as f64) as f32
};
let scene = |x: usize, y: usize| 0.01 + 0.5 * (x as f32 / w as f32) * (0.3 + 0.7 * y as f32 / h as f32);
let database = EmbeddedLens { vignette: Some(vignette), source: LensSource::Database, ..Default::default() };
let camera = 1.0 - (-0.75f32).exp();
let at_quarter = |raw: &RawImage, bytes: &[u8], embedded: Option<&EmbeddedLens>| {
let t = lightcraft_raw::color::camera_transform(raw, lightcraft_raw::color::as_shot_white_xy(raw));
let look = monochrome_look(raw, bytes, &t, None, embedded).expect("a tone curve");
ToneMap::camera(&look.tone, 0.0, 0.0, 0.0).apply(0.25)
};
// the camera JPEG of the vignetted sensor, uncorrected
let vignetted = |x: usize, y: usize| scene(x, y) / gain(x, y);
let (raw, bytes) = grey_raw_with_jpeg((w, h), vignetted, vignetted, [1.0; 3]);
let (with_profile, without) = (at_quarter(&raw, &bytes, Some(&database)), at_quarter(&raw, &bytes, None));
assert!((with_profile - camera).abs() < 0.03, "the camera's curve at 0.25: {with_profile} vs {camera}");
assert!((with_profile - without).abs() < 0.01, "as without the profile: {with_profile} vs {without}");
// the same in colour: the tinted JPEG takes the colour fit, whose curve the whole profile darkened
let tint = [1.0, 0.9, 0.8];
let (raw, bytes) = grey_raw_with_jpeg((w, h), vignetted, vignetted, tint);
let colour_at_quarter = |raw: &RawImage, bytes: &[u8], embedded: Option<&EmbeddedLens>| {
let (_, _, look) = starting_colour(&mut raw.clone(), bytes, None, embedded);
let look = look.expect("a colour look");
assert!(look.matrix != Mat3::IDENTITY || look.hue_sat.is_some(), "the colour fit, not the black-and-white one");
ToneMap::camera(&look.tone, 0.0, 0.0, 0.0).apply(0.25)
};
let (with_profile, without) = (colour_at_quarter(&raw, &bytes, Some(&database)), colour_at_quarter(&raw, &bytes, None));
assert!((with_profile - without).abs() < 0.01, "the colour fit's curve as without the profile: {with_profile} vs {without}");
// a camera JPEG with the whole correction applied: the whole correction reaches the fit
let (raw, bytes) = grey_raw_with_jpeg((w, h), vignetted, scene, [1.0; 3]);
let corrected = at_quarter(&raw, &bytes, Some(&database));
assert!((corrected - camera).abs() < 0.03, "the camera's curve at 0.25: {corrected} vs {camera}");
// and in colour: the colour fit keeps the database profile, whose correction it would otherwise learn into the curve
let (raw, bytes) = grey_raw_with_jpeg((w, h), vignetted, scene, tint);
let (with_profile, without) = (colour_at_quarter(&raw, &bytes, Some(&database)), colour_at_quarter(&raw, &bytes, None));
assert!(without > with_profile + 0.03, "without the profile the colour fit's curve brightens: {without} vs {with_profile}");
}
/// A lens-warped sensor proxy gets the vignetting gain of the position it samples, as the render applies it: the
/// vignetted sensor, corrected, gives the proxy of the same sensor without vignetting.
#[test]
@@ -2448,6 +2500,48 @@ fn dng_tone_gates_follow_the_files_own_tags() {
assert!(looked.profile.look_table.is_some() && eligible(RawFormat::Dng, looked), "a look table defines colour, not tone");
}
/// A DNG's tone fit takes a lens database's vignetting correction in the share its camera JPEG shows, as the other
/// raws' fits do: none for a JPEG left uncorrected (the curve as without the profile), all of it for a corrected one.
/// The file's own vignetting data still reaches it whole.
#[test]
fn dng_tone_fit_takes_a_lens_database_vignetting_as_far_as_the_camera_jpeg_shows_it() {
use lightcraft_develop::{EmbeddedLens, EmbeddedVignette, LensSource};
let (w, h) = (384usize, 256usize);
let vignette = EmbeddedVignette { k: [1.0, 0.0, 0.0, 0.0, 0.0], center: lightcraft_geom::Point::new(0.5, 0.5), radius: 0.6 };
let gain = |x: usize, y: usize| {
let point = lightcraft_geom::Point::new(x as f64 + 0.5, y as f64 + 0.5);
lightcraft_pipeline::optics::embedded_vignette_gain(&vignette, point, w as f64, h as f64) as f32
};
// a gradient with blocks of texture, so the preview shows the same picture (`structure_agrees`)
let texture = |x: usize, y: usize| ((x / 6).wrapping_mul(2_654_435_761) ^ (y / 6).wrapping_mul(40_503)) % 7;
let scene = |x: usize, y: usize| (0.01 + 0.5 * (x as f32 / w as f32) * (0.3 + 0.7 * y as f32 / h as f32)) * (0.55 + 0.075 * texture(x, y) as f32);
let vignetted = |x: usize, y: usize| scene(x, y) / gain(x, y);
let database = EmbeddedLens { vignette: Some(vignette), source: LensSource::Database, ..Default::default() };
let at_quarter = |jpeg_scene: &dyn Fn(usize, usize) -> f32, embedded: Option<&EmbeddedLens>| {
// tinted: a fit's pairs need some colour (`collect_pairs`)
let (mut raw, bytes) = grey_raw_with_jpeg((w, h), vignetted, jpeg_scene, [1.0, 0.95, 0.9]);
raw.format = RawFormat::Dng;
// a camera whose RGB is linear sRGB (XYZ to sRGB under D65): the grey sensor stays grey
let xyz_to_camera = Mat3([[3.2406, -1.5372, -0.4986], [-0.9689, 1.8758, 0.0415], [0.0557, -0.2040, 1.0570]]);
raw.color = lightcraft_raw::ColorData { illuminant: [21, 0], color_matrix: [Some(xyz_to_camera), None], ..Default::default() };
let t = lightcraft_raw::color::camera_transform(&raw, lightcraft_raw::color::as_shot_white_xy(&raw));
assert!(dng_tone_eligible(&raw, &t), "a DNG whose tone the fit defines");
let look = fit_dng_tone(&raw, &bytes, &t, embedded).expect("a DNG tone fit");
ToneMap::camera(&look.tone, 0.0, 0.0, 0.0).apply(0.25)
};
let (with_profile, without) = (at_quarter(&vignetted, Some(&database)), at_quarter(&vignetted, None));
assert!((with_profile - without).abs() < 0.01, "an uncorrected JPEG, as without the profile: {with_profile} vs {without}");
let (with_profile, without) = (at_quarter(&scene, Some(&database)), at_quarter(&scene, None));
assert!(without > with_profile + 0.03, "a corrected JPEG: without the profile the curve brightens: {without} vs {with_profile}");
// the file's own vignetting data is what its camera applied: it reaches the fit whole, whatever the JPEG shows
let file = EmbeddedLens { source: LensSource::File, ..database };
let with_file = at_quarter(&scene, Some(&file));
assert!((with_file - with_profile).abs() < 0.01, "a corrected JPEG, as with the measured share: {with_file} vs {with_profile}");
let (with_file, without) = (at_quarter(&vignetted, Some(&file)), at_quarter(&vignetted, None));
assert!(without > with_file + 0.03, "an uncorrected JPEG still gets the file's whole correction: {without} vs {with_file}");
}
/// The 1024 px preview Lightroom Classic writes into a 7008 px DNG is fitted; a 256 px thumbnail is not.
#[test]
fn dng_tone_fit_takes_lightroom_sized_previews() {
@@ -2798,3 +2892,251 @@ fn a_narrow_black_and_white_curve_that_darkens_the_bright_areas_is_refused() {
assert!(sky > 0.8, "an accepted curve must not darken what the camera renders at 0.93: {sky}");
}
}
/// A lens database's vignetting correction reaches the fit in the share the camera JPEG shows: a JPEG with none, part
/// or all of it is measured as such, and a JPEG without enough usable pixels keeps the whole correction.
#[test]
fn camera_vignetting_amount_measures_the_share_the_jpeg_shows() {
use lightcraft_develop::EmbeddedVignette;
let vignette = EmbeddedVignette { k: [2.0, 1.0, 0.0, 0.0, 0.0], center: lightcraft_geom::Point::new(0.5, 0.5), radius: 0.6 };
let (w, h) = (96, 64);
let gain = |i: usize| {
lightcraft_pipeline::optics::embedded_vignette_gain(
&vignette,
lightcraft_geom::Point::new((i % w) as f64 + 0.5, (i / w) as f64 + 0.5),
w as f64,
h as f64,
) as f32
};
// a scene of unrelated brightnesses (no gradient for the vignetting to hide in), darkened by the lens
let mut seed = 12345u32;
let mut sensor = Rgb32f::new(w, h);
for (i, p) in sensor.data.iter_mut().enumerate() {
seed = seed.wrapping_mul(1_664_525).wrapping_add(1_013_904_223);
let v = 0.02 + 0.4 * (seed >> 8) as f32 / (1u32 << 24) as f32;
*p = [v, v * 0.9, v * 0.7].map(|c| c / gain(i));
}
let clipped = vec![false; w * h];
for shown in [0.0, 0.4, 1.0] {
let mut reference = sensor.clone();
for (i, p) in reference.data.iter_mut().enumerate() {
let g = 1.0 + (gain(i) - 1.0) * shown;
*p = p.map(|c| (c * g).powf(1.0 / 2.2).min(1.0));
}
let amount = camera_vignetting_amount(&sensor, &reference, &clipped, &vignette, ProxyFrame::new(lightcraft_geom::Orientation::Normal));
assert!((amount - f64::from(shown)).abs() < 0.051, "the JPEG shows {shown}, measured {amount}");
}
// too few pixels to measure on: the whole correction, although this JPEG shows none of it
let (tw, th) = (8, 8);
let mut tiny = Rgb32f::new(tw, th);
for (i, p) in tiny.data.iter_mut().enumerate() {
let g = lightcraft_pipeline::optics::embedded_vignette_gain(
&vignette,
lightcraft_geom::Point::new((i % tw) as f64 + 0.5, (i / tw) as f64 + 0.5),
tw as f64,
th as f64,
) as f32;
let v = 0.05 + 0.05 * ((i * 7) % 8) as f32;
*p = [v, v * 0.9, v * 0.7].map(|c| c / g);
}
let mut tiny_reference = tiny.clone();
tiny_reference.map_in_place(|p| p.map(|c| c.powf(1.0 / 2.2)));
let frame = ProxyFrame::new(lightcraft_geom::Orientation::Normal);
assert_eq!(camera_vignetting_amount(&tiny, &tiny_reference, &[false; 64], &vignette, frame), 1.0);
}
/// A camera that renders some hues brighter than others doesn't read as vignetting where those hues gather toward
/// the corners: the JPEG without any correction, whose blue pixels (more of them toward the corners) the camera
/// renders brighter, is measured as showing none of it.
#[test]
fn camera_vignetting_amount_is_not_misled_by_hues_gathered_in_the_corners() {
use lightcraft_develop::EmbeddedVignette;
let vignette = EmbeddedVignette { k: [2.0, 1.0, 0.0, 0.0, 0.0], center: lightcraft_geom::Point::new(0.5, 0.5), radius: 0.6 };
let (w, h) = (96, 64);
let mut seed = 54321u32;
let mut random = || {
seed = seed.wrapping_mul(1_664_525).wrapping_add(1_013_904_223);
(seed >> 8) as f32 / (1u32 << 24) as f32
};
let mut sensor = Rgb32f::new(w, h);
let mut reference = Rgb32f::new(w, h);
for (i, (s, r)) in sensor.data.iter_mut().zip(reference.data.iter_mut()).enumerate() {
let point = lightcraft_geom::Point::new((i % w) as f64 + 0.5, (i / w) as f64 + 0.5);
let gain = lightcraft_pipeline::optics::embedded_vignette_gain(&vignette, point, w as f64, h as f64) as f32;
let radius = ((point.x / w as f64 - 0.5).hypot(point.y / h as f64 - 0.5) / 0.5f64.hypot(0.5)) as f32;
let v = (0.02 + 0.4 * random()) / gain;
let blue = random() < radius;
*s = if blue { [0.4 * v, 0.6 * v, v] } else { [v, 0.6 * v, 0.4 * v] };
let brightness = if blue { 1.6 } else { 1.0 };
*r = s.map(|c| (c * brightness).powf(1.0 / 2.2).min(1.0));
}
let clipped = vec![false; w * h];
let amount = camera_vignetting_amount(&sensor, &reference, &clipped, &vignette, ProxyFrame::new(lightcraft_geom::Orientation::Normal));
assert!(amount < 0.051, "the JPEG shows no correction, measured {amount}");
}
/// A CR3 sensor proxy moved to its camera JPEG's framing gets the vignetting gain of the position each pixel shows,
/// not of where it lands.
#[test]
fn the_vignetting_gain_of_a_framed_proxy_is_taken_where_its_pixels_come_from() {
use lightcraft_develop::EmbeddedVignette;
let vignette = EmbeddedVignette { k: [2.0, 1.0, 0.0, 0.0, 0.0], center: lightcraft_geom::Point::new(0.5, 0.5), radius: 0.6 };
let (w, h) = (96, 64);
let framing = Cr3Framing { scale: 0.92, offset: [0.02, -0.015] };
let frame = ProxyFrame { orientation: lightcraft_geom::Orientation::Normal, framing: Some(framing) };
let gains = vignetting_gains(&Rgb32f::new(w, h), &vignette, frame);
for i in [0, w - 1, w * h / 2 + w / 3, w * h - 1] {
let (x, y) = framing.source((i % w) as f32 + 0.5, (i / w) as f32 + 0.5, w, h);
let expected = lightcraft_pipeline::optics::embedded_vignette_gain(
&vignette,
lightcraft_geom::Point::new(f64::from(x), f64::from(y)),
w as f64,
h as f64,
);
assert!((gains[i] - expected).abs() < 1e-9, "pixel {i}: {} vs {expected}", gains[i]);
}
}
/// What `camera_vignetting_amount` can't measure on keeps the whole correction: proxies of different sizes, and a flat
/// scene, where every share ranks alike (a tie keeps the larger share, the correction a camera JPEG usually has).
/// Clipped and black pixels are left out: here they sit where the correction would brighten or darken them most and
/// would pull the share of a JPEG without any correction up. A JPEG clips highlights the sensor doesn't, so pixels
/// clipped in the JPEG are left out without the sensor's clip mask too. Non-finite pixels don't spoil the measurement.
#[test]
fn camera_vignetting_amount_falls_back_and_leaves_out_what_it_cannot_measure() {
use lightcraft_develop::EmbeddedVignette;
let vignette = EmbeddedVignette { k: [2.0, 1.0, 0.0, 0.0, 0.0], center: lightcraft_geom::Point::new(0.5, 0.5), radius: 0.6 };
let (w, h) = (96, 64);
let gains: Vec<f32> = (0..w * h)
.map(|i| {
let point = lightcraft_geom::Point::new((i % w) as f64 + 0.5, (i / w) as f64 + 0.5);
lightcraft_pipeline::optics::embedded_vignette_gain(&vignette, point, w as f64, h as f64) as f32
})
.collect();
let measure = |sensor: &Rgb32f, reference: &Rgb32f, clipped: &[bool]| {
camera_vignetting_amount(sensor, reference, clipped, &vignette, ProxyFrame::new(lightcraft_geom::Orientation::Normal))
};
let unclipped = vec![false; w * h];
let mut flat = Rgb32f::new(w, h);
flat.data.fill([0.2, 0.18, 0.14]);
assert_eq!(measure(&flat, &flat, &unclipped), 1.0, "a tie keeps the whole correction");
assert_eq!(measure(&flat, &Rgb32f::new(w, h / 2), &unclipped), 1.0, "proxies of different sizes");
// a scene of unrelated brightnesses, darkened by the lens, and its JPEG without any correction
let mut seed = 777u32;
let mut sensor = Rgb32f::new(w, h);
for (p, g) in sensor.data.iter_mut().zip(&gains) {
seed = seed.wrapping_mul(1_664_525).wrapping_add(1_013_904_223);
let v = 0.02 + 0.4 * (seed >> 8) as f32 / (1u32 << 24) as f32;
*p = [v, v * 0.9, v * 0.7].map(|c| c / g);
}
let mut reference = sensor.clone();
reference.data.iter_mut().for_each(|p| *p = p.map(|c| c.powf(1.0 / 2.2)));
assert!(measure(&sensor, &reference, &unclipped) < 0.051);
let mut sorted = gains.clone();
sorted.sort_by(f32::total_cmp);
let (low, high) = (sorted[w * h / 4], sorted[w * h * 3 / 4]);
// the quarter the correction brightens most, clipped white in the JPEG
let corners: Vec<bool> = gains.iter().map(|g| *g >= high).collect();
let mut clipped_reference = reference.clone();
clipped_reference.data.iter_mut().zip(&corners).filter(|(_, c)| **c).for_each(|(p, _)| *p = [1.0; 3]);
let amount = measure(&sensor, &clipped_reference, &corners);
assert!(amount < 0.051, "clipped pixels are left out: measured {amount}");
let amount = measure(&sensor, &clipped_reference, &unclipped);
assert!(amount < 0.051, "pixels clipped in the JPEG alone are left out: measured {amount}");
let mut bright_reference = reference.clone();
bright_reference.data.iter_mut().zip(&corners).filter(|(_, c)| **c).for_each(|(p, _)| *p = [0.97; 3]);
let amount = measure(&sensor, &bright_reference, &unclipped);
assert!(amount > 0.1, "the same pixels, just below the clip, would have pulled the share up: {amount}");
// the quarter it brightens least, black in the JPEG
let mut dark_reference = reference.clone();
let darkened = |level: f32| {
let mut r = dark_reference.clone();
r.data.iter_mut().zip(&gains).filter(|(_, g)| **g <= low).for_each(|(p, _)| *p = [level; 3]);
r
};
let amount = measure(&sensor, &darkened(0.0), &unclipped);
assert!(amount < 0.051, "black pixels are left out: measured {amount}");
let amount = measure(&sensor, &darkened(1e-3), &unclipped);
assert!(amount > 0.1, "the same pixels, measurable, would have pulled the share up: {amount}");
// non-finite pixels in either proxy
for i in (0..w * h).step_by(37) {
sensor.data[i] = [f32::NAN, 0.1, 0.1];
dark_reference.data[i + 1] = [f32::INFINITY; 3];
}
let amount = measure(&sensor, &dark_reference, &unclipped);
assert!(amount < 0.051, "non-finite pixels are left out: measured {amount}");
}
/// A sensor proxy of a photo turned upright gets the gain of where each pixel lands in the upright frame the lens
/// profile describes: with the optical centre off the middle, pixel (x, y) of a 96 × 64 sensor turned a quarter
/// clockwise takes the gain at (64 - y, x) of the 64 × 96 upright frame, and turned anticlockwise at (y, 96 - x).
#[test]
fn the_vignetting_gain_of_a_turned_proxy_is_taken_in_the_upright_frame() {
use lightcraft_develop::EmbeddedVignette;
use lightcraft_geom::{Orientation, Point};
let vignette = EmbeddedVignette { k: [2.0, 1.0, 0.0, 0.0, 0.0], center: Point::new(0.3, 0.6), radius: 0.6 };
let (w, h) = (96usize, 64usize);
let (wf, hf) = (w as f64, h as f64);
let normal = vignetting_gains(&Rgb32f::new(w, h), &vignette, ProxyFrame::new(Orientation::Normal));
for (orientation, upright) in [
(Orientation::Rotate90, (|x: f64, y: f64, _: f64, h: f64| (h - y, x)) as fn(f64, f64, f64, f64) -> (f64, f64)),
(Orientation::Rotate270, |x, y, w, _| (y, w - x)),
] {
let gains = vignetting_gains(&Rgb32f::new(w, h), &vignette, ProxyFrame::new(orientation));
let mut differ = 0;
for i in 0..w * h {
let (x, y) = upright((i % w) as f64 + 0.5, (i / w) as f64 + 0.5, wf, hf);
let expected = lightcraft_pipeline::optics::embedded_vignette_gain(&vignette, Point::new(x, y), hf, wf);
assert!((gains[i] - expected).abs() < 1e-9, "{orientation:?}, pixel {i}: {} vs {expected}", gains[i]);
differ += usize::from((gains[i] - normal[i]).abs() > 1e-3);
}
assert!(differ > w * h / 2, "{orientation:?}: the turn matters for this lens ({differ} pixels differ)");
}
}
/// A CR3 sensor proxy moved to its camera JPEG's framing is measured with the gain of where its pixels come from: the
/// share a JPEG with the whole correction shows is found with the framing, and missed without it.
#[test]
fn camera_vignetting_amount_follows_a_cr3_proxys_framing() {
use lightcraft_develop::EmbeddedVignette;
use lightcraft_geom::{Orientation, Point};
let vignette = EmbeddedVignette { k: [2.0, 1.0, 0.0, 0.0, 0.0], center: Point::new(0.5, 0.5), radius: 0.6 };
let (w, h) = (96usize, 64usize);
let framing = Cr3Framing { scale: 0.8, offset: [0.08, -0.06] };
// a scene of unrelated brightnesses, one per sensor pixel
let scene = |x: f32, y: f32| {
let seed = (x.floor() as u32).wrapping_mul(73_856_093) ^ (y.floor() as u32).wrapping_mul(19_349_663);
0.02 + 0.4 * (seed.wrapping_mul(1_664_525).wrapping_add(1_013_904_223) >> 8) as f32 / (1u32 << 24) as f32
};
// the framed proxy: pixel q shows the vignetted sensor at `framing.source(q)`
let mut sensor = Rgb32f::new(w, h);
let mut source_gains = Vec::with_capacity(w * h);
for (i, p) in sensor.data.iter_mut().enumerate() {
let (x, y) = framing.source((i % w) as f32 + 0.5, (i / w) as f32 + 0.5, w, h);
let g = lightcraft_pipeline::optics::embedded_vignette_gain(&vignette, Point::new(f64::from(x), f64::from(y)), w as f64, h as f64) as f32;
let v = scene(x, y) / g;
*p = [v, v * 0.9, v * 0.7];
source_gains.push(g);
}
let clipped = vec![false; w * h];
let measure = |reference: &Rgb32f, framing: Option<Cr3Framing>| {
camera_vignetting_amount(&sensor, reference, &clipped, &vignette, ProxyFrame { orientation: Orientation::Normal, framing })
};
for shown in [0.0f32, 0.75, 1.0] {
let mut reference = sensor.clone();
for (p, g) in reference.data.iter_mut().zip(&source_gains) {
*p = p.map(|c| (c * (1.0 + (g - 1.0) * shown)).powf(1.0 / 2.2));
}
let framed = measure(&reference, Some(framing));
assert!((framed - f64::from(shown)).abs() < 0.051, "the JPEG shows {shown}, measured {framed} with the framing");
if shown == 1.0 {
let unframed = measure(&reference, None);
assert!(unframed < 0.9, "without the framing the gains are taken at the wrong places: {unframed}");
}
}
}
+3 -2
View File
@@ -1,11 +1,12 @@
use super::{Arc, DcpProfile, Deserialize, DevelopSettings, MediaKind, Photo, Rgb32f, Rgba8, Serialize, SourceInfo};
/// Bump when the pipeline's output changes, to invalidate cached thumbnails.
/// 87: a lens database's vignetting correction reaches the look fit only in the share the camera JPEG shows
/// (#3943, which had reserved 83: taken after 86, so a later bump counting up from here can't meet an older cache).
/// 86: pushed shadows keep the camera profile's colour and tone (#2092).
/// 85: raw decoding keeps negative channels (#2278).
/// 84: full-size raw demosaic runs on the white-balanced mosaic with a clip mask (#1328).
/// 83 is reserved by open #3943.
pub const RENDER_CACHE_VERSION: u64 = 86;
pub const RENDER_CACHE_VERSION: u64 = 87;
/// Thumbnails render at one of these long edges (so window/cell size changes reuse the cache).
pub const THUMB_SIZES: [usize; 4] = [128, 256, 384, 512];
+24 -1
View File
@@ -136,7 +136,30 @@ it (Enable Profile Corrections). The camera applied the same correction to its J
(`fit_preview`, `monochrome_look`, the near-black tone fallback) therefore takes its sensor proxy through
`look_proxies`, which multiplies it by that gain as `fit_dng_tone` already did (`correct_vignetting`). Before
`LOOK_VERSION` 13 the RAF fit saw the uncorrected sensor: the tone curve learned the JPEG's corrected brightness, and
the render added the correction again. Lens-database corrections (`LIGHTCRAFT_LENSFUN_DIR`) reach the fit the same way.
the render added the correction again. A lens-database profile (`LIGHTCRAFT_LENSFUN_DIR`, the downloaded lensfun data)
describes the lens, not what the camera did to its JPEG, so since `LOOK_VERSION` 26 it reaches the fit only in the
share the JPEG shows (`camera_vignetting_amount`): the camera's tone curve is monotone, so the share whose corrected
sensor ranks its pixels' luminance most like the JPEG wins (0 to 100 % in 5 % steps). The ranks are compared within
classes of similar sensor chromaticity (near-neutral and eight hue sectors), weighted by their pixel counts: a camera
that renders some hues brighter than others would otherwise read as vignetting where those hues gather toward the
corners. A CR3 proxy moved to its JPEG's framing gets the gain of the position each pixel shows, and a DNG's tone fit
(`fit_dng_tone`) takes a database profile in the measured share too. The whole correction is kept when nothing can
be measured: proxies of different sizes, fewer than 256 usable pixels (pixels clipped on the sensor or in the camera
JPEG, black and non-finite ones are left out, as are chromaticity classes under 32 pixels), a lens-warped sensor proxy (the gain would no longer be at each
pixel's source position); shares that rank alike keep the larger one. Within a class the camera's rendering is taken as alike, so two
saturations of one hue that it renders differently, one gathered toward the corners, can still read as vignetting.
With the whole profile, an ILCE-7M3 frame at f/2 with an FE 28mm F2 (lensfun: corners at 16 % of the centre) fitted
0.062 held-out RMS instead of 0.027 and rendered darker and orange. Its camera JPEG, with vignetting correction Auto
in the maker note, is measured as showing none of that correction relative to the raw, like the A7CR JPEGs in
[sony-lens-corrections.md](sony-lens-corrections.md). Of 91 CC0 corpus raws (all 37 ARWs, 19 ORFs, 15 PEFs, 20
NEFs), 10 get a lens database vignetting profile into their fit (7 Sony, 2 Olympus, 1 Nikon). The shares measured
are 0 % on two, 5 % on three (SLT-A33, ILCE-7SM2, DSC-RX1RM3) and 10–45 % on five, and the mean CIEDE2000 of the
central half of the render against the camera JPEG goes from 4.69 to 3.96 (6 better, 3 within 0.05, the SLT-A33 0.12
worse). The whole profile had made 9 of the 10 darker (0.4 to 8.5 L*), with small, scene-dependent colour shifts
(mostly lost chroma). Of the 35 corpus CR3s, 22 get a lens database vignetting profile into their fit; their camera
JPEGs show 0 to 100 % of it (median 45 %), the held-out RMS is lower on 21, and the mean CIEDE2000 goes from 2.86 to
2.62 (13 better, 5 within 0.05, 4 worse by up to 0.22). Their framing is estimated on the uncorrected sensor and came
out the same as on the corrected one for all 22.
`proxies` applies the gain before it moves the sensor into the JPEG's lens geometry, so each pixel gets the gain of the
position it samples, as in the render. The choice between the warped and the plain sensor (`alignment`) leaves out
the pixels the warp finds no sensor for. It used to read them as black, a false edge along the border that made the
+7
View File
@@ -82,6 +82,13 @@ corrections: **Enable Profile Corrections** and its Distortion / Vignetting amou
stage (one resample), orientation handling and DNG export. A conversion whose radial error exceeds 0.001 of the
half diagonal, or that would fold the image, is not applied.
A raw whose look is fitted to its own camera JPEG (Sony, Nikon, Pentax, Olympus and others without a colour
matrix, and a DNG whose tone is fitted to its preview, [camera-preview-colour.md](camera-preview-colour.md)) has that fit made on the sensor with only the
share of a profile's vignetting correction its camera JPEG shows, measured per photo: the profile describes the
lens, not what the camera did to its JPEG relative to the raw (a Sony JPEG with shading compensation Auto can show
none of it). When the share can't be measured (too few usable pixels, or a lens-warped sensor proxy) the fit keeps
the whole correction. The render still applies the profile at the Vignetting amount.
Normalisation follows lensfun's documentation: distortion and TCA radii are 1 at half the shorter side of the
calibration frame (its `cropfactor` and `aspect-ratio`), vignetting radii 1 at its corner; the optical centre is
the image centre (lensfun's `<center>` offsets are not read). Missing or invalid crop factors remain unknown;
+5 -1
View File
@@ -222,7 +222,10 @@ Neither names ORF or specifies its file layout. These references do not establis
bodies, median ΔE 5.1, ΔL\* +0.2; rejected fits fall back to a neutral matrix at median ΔE 18.5,
ΔL\* −11, chroma ×0.39. RW2 140 of 174 files accepted, median 5.0. NEF 13 of 13, 2.9–7.8. RAF 23 of
24, pooled X-H2S 1.62 / X-T4 2.34 (measured before `LOOK_VERSION` 13 stopped applying the embedded vignetting
correction twice); X-S10, 60 photos not used to find that bug, mean ΔE00 2.71 → 2.55 with it fixed. SRW 2.2–7.6.
correction twice); X-S10, 60 photos not used to find that bug, mean ΔE00 2.71 → 2.55 with it fixed. Since
`LOOK_VERSION` 26 a lens database's vignetting reaches the fit only in the share the camera JPEG shows (an
ILCE-7M3 with an FE 28mm F2 at f/2, whose JPEG shows none of it, had rendered darker and orange with the whole
profile). SRW 2.2–7.6.
- Against Lightroom itself (few): Sony DRO median ΔE76 7.5 → 3.3; Olympus E-1 vs Lightroom Classic
ΔE00 11.25 → 8.30; ProRAW with its gain map ΔE00 19 (why the map is off). No measurement against
Adobe Standard across models exists.
@@ -294,6 +297,7 @@ Beyond decoding:
| Date | Change | Summary |
|---|---|---|
| 2026-11-07 | patch | Camera look: a lens database's vignetting reaches the per-file fit only in the share the camera JPEG shows (`LOOK_VERSION` 26), so raws whose JPEG shows little or none of it (mostly Sony) no longer render too dark, with skewed colour, with lensfun profiles. |
| 2026-11-07 | correction | Compressed ORF sensor support withdrawn pending provenance review; embedded preview fallback remains. Coverage regenerated without the removed decoder: 557 verified, 665 unverified, 187 preview-only, 37 unsupported; 94% use-weighted coverage. |
| 2026-11-04 | minor | Compressed ORF support was introduced in #3775; subsequently withdrawn pending provenance review. Earlier clean-room and verification claims are withdrawn; compressed files use embedded previews when available. See [ORF status](orf-compression.md). |
| 2026-10-26 | patch | Bundled camera profile count 5 → 9 (Nikon Z 6II, Z 8 and D5300, ILCE-7RM5); counts only |