Chapter 10 Color Management and White Balance
One-Sentence Goal
Establish an auditable color pipeline from the sensor linear domain to a target color space; perform scene/view–consistent white-point estimation, chromatic adaptation, CCM solving, and rendering; and control stability for ΔE, skin tones, and neutral gray via metrics and contracts.
I. Scope & Targets
- Inputs
- Raw imaging & metadata: RGB_raw (Bayer / multispectral), ts | tau_mono, ISO, exposure, T_cam, gain_map, lens & filter descriptors.
- Calibration & references: color-chart observations { patch_j }, reference illuminant or SPD E(λ), sensor spectral sensitivities S_c(λ), reference white W_ref.
- Target color space & transfer: dst_cs ∈ { sRGB, DisplayP3, Rec.2020, ACEScg, ProPhotoRGB }, TRC/OETF.
- Outputs
- White balance: wb = diag(g_R, g_G, g_B) or tile-wise wb(x,y); illuminant estimate illuminant = { CCT, Tint or W_src }.
- Color transforms: M_ccm, chromatic adaptation CAT(W_src→W_dst), and the rendering matrix
M_render = M_dst * CAT * M_ccm * wb. - Artifacts & manifest: profile.v1 (models + coefficients), manifest.imaging.color, hash_sha256(profile), signature.
- Applicability
- Perform white balance in the RAW linear domain before demosaicing; multi-modal/multi-resolution pipelines share a single white point but may use independent M_ccm.
- Dual / mixed illuminants may use zonal estimation or soft segmentation; publish the strategy and masks.
II. Terms & Variables
- Physics & perception
- E(λ): scene spectral power distribution; R(λ): surface reflectance; S_c(λ): sensor spectral sensitivity.
- W = (X_w, Y_w, Z_w): white point; XYZ, Lab are CIE spaces; u'v' chromaticity.
- Camera & matrices
- RGB_raw_lin: RAW after dark/PRNU/DSNU correction (linear).
- wb = diag(g_R,g_G,g_B): white-balance gain matrix.
- M_ccm ∈ R^{3×3}: camera-to-XYZ (scene-referred).
- CAT(W_s→W_d) = M^{-1} * diag( W_d / W_s ) * M (Bradford/Von Kries family).
- M_dst: XYZ → target RGB (linear) for dst_cs.
- TRC/OETF: target system tone/gamma mapping.
- Metrics
- ΔE_ab (CIE76), ΔE_00 (CIEDE2000); err_awb (white-point residual in u'v').
- gamut_viol: gamut overflow ratio; skin_angle: deviation of skin hue angle.
- Units & dimensions
unit(RGB_raw_lin)="a.u.", unit(XYZ)="a.u." (relative); unit(CCT)="K"; check_dim must pass.
III. Axioms P210- (Color & WB Baseline)*
- P210-1 (Linear-first): Execute white balance and CCM in the linear domain; never apply channel gains after non-linear TRC.
- P210-2 (Scene-referred default): Manage color as scene-referred by default; any mapping to display-referred must explicitly record the OETF and tone curve.
- P210-3 (White-point unity): A single W_src is shared by all channels and spatial transforms for a frame; with multiple illuminants, publish the regions and fusion weights.
- P210-4 (Invertible & traceable): Version all of M_ccm, CAT, M_dst, and TRC; linear segments must have a controlled condition number on Ω_valid.
- P210-5 (Noise-aware): White-point and CAT estimates should consider channel noise and SNR; use robust estimators in low-light/high-ISO regimes.
- P210-6 (Spectral incompleteness): Camera vs. target-observer mismatch is unavoidable; training/evaluation of M_ccm must span representative spectra.
- P210-7 (Temporal/thermal stability): Record gain/response drift vs. temperature/exposure in the manifest and compensate via color regression or interpolation.
IV. Minimal Equations S210-*
- S210-1 (Image formation)
y_c = k * ( ∫ E(λ) * R(λ) * S_c(λ) dλ ) + n_c,c ∈ {R,G,B}. - S210-2 (Linear white balance)
RGB_wb = wb * RGB_raw_lin = diag(g_R,g_G,g_B) * RGB_raw_lin. - S210-3 (Camera to XYZ, linear)
XYZ_s = M_ccm * RGB_wb. Solve M_ccm by least squares:
argmin_M ∑_j || XYZ_ref_j - M * RGB_wb_j ||_2^2. - S210-4 (Chromatic adaptation, CAT)
XYZ_d = CAT(W_src→W_dst) * XYZ_s, where
CAT = M_B^{-1} * diag( (M_B*W_dst) / (M_B*W_src) ) * M_B (Bradford). - S210-5 (Target color space, linear)
RGB_dst_lin = M_dst^{-1} * XYZ_d, then gamut_map(RGB_dst_lin) within Ω. - S210-6 (Transfer characteristics)
RGB_out = OETF( RGB_dst_lin ) (e.g., sRGB piecewise gamma, PQ, HLG). - S210-7 (AWB residual & color error)
err_awb = || u'v'(W_est) - u'v'(W_ref) ||_2 ;
ΔE_ab = sqrt( (L1-L2)^2 + (a1-a2)^2 + (b1-b2)^2 ). - S210-8 (Two-illuminant CCM interpolation)
M_ccm(T) = α(T) * M_A + ( 1 - α(T) ) * M_B, with α(T) ∈ [0,1] from CCT or D_uv interpolation. - S210-9 (Skin-tone hue angle)
skin_angle = atan2( a*, b* ) - theta_skin_ref, for skin-hue consistency monitoring.
V. Pipeline & Operational Flow M100-*
- M100-1 Readiness: Apply dark/flat and fixed-pattern corrections (Chapter 8) to get RGB_raw_lin; verify unit/dim.
- M100-2 White-point estimation: prioritized strategy:
- Highlight / gray-card detection (with geometric/radiometric checks),
- Gray-world / Gray-edge,
- Learning-based illuminant_net (for low-light / mixed light).
Output W_src, wb, and confidence.
- M100-3 Linear WB: RGB_wb = wb * RGB_raw_lin (RAW domain; map Bayer channels per CFA layout).
- M100-4 CCM selection / interpolation: Choose or interpolate M_ccm using CCT/D_uv, T_cam, ISO.
- M100-5 Chromatic adaptation: Compute CAT(W_src→W_dst) to obtain XYZ_d.
- M100-6 Target color-space mapping: RGB_dst_lin = M_dst^{-1} * XYZ_d; apply gamut_map (prefer compression, then clip).
- M100-7 Transfer & rendering: Apply OETF/TRC, optional local tone mapping; embed ICC/DNG tags and export profile.v1.
- M100-8 Quality assessment: On chart and skin ROIs, compute ΔE_00, err_awb, gamut_viol, skin_angle.
- M100-9 Contracts & fallback: On assertion failure, fall back to a conservative configuration or publish WB + XYZ only.
- M100-10 Persistence & signature: Emit manifest.imaging.color, recording matrices, white point, TRC, metrics, and signature.
VI. Contracts & Assertions
- assert wb_domain: WB is applied to linear RAW; ||log2(g_R) - log2(g_G)|| and ||log2(g_B) - log2(g_G)|| remain within thresholds to avoid gain saturation.
- assert awb_residual: err_awb ≤ tol_awb_uv; gray-card a*,b* magnitudes ≤ tol_gray_ab.
- assert color_error: mean(ΔE_00) ≤ tol_dE_mean and p95(ΔE_00) ≤ tol_dE_p95.
- assert gamut: gamut_viol ≤ tol_gamut_overflow, with recorded compression ratio.
- assert cond_render: cond(M_render_linear) ≤ tol_cond to avoid numerical instability.
- assert skin_tone: |skin_angle| ≤ tol_skin_angle; skin luminance within [L_min, L_max].
- assert profile_binding: the runtime profile profile.v1 hash matches the manifest.
VII. Implementation Bindings I100-*
- I100-1 estimate_illuminant(RGB_raw_lin, meta, strategy) -> W_src, wb, conf
- I100-2 apply_wb_raw(raw, wb, cfa) -> raw_wb
- I100-3 select_or_interpolate_ccm(CCT, T_cam, ISO, repo) -> M_ccm
- I100-4 chromatic_adapt(XYZ, W_src, W_dst, method) -> XYZ_d, CAT
- I100-5 rgb_xyz_transform(RGB, M) -> out (generic 3×3 linear transform)
- I100-6 gamut_map(RGB_lin, mode, params) -> RGB_lin' (compression → clip)
- I100-7 apply_oetf(RGB_lin, oetf_name) -> RGB_out
- I100-8 evaluate_color_metrics(image, patches, refs) -> { ΔE_00, err_awb, gamut_viol, skin_angle }
- I100-9 emit_color_profile(M_ccm, CAT, M_dst, wb, oetf, meta) -> profile.v1
- I100-10 bind_manifest_color(profile, metrics, hashes) -> manifest.imaging.color
VIII. Cross-References
- Fixed-pattern noise & flat-field: Chapter 8—perform DSNU/PRNU and color-shading corrections before WB.
- Optics & PSF: Chapter 5—lateral chromatic aberration and off-axis aberrations may induce fringes; coordinate with demosaic strategy.
- Sampling & reconstruction: Chapter 6—apply WB after sampling when using chroma-preserving kernels or directly in RAW.
- Noise & denoising: Chapter 7—channel SNR bounds the illuminant estimator and WB caps.
- Cleansing time axis: Methods.Cleaning v1.0, Chapter 5—multi-frame chart average and AE alignment require tau_mono.
- Data specification: EFT.WP.Core.DataSpec v1.0—bind profile.v1 and manifest.imaging.color fields.
IX. Quality Metrics & Risk Control
- Core indicators
- mean/p95(ΔE_00), err_awb(u'v'), gamut_viol, skin_angle, cond(M_render), artifact_rate.
- Runtime monitoring: within window Delta_t, track drift_g_R,B, drift_CCT, slope of ΔE_00, and alerts.
- Key risks & playbooks
- Mixed illuminants: partitioned AWB + feathered fusion; on failure, fall back to gray-world with low-confidence tagging.
- High gain / saturation: constrain WB caps and normalize via G channel; enable highlight protection if needed.
- Observer mismatch: switch to ACEScg working space and publish observer-difference notes.
- Config drift: maintain versioned mapping { CCT, T_cam } -> { wb, M_ccm } with regression/interpolation.
- Algorithm instability: if cond(M) exceeds threshold, switch to LUT-based rendering or lower-order matrices.
Summary
This chapter codifies the minimal closed loop for color management—RAW → wb → M_ccm → CAT → M_dst^{-1} → TRC—and enforces contracts via ΔE, white-point residuals, gamut overflow, and skin-hue angle. Artifacts are published as profile.v1 and manifest.imaging.color, ensuring consistent, auditable rendering across devices and scenes.