Repository navigation
Open
Description
Dehaze is far too strong and isn't usable at normal values: even +20–30 darkens the whole photo, crushes shadows to black and draws dark halos around bright areas. The cause is how haze is estimated, not just the slider gain.
Where
crates/pipeline/src/finish.rs(the// --- dehaze (scene linear)block)crates/pipeline/src/local.rs: the haze plane isgaussian(dark_of(..))with sigma = 2 % of the long edge; airlight = 99.5th percentile of that plane.
This code hasn't changed since M0.4 and was tuned by eye.
Why it's too strong
- Ordinary tones count as haze. The dark-channel prior relies on a minimum over a patch, which is about 0 in haze-free areas. We use a Gaussian blur of the per-pixel
min(r,g,b). For neutral or muted pixels that's roughly the pixel's own brightness, sot = 1 − 0.95·s·dsubtracts the brightness itself. At +100 every tone below the airlight is scaled by about 0.05 (−4.3 EV). - Halos. The wide blur carries bright sky into the foreground's haze estimate, so
v − A·(1 − t)goes negative and the.max(0)clips it. A shadow pixel (0.05) beside bright sky (blurred d = 0.7, A = 0.8) clips to pure black at +10. - No gentle range. +100 maps to the prior's maximum (ω = 0.95, t floor 0.12) and the slider scales linearly. Negative dehaze blends up to 70 % toward 0.9·A, which washes the photo out.
Numbers
Simulated: brightness change of a neutral tone sitting in a neighbourhood of the same tone (A = 0.8):
| tone | +10 | +25 | +50 | +75 | +100 |
|---|---|---|---|---|---|
| 0.05 | −0.14 EV | −0.37 | −0.89 | −1.73 | −4.23 |
| 0.18 | −0.11 | −0.31 | −0.77 | −1.55 | −3.97 |
| 0.40 | −0.07 | −0.21 | −0.54 | −1.16 | −3.39 |
Measured: lightcraft-cli render docs/images/grid-pd.jpg --size 900 --set effects.dehaze=N (8-bit luma):
| dehaze | mean | median | p90 | pixels < 4 |
|---|---|---|---|---|
| 0 | 40.9 | 36 | 85 | 6.3 % |
| +25 | 33.6 | 26 | 77 | 14.4 % |
| +50 | 26.7 | 11 | 67 | 26.8 % |
| +100 | 15.0 | 0 | 31 | 73.8 % |
docs/images/ba-tetons.jpg at +30 visibly crushes the mid-greys to black, with dark halos around bright edges.
Proposed fix
- Estimate haze from a min-filter (patch) dark channel normalised by the airlight per channel, refined with the guided filter, instead of a Gaussian average.
- Keep haze-free shadows at t ≈ 1, so dehaze stops darkening them.
- Ease the slider response in so low values stay subtle, and hold midtone exposure steady.
- Re-check negative dehaze.
- This changes how existing edits render, so ship it as a new process version (
docs/process-versions.md) and keep V1 as it is. Measure against Lightroom exports with the single-slider tool from LR-BEHAV-RENDER-FIDELITY: tools/render_fidelity.py measures single-slider responses against your own Lightroom exports #1181 where possible.
Related: #1146 (accuracy in zoom windows), LR-BEHAV-RENDER-FIDELITY, LR-EDIT-EFFECTS-DEHAZE (✅ in the checklist; should be 🟡 until fixed).
Metadata
Metadata
Assignees
Labels
No labels
Activity
mattsivak commentedon Oct 12, 2026
I am working on this: a reworked dehaze (patch dark channel + guided refinement, gentler slider response, exposure held steady) shipped as a new process version so existing edits keep rendering as before. A PR will link back here.
mattsivak commentedon Oct 12, 2026
Research summary and fix plan
Why the current Dehaze is too strong
The current code (
crates/pipeline/src/finish.rs:448-461,local.rs, GPU mirror infinish.wgsl) follows the same physical haze model as everyone else:I = J·t + A(1−t). Four places differ from the reference method (He et al., dark channel prior) in ways that make it far too harsh:min(r,g,b), σ = 2 % of the long edgemin_c(I_c/A_c)ω = 0.95·amount,t ≥ 0.12, no exposure compensationMeasured on a test JPEG at +0 / +25 / +50 / +100:
How other apps behave (public docs and reviews only)
Users expect:
Plan: a new process version (V3)
V1 and V2 edits keep rendering the same pixels; new edits get V3.
Haze map, built once per image from a fixed 1024 px proxy of the whole frame, so preview, export and zoomed renders match:
g = min_c(e_c/A'_c), then a patch min filter (r ≈ 1.2 % of the long edge, O(1) van Herk/Gil-Werman).g(r ≈ 3.5 %, ε = 1e-3). Cache only itsa/bcoefficients.lin_keydoesn't).Per pixel (CPU
finish.rsand GPUfinish.wgsl):d̃ = a·g + b, witha/bsampled bilinearly from the proxy.t = max(1 − 0.95·k^1.5·d̃, lerp(1, 0.25, k)), so it eases in gently and amplifies no more than ×4;d̃is high.Two side benefits: zoomed renders no longer need a wider margin, and the GPU's mid-render airlight readback goes away for V3.
Acceptance targets
Also required:
Steps (one commit each,
cargo xtask cigreen)LR-EDIT-EFFECTS-DEHAZEto 🟡, fix the README claim, updatedocs/gaps.md.Process::V3asLATEST, plus process-version docs and tests.rastermin filter andpipeline/src/haze.rs, wired intoPlan.tests_dehaze.rs(acceptance bands, halo, flat grey, NaN, V1 unchanged, window vs whole, masks).equivalence.rs.cargo xtask bench.Out of scope for now:
Open question: the "+50 darkness" band is an estimate. Before final tuning, we'll check it against Lightroom on a photo we own, by observation only.
LR-EDIT-EFFECTS-DEHAZE: process V3 dehaze (patch dark channel, eased …
mattsivak commentedon Oct 12, 2026
Update: @emmertex's #1283 fixes this too, and it was up first. It's the smaller change, so that's the one to land. I've reviewed it with before/after renders on four photos and a passing GPU test run on Metal: #1283 (review)
My draft #1286 is on hold. Once #1283 is merged, I'll trim it down to a small follow-up on top of it:
dehaze_report) and the GPU tests.LR-EDIT-EFFECTS-DEHAZE: raise the V3 transmission floor to 0.3 so +10…
David990 commentedon Oct 14, 2026
Version 0.8: Texture, Clarity and Dehaze behave like a 1990s sharpen filter just using a different radii. Lightroom's Texture, Clarity and Dehaze operate differently and produce very different results. The current LightCraft implementation butchers the photos.
LR-EDIT-EFFECTS-DEHAZE: process V3 dehaze (patch dark channel, eased …
unemployedCHAD commentedon Oct 25, 2026
not sure if this is the same thing, but dehaze feels off for me too, kinda like @David990 said. pushing it up mostly just adds contrast, and pulling it down doesn't give that foggy look like in lightroom. on 0.14.0. thanks for working on this!
vvzvlad commentedon Nov 16, 2026
Negative Dehaze washes photos out compared with Lightroom. I measured this on 0.21.1 with a photo imported from a Lightroom Classic catalog: a Canon JPEG, process 15.4, with Contrast −36, Highlights −64, Shadows +51, Whites +32, Blacks −40, Dehaze −27, Clarity +16 and a custom point curve. I compared Lightroom's own export with LightCraft's
app.export, both sRGB at 1440 px, using the 2nd-percentile L* (CIELAB) as the black point:Nearly all of the difference comes from Dehaze −27. Blacks −40 hardly matters under it: setting Blacks to 0 moves the black point by only 0.8. In my catalog, 477 of 11,260 photos have a negative Dehaze.
HB-439: positive Dehaze refitted to Lightroom's +16 / +50 / +100 on s…