Skip to content

© 2026 Rami Kronbi · Beirut, Lebanon

Back
Writing

Why color science comes before the model

To teach a network an edit, the training pairs must be linear, calibrated, and exact. Most of the work is in the decode.

I built Imagen for 3D reconstruction from 360° captures with phone and embedded cameras, where every frame has to come out with consistent, calibrated colour before any geometry is computed. Professional interior shoots are taken as sets: ambient brackets at −6, −3, 0, +3, and +6 EV, flash fills, and lights-on stacks, blended and graded by hand. The Imagen pipeline captures that before-and-after relationship at scale so an HDRNet bilateral-grid network can learn the edit.

Ingestion has to guess right

Sessions arrive as folders of RAW files and edited JPEGs with no labels. Ingestion groups brackets by timestamp, identifies the ambient sequence, flash fills, and lights-on stacks, and writes an index per scene so a run can resume after interruption.

The DNG pipeline, in full

Canon EOS R5 DNGs from recent converters use JPEG XL tiles that LibRaw cannot decode, so the pipeline falls back to tifffile and applies the DNG specification’s color pipeline itself: per-channel polynomial linearization from the opcode list, white balance and camera calibration, the forward matrix to XYZ D50, Bradford adaptation to D65, and finally linear sRGB. Lens distortion, chromatic aberration, and vignetting are corrected with lensfun profiles. The output is 16-bit linear PNG, scene-referred, with no gamma.

Targets must not be reinterpreted

The edited JPEG is the ground truth. It is linearized so its values are preserved exactly rather than re-graded by the pipeline. If the target drifts, the model learns the pipeline’s taste instead of the edit.

Layth Ayache contributed training and delivery runs. The lesson carries over to any reconstruction pipeline: get the decode right, keep the target exact, and the model has something honest to learn.