Skip to content

LR-EDIT-OPTICS-PROFILE: enable Sony ILCE-7M3 (A7 III) embedded distortion correction - #1384

Closed
alvarohn wants to merge 7 commits into
storytold:mainfrom
alvarohn:claude/keen-heisenberg-szgpjb
Closed

alvarohn wants to merge 7 commits into
storytold:mainfrom
alvarohn:claude/keen-heisenberg-szgpjb

Conversation

@alvarohn

Copy link
Copy Markdown

Summary

The A7 III's raw-IFD 0x7037 distortion tables have been read since #498 but refused by the model check, because
their corner warp was unverified in review. This validates them against the camera's own JPEG of the same exposure
and enables the body. One line in arw_lens.rs changes; everything else is tests, docs and the measurement tool.

Validation

27 RAW+JPEG pairs from one ILCE-7M3 (Lens Comp. ▸ Distortion Comp.: Auto, so the JPEG is the camera's corrected
render): a checkerboard filling the frame on a TV (handheld) and a desktop monitor (tripod), compressed and
uncompressed raws, wide open to f/8, plus one textured wall. Lenses: FE 16–35mm F4 ZA OSS (16, 20, 35 mm),
FE 28–70mm F3.5–5.6 OSS (28, 33, 50, 70 mm), FE 50mm F1.8. Tables range from strong barrel (16 mm, −690 at the
corner) to strong pincushion (70 mm, +1161).

LightCraft renders each ARW with the profile correction on and off; sub-pixel board corners are matched with the
JPEG's and a similarity (zoom, rotation, shift) is fitted, since the camera fills its frame with its own zoom. No lens
coefficient is fitted.

Lens / focal length Shots Corrected vs JPEG, median / p95 (px at 6000) Uncorrected median Camera / LightCraft correction
FE 16–35 F4 ZA / 16 mm 10 0.33–0.38 / 1.01–1.15 16.7–17.0 1.02
FE 16–35 F4 ZA / 20 mm 4 0.16–0.24 / 0.34–0.50 3.9–4.4 0.98
FE 16–35 F4 ZA / 35 mm 2 0.18–0.21 / 0.39–0.44 11.0–11.1 1.01–1.02
FE 28–70 / 28 mm 2 0.24–0.25 / 0.59–0.64 13.2–13.4 1.02
FE 28–70 / 33 mm 1 0.07 / 0.16 0.8 1.00
FE 28–70 / 50 mm 1 0.30 / 0.69 20.8 1.01
FE 28–70 / 70 mm 1 0.44 / 0.93 26.4 1.01
FE 50 F1.8 / 50 mm 4 0.06–0.12 / 0.15–0.31 2.8–3.0 1.00–1.01
Wall, 16 mm (SIFT) 1 0.37 / 1.06 5.6 —
  • At the 2376 px exports used for the ILCE-7RM4A (0.10–0.36 px medians there), the A7 III board medians are
    0.02–0.17 px and the p95 at most 0.46 px.
  • LightCraft applies the camera's amount of correction within 2 % (last column: JPEG ≈ uncorrected +
    α·(corrected − uncorrected), radially). What remains is about 1.5 px at the 16 mm corners, of a 35 px correction.
  • Corrected rows and columns are as straight as the JPEG's in every shot; uncorrected ones bow 7–55 px.
  • Compressed vs uncompressed, TV vs monitor and wide open vs f/8 agree.
  • On this body Sony's crop tags and the default crop agree (12, 12, 6000×4000 of 6048×4024), so the warp is centred
    on the image; fitted against the camera, the centre is within 0.3 px.

Full method and per-shot notes: docs/sony-lens-corrections.md → ILCE-7M3 validation. The photographs are not
committed.

Changes

  • crates/raw/src/vendor/arw_lens.rs: the model check accepts ILCE-7M3 (still exact; ILCE-7M3 and
    ILCE-7SM3 stay refused). New test ilce_7m3_matches_the_cameras_own_jpeg_geometry: the warp from three of these
    tables (16, 35, 70 mm) stays within 0.0008 of the half diagonal of the camera's fitted geometry, and the
    uncorrected frame is at least 10× further off. The DNG round-trip test now expects a warp for ILCE-7M3.
  • crates/raw/tests/corpus.rs: the two ILCE-7M3 corpus samples now expect one warp. Not run here: raw.pixls.us
    isn't reachable from my environment, so this corpus test skipped. The doc lists both samples with 16-sample tables
    and 3:2 framing, so one warp each is expected, but please run cargo xtask corpus --download first.
  • crates/engine/src/media.rs: RENDER_CACHE_VERSION 61 → 62.
  • tools/sony_distortion_check.py (+ tools/requirements-sony-distortion-check.txt): the measurement tool, so
    another body can be validated the same way. It was checked on synthetic boards with known radial distortion
    (corrected: 0.04 px; 80 % corrected: ratio 1.26 vs 1.25–1.28 expected).
  • Docs: sony-lens-corrections.md (validation section, coverage table), parity checklist row
    LR-EDIT-OPTICS-PROFILE, gaps.md, raw-parity.md, whats-new.md.
  • contributors/people.toml: my own entry (Álvaro HN), committed as me.

The branch also adds and then reverts a fork-only workflow (.github/workflows/fork-windows-x64.yml) that built
an unsigned Windows installer in my fork; it is not in the diff.

cargo xtask ci is green (fmt, clippy, heif, test, parity, layers, assets, wasm).

🤖 Generated with Claude Code

claude and others added 6 commits October 12, 2026 05:40
…era JPEGs

Renders each ARW with the embedded correction on and off and compares it with the camera's
own JPEG: residual offsets by radius after a similarity fit, checkerboard line straightness,
and the ratio of the camera's correction to LightCraft's. Checked on synthetic boards with
known radial distortion (corrected: 0.04 px median, ratio 1.000; 80 % corrected: ratio 1.26,
expected about 1.25-1.28). Needs numpy, scipy and opencv-python-headless.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015gRtdWF1E9358FfzhzYqCS
…ection

The A7 III's raw-IFD 0x7037 tables were refused until their geometry was checked. Measured against
the camera's own JPEG of the same exposure (Lens Comp. Distortion: Auto) on 27 RAW+JPEG pairs from
one body with the FE 16-35 F4 ZA, FE 28-70 and FE 50 F1.8 (strong barrel to strong pincushion,
compressed and uncompressed, TV and monitor checkerboards): corrected board corners sit 0.06-0.44 px
(median, 6000 px frame) from the JPEG's, against 0.8-26 px uncorrected; LightCraft applies the
camera's amount of correction within 2 %; corrected rows and columns are as straight as the JPEG's.
Sony's crop and the default crop agree on this body, so the warp is centred on the image.

A unit test pins the warp from three of these tables to the camera's fitted geometry; the model
boundary tests now accept ILCE-7M3 and still refuse its neighbours. RENDER_CACHE_VERSION is bumped.
The measurement script handles screen moiré (X-corner check, duplicate corners, consensus lattice
vectors). The corpus test's two ILCE-7M3 samples now expect one warp; raw.pixls.us is not reachable
from this environment, so that test was skipped here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015gRtdWF1E9358FfzhzYqCS
Not for upstream. Same steps as release.yml's Windows job, unsigned, published as a pre-release
of alvarohn/lightcraft.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015gRtdWF1E9358FfzhzYqCS
…on tools

Moves it to tools/ with a pinned requirements file, as tools/spectral_camera_table.py does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015gRtdWF1E9358FfzhzYqCS
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015gRtdWF1E9358FfzhzYqCS
Reverts ed68b2e; the installer it built stays in alvarohn/lightcraft's releases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015gRtdWF1E9358FfzhzYqCS
Conflict in docs/whats-new.md (both added entries at the top). Main also bumped RENDER_CACHE_VERSION to 62 for its
own pipeline change, the number this branch had taken: now 63, so thumbnails rendered by main's 62 without the
ILCE-7M3 warp are rebuilt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015gRtdWF1E9358FfzhzYqCS
deunderscorepaul pushed a commit to deunderscorepaul/lightcraft-classic that referenced this pull request Oct 17, 2026
…d distortion correction

Applied by hand on top of the fork's newer Sony lens-correction decoder (DISTORTION_MODELS); the PR's Python check tool is left out.

Thanks @alvarohn

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
elrumo pushed a commit to elrumo/lightcraft that referenced this pull request Oct 19, 2026
# Conflicts:
#	docs/whats-new.md
elrumo pushed a commit to elrumo/lightcraft that referenced this pull request Oct 19, 2026
@janickm

janickm commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Thanks @alvarohn for the validation work. This branch conflicts with current main (the Sony decoder was rewritten in #1176 and gained the A7CR path in #1901), so I rebased it as #3144: your commits and authorship are kept, the change is ported to the new DISTORTION_MODELS list, and the two "Fork only" Windows-installer commits are dropped. cargo xtask ci --quick passes, and the public A7 III corpus samples plus my own A7 III raws now get the warp. Happy to close #3144 if you'd rather rebase this one instead.

FredApps added a commit that referenced this pull request Nov 4, 2026
LR-EDIT-OPTICS-PROFILE: enable Sony ILCE-7M3 embedded distortion correction (rebase of #1384)
@FredApps

FredApps commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Closing as superseded: #3144 rebased this change onto current main and was merged as ac55490. Thank you @alvarohn for the original work on the ILCE-7M3 embedded distortion correction, it's in main now via #3144.

@FredApps FredApps closed this Nov 4, 2026
emmertex pushed a commit to emmertex/chromaforge that referenced this pull request Nov 7, 2026
…ch up

The isolation guard reads 4 pixels around a candidate, one more than detection's 3-pixel margin, so on a raw whose
active area starts at the frame's edge (Sony A7C II lossless L) a neighbour position wrapped and the sample index
overflowed. Neighbours now go through a checked step that skips anything outside the active area, and sample
indexes are checked.

The A7 III's lens-record test allows its applied distortion, enabled by the port of storytold/lightcraft#1384.
The DRO test's 5 % points compare with the fit before smoothing, which they were measured against.

Sources: own design.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

4 participants