Perceptual vs Relative Colorimetric Math in GIMP

When converting image color spaces using ICC profiles in GIMP, rendering intents determine the mathematical algorithm used to translate color coordinates between source and destination gamuts via a Profile Connection Space (typically CIEXYZ or CIELAB). The fundamental mathematical difference lies in how out-of-gamut values and white points are handled: Relative Colorimetric uses a deterministic linear chromatic adaptation and hard boundary clipping to preserve in-gamut chromaticity, whereas Perceptual intent applies non-linear multidimensional compression across the entire color volume to preserve relative proportional distances between colors.

The Profile Connection Space and Chromatic Adaptation

Color management in GIMP relies on LittleCMS to calculate conversions between a source ICC profile and a destination ICC profile through an intermediate Profile Connection Space (PCS).

In Relative Colorimetric conversion, the source white point is mapped to the destination white point through a linear chromatic adaptation transform (CAT), most commonly the Bradford transform:

\[\mathbf{X}_{\text{adapted}} = \mathbf{M}_{\text{CAT}}^{-1} \cdot \mathbf{S} \cdot \mathbf{M}_{\text{CAT}} \cdot \mathbf{X}_{\text{source}}\]

Where \(\mathbf{M}_{\text{CAT}}\) transforms CIEXYZ values into a cone response space (RGB-like sensors), and \(\mathbf{S}\) is a diagonal scaling matrix representing the ratio of destination to source white points:

\[\mathbf{S} = \begin{bmatrix} \frac{\rho_{\text{dest\_white}}}{\rho_{\text{src\_white}}} & 0 & 0 \\ 0 & \frac{\gamma_{\text{dest\_white}}}{\gamma_{\text{src\_white}}} & 0 \\ 0 & 0 & \frac{\beta_{\text{dest\_white}}}{\beta_{\text{src\_white}}} \end{bmatrix}\]

Once the white points align, in-gamut color coordinates remain an identity function:

\[f(C) = C \quad \forall C \in \text{Gamut}_{\text{destination}}\]

Out-of-Gamut Handling: Clipping vs. Non-Linear Mapping

The mathematical divergence between the two rendering intents occurs predominantly at and beyond the destination gamut boundaries.

Relative Colorimetric: Hard Boundary Projection

For any color vector \(C\) that falls outside the boundary surface \(\partial G_{\text{dest}}\) of the target gamut, Relative Colorimetric computes an orthogonal or minimum \(\Delta E\) projection to the nearest surface point:

\[C_{\text{mapped}} = \arg\min_{C' \in \partial G_{\text{dest}}} \Delta E(C, C')\]

Because any point outside the target gamut volume is projected onto the outer shell:

  • Two distinct out-of-gamut vectors \(C_1 \neq C_2\) may resolve to the exact same destination coordinate: \(f(C_1) = f(C_2)\).
  • This results in gradient clipping (loss of tonal differentiation in highly saturated regions) while guaranteeing mathematical accuracy for all in-gamut points.

Perceptual: Non-Linear Gamut Compression

Perceptual rendering does not preserve the identity function for in-gamut colors. Instead, it re-scales the entire source gamut volume to fit inside the destination gamut volume using continuous, monotonic compression functions (often sigmoid or spline-based curves).

Mathematically, given a distance \(r\) from the neutral axis (chroma/saturation) and lightness \(L\):

\[r_{\text{dest}} = g(r_{\text{source}}, L)\]

Where \(g(r)\) is a non-linear mapping designed such that:

  1. Monotonicity: If \(r_1 < r_2\), then \(g(r_1) < g(r_2)\) (ensuring gradients do not clip or invert).
  2. Boundary condition: \(\max(g(r)) \le r_{\text{boundary}}(L)\).
  3. Internal shift: For coordinates deep inside the gamut (\(r \to 0\)), \(g(r) \approx r\), but as \(r\) increases, in-gamut colors are progressively compressed inward to clear space for out-of-gamut colors.

Algorithmic Calculation vs. LUT Encoding

A critical mathematical difference in how GIMP and LittleCMS execute these two intents involves procedural computation versus Look-Up Table (LUT) interpolation:

  • Relative Colorimetric calculations are largely procedural and algorithmic. The engine evaluates color space matrices or profile curve data directly, computing the linear transform and gamut boundary intersections in real time.
  • Perceptual mappings are typically pre-computed by the profile creator and baked into multi-dimensional Look-Up Tables inside the ICC profile (specifically within the A2B0 and B2A0 profile tags). During conversion in GIMP, the color engine performs trilinear or tetrahedral interpolation over these pre-computed grid points:

\[C_{\text{dest}} = \sum_{i} w_i \cdot \text{LUT}(P_i)\]

Where \(P_i\) are the enclosing vertices in the PCS grid and \(w_i\) are spatial interpolation weights. Consequently, while Relative Colorimetric produces mathematically uniform results across different profiles targeting the same gamut, Perceptual results vary based on the specific aesthetic compression curves chosen by the ICC profile's creator.