Skip to content

Kelvin white balance for raws whose camera has no colour matrices #730

Open

Description

@cajax

Problem

The white-balance scale is chosen by file extension, not by whether LightCraft knows the camera's colour:

  • UI / catalog: Photo::relative_wb() (crates/catalog/src/model.rs:314) puts every ARW, NEF, NRW, RW2, RWL, RAW, RAF, CR3, CR2, PEF, SRW and ORF on the relative −100…+100 scale.
  • Render: crates/engine/src/files.rs:370 sets relative_wb when the file has no colour matrices of its own, decided before the spectral lookup, so even raws that fall back to the spectral matrices keep relative WB (adapted generically in crates/pipeline/src/local.rs:35 instead of through the camera matrices).

So the 52 models with measured matrices in lightcraft_raw::spectral (e.g. ILCE-7M3, ILCE-7M4, ILCE-7RM3, D850, EOS 5D Mark III) never get a Kelvin readout, unlike Lightroom. For most of their files the matrices are not used at all: the JPEG fit (camera_preview::starting_colour) wins, and the matrices are only the fallback when it fails.

Proposal

When a camera has colour matrices (its own in the file, or a spectral table row), show As Shot and the Temp slider in Kelvin:

  • The colour look stays as it is (JPEG fit or bundled per-model profile). The matrices only convert white balance to and from Kelvin: as-shot multipliers → As Shot Kelvin/tint; slider Kelvin/tint → multipliers → the shift applied relative to the as-shot look.
  • Raws without matrices keep the relative scale.
  • The catalog decision (Photo::relative_wb) and the render decision (files.rs) must agree.

Must handle

Validation data (ILCE-7M3)

A series shot with WB set to Color Temp./Filter, filter 0 (plus 5500 K G2 / M2), with a grey card in frame, at 1/320 s f/8 ISO 100 under midday daylight with varying cloud. The files are private and kept locally, not in the corpus. As-shot multipliers through the ILCE-7M3 spectral matrices:

Dial Reads as Tint
2500 K 2274 K −2.1
3000 K 2707 K −4.0
3500 K 3157 K −4.7
4000 K 3611 K −4.7
4500 K 4060 K −4.0
5000 K 4524 K −2.8
5500 K 4986 K −2.4
6000 K 5443 K −1.0
6500 K 5898 K −0.2
7000 K 6356 K +0.7
7500 K 6841 K +2.1
8000 K 7323 K +3.5
8500 K 7835 K +4.9
9000 K 8371 K +6.3
9500 K 8907 K +7.6
9900 K 9338 K +8.9
5500 K G2 4830 K −36.4
5500 K M2 5017 K +22.0
  • Tint stays near the locus across the whole range (the generic model the docs describe read one Sony file as −127), and G2 / M2 move it in the right directions.
  • Kelvin reads 7–10 % below the dial, smoothly and monotonically.
  • The grey card's raw values read 4830–5045 K, tint about −4, in every frame regardless of the dial (CIE daylight would be about +9.5 tint in LightCraft's units). On Sony's own dial scale the same card reads about 5350–5550 K. Daylight can't tell which is right.

Open: whether the spectral matrices or Sony's dial labels are off. A grey card lit only by an incandescent bulb (blackbody, near Illuminant A where the spectral fit is exact by construction) should decide it. If the matrices read about 10 % low, the dial series doubles as the ILCE-7M3's measured correction curve.

Related: #296 (no Kelvin on an A7 IV ARW, reported together with a separate colour-rendering complaint).

Activity

  1. bitshiftza commented on Oct 10, 2026

    @bitshiftza
    Contributor

    Working on this.

  2. Nmarello commented on Oct 12, 2026

    @Nmarello

    A related symptom: when a Lightroom sidecar's Kelvin white balance can't be used, the import says nothing.

    A CR2 from a Canon EOS Rebel T5, with a sidecar carrying crs:WhiteBalance="Custom" crs:Temperature="4200" crs:Tint="+8", imports as As Shot (wb.temp 6500, tint 0). library.import reports "sidecars": 1 with no warnings, although docs/xmp-interop.md says partly transferable crs: settings produce per-photo warnings.

    Everything else in the same sidecar mapped exactly: Exposure2012, Contrast2012, Highlights2012, Shadows2012, Whites2012, Blacks2012, Clarity2012, Vibrance, Saturation and the crop. Until Kelvin works for these cameras, a warning such as "white balance 4200 K / +8 not applied (this camera uses the relative scale)" would tell users their Lightroom WB didn't come across.

  3. AlexChambers commented on Oct 13, 2026

    @AlexChambers
    Contributor

    Could you retest Kelvin white balance in LightCraft 0.7.1? PR #752, included through #981, gives calibrated cameras an absolute temperature scale. A public A7 IV sample imports at As Shot 4763 K and tint +13. Cameras without calibration can still use the relative scale. This doesn't establish exact agreement with the camera's Kelvin dial, and the Canon sidecar-warning follow-up remains unresolved.

  4. Nmarello commented on Oct 15, 2026

    @Nmarello

    Retested on 0.8.0 (the macOS CLI) with the same Canon EOS Rebel T5 CR2s.

    Kelvin readout: The T5 (EOS 1200D / Kiss X70) has no row or alias in the spectral table, so as expected it stays on the relative scale. After a decode, develop.get and photo.inspect show As Shot as 6500 / 0. For reference, macOS's raw engine (CIRAWFilter.neutralTemperature) reads these auto-WB shots at about 3400 K.

    Sidecar warning: This looks fixed. The same sidecar (crs:WhiteBalance="Custom" crs:Temperature="4200" crs:Tint="+8", with no AsShotTemperature) still imports as As Shot, but library.import now says so:

    "warnings": [{"code": "unmappedXmp", "fields": ["Temperature, Tint (custom white balance without AsShotTemperature: kept As Shot)"], …}]
    

    On 0.6.0 the same file returned "warnings": null. Everything else in the sidecar still maps exactly.

    With an as-shot reference: Adding crs:AsShotTemperature="3400" crs:AsShotTint="+8" to that sidecar gives Custom 10222 K / 0 on the relative scale. That's the expected −56 mired shift for 3400 → 4200 K. The render warms to match, and there are no warnings.

    From my side the silent drop is resolved; the T5 just doesn't get Kelvin yet. Thanks for following up.

  5. changed the title [-]Absolute Kelvin white balance for raws whose camera has colour matrices[/-] [+]Kelvin white balance for raws whose camera has no colour matrices[/+] on Oct 21, 2026
  6. aiongg commented on Oct 21, 2026

    @aiongg
    Contributor

    From #2028: Fujifilm RAF (body not named) shows only the −100…+100 scale.

  7. radialmonster commented on Oct 22, 2026

    @radialmonster
    Contributor

    The X-T20, X-T2, X-Pro2, X-E3, X-H1 and X100F now get an absolute As Shot Kelvin and tint instead of 0 / 0, in PR #2514. It uses the neutral multipliers for Illuminant A and D65 that the RAF itself stores, plus standard colorimetry, so no other camera's data is involved. It is about 7 mired and 3 tint rms off the matrix-based scale in the core range; an X-T20 sample reads 6193 K / +16.

    The greens and yellows (default colour) are not changed there. That needs a chart shot from an X-Trans III body: the raw plus the chart, under daylight.

    If this solves it, please close the issue, thanks! If not, feel free to reply with more.

  8. radialmonster commented on Oct 22, 2026

    @radialmonster
    Contributor

    PR #2527 (depends on #2514) puts every raw whose file stores neutral multipliers for known lights, and whose camera has no matrices, on the Kelvin scale. Files moved from the relative scale, with As Shot K drawn from the file's own presets:
    Panasonic RW2: 7981 files, medians mostly 4300 to 7300 K
    Sony ARW: 368 (plus Hasselblad Lunar 1)
    Canon CR2: 355, CR3: 111 (As Shot K over the camera's own ColorTempAsShot, median 1.00 and 0.98)
    Pentax and Ricoh PEF: 56 (K-5 3830, K-7 4829, K10D 5237, K-1 4200, K-3 III 5270)
    Leica RW2: 23
    Fujifilm RAF: 15
    Per-body counts with median/min/max are in the PR. Still relative, nothing usable in the files: Nikon NEF, Olympus ORF, Samsung SRW, Minolta MRW, Epson ERF, Sony DSC-R1.

  9. added a commit that references this issue on Oct 31, 2026
  10. radialmonster commented on Dec 4, 2026

    @radialmonster
    Contributor

    @Nmarello Thanks for the retest. The Rebel T5 (EOS 1200D) is covered by #2527, which is still open. It reads As Shot Kelvin from the presets the CR2 itself stores. On that branch, three T5/1200D samples read 4969 K / −7, 5352 K / +4 and 5981 K / +7 instead of 6500 / 0.

    If you'd like to follow it, #2527 is the place.

    If this solves it, please close the issue, thanks! If not, feel free to reply with more.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions