🎨 Color Constancy & Chromatic Adaptation

Von Kries chromatic adaptation: scale LMS cone signals by illuminant estimate. Retinex theory: surface color = ratio of scene reflectances. See dress illusion and simultaneous contrast.

PerceptionInteractive
Von Kries chromatic adaptation · Change illuminant to see adaptation effect · P pause · R reset

How it Works

This simulation demonstrates von Kries chromatic adaptation. A set of colored patches is illuminated by a colored light source. Without adaptation, the patches' colors are distorted by the illuminant. With von Kries adaptation, the visual system scales each cone channel (L, M, S) by the inverse of the estimated illuminant color, restoring perceived colors toward their true reflectances.

The Retinex mode shows how Land's algorithm computes color by comparing each patch to its neighbors, demonstrating that color is a property of reflectance ratios, not absolute intensities. The dress illusion mode shows how the same image colors can be perceived differently depending on the assumed illuminant.

von Kries: [L', M', S'] = [L/L₀, M/M₀, S/S₀]
Adapted RGB = T⁻¹ · diag(1/L₀, 1/M₀, 1/S₀) · T · RGB
Retinex: color(x) = R(x) · I → log(R) = log(I·R) − log(I_local)
Grey World: [L₀, M₀, S₀] = mean([L, M, S]) over scene

Frequently Asked Questions

What is color constancy?

Color constancy is the ability to perceive the color of objects as relatively stable despite changes in the color of the illuminating light. For example, a red apple appears red both in yellow indoor lighting and blue outdoor daylight, even though the wavelengths reaching the eye differ dramatically.

What is the von Kries chromatic adaptation transform?

The von Kries transform adapts the visual system to the color of the illuminant by scaling the LMS cone outputs independently: L' = L/L₀, M' = M/M₀, S' = S/S₀, where L₀, M₀, S₀ are the LMS responses to the estimated illuminant. This normalizes the scene as if viewed under equal-energy white light.

What is Retinex theory?

Land's Retinex theory proposes that color perception is determined by the ratios of light reflected from surfaces in the scene, not by the absolute amounts. The visual system computes lightness separately in different wavelength bands, comparing each point to its neighborhood, then combines them into a color percept.

What caused the 'The Dress' illusion?

The Dress illusion (2015) showed a dress that some people saw as blue/black and others as white/gold. It arose because people's visual systems made different assumptions about the illuminant color. Those assuming a warm illuminant subtracted it and saw blue/black; those assuming cool light saw white/gold.

What is simultaneous color contrast?

Simultaneous color contrast is the phenomenon where a color appears different depending on the surrounding colors. A gray square looks slightly pinkish surrounded by green, and slightly greenish surrounded by red. Lateral inhibition in the visual system enhances borders and differences between adjacent color regions.

What are the LMS cones?

L (Long), M (Medium), and S (Short) wavelength cones are the three types of color-sensitive photoreceptors in the human retina. L-cones peak around 560nm (red), M-cones around 530nm (green), S-cones around 420nm (blue). All color perception arises from comparing these three cone responses.

What is chromatic adaptation?

Chromatic adaptation is the visual system's adjustment to the color of the ambient illuminant. When you enter a room lit by warm yellow light, the visual system gradually reduces sensitivity to yellow wavelengths, making colors appear closer to how they look in neutral daylight. This happens over seconds to minutes.

How does the brain estimate the illuminant?

The brain uses several cues: the average color of the scene (grey world assumption), the brightest point (white world assumption), edge-based analysis, scene memory (knowing grass is green), and the spatial pattern of colors across the scene (gamut mapping).

What is the grey world assumption?

The grey world assumption is a computational color constancy algorithm that assumes the average reflectance of a scene is neutral grey. By computing the mean RGB values of the image and dividing each channel by this mean, we estimate the illuminant and correct for it, making the overall scene appear neutral.

Why does color constancy sometimes fail?

Color constancy fails when the visual system receives ambiguous or misleading illuminant cues. Strong colored shadows, uniform illuminants, unusual spectral compositions, very bright or saturated colors, or conflicting context can all cause the visual system to make incorrect illuminant assumptions, leading to color illusions.

About this simulation

This simulator renders nine reference color patches under a tinted illuminant, then blends in a von Kries correction that divides each channel by the illuminant's own color before rescaling — the same per-channel normalization your visual system performs to keep an apple looking red under both candlelight and daylight. Four modes let you compare raw illuminant distortion, simultaneous contrast, the famous Dress illusion, and Retinex-style neighbor comparison side by side.

🔬 What it shows

A patch grid under a controllable colored illuminant, with a slider-driven von Kries adaptation strength that morphs the raw, illuminant-tinted colors back toward their true reflectances — plus dedicated modes for contrast, the Dress illusion, and Retinex reasoning.

🎮 How to use

Set Illuminant Hue and Saturation to tint the light source, drag Adaptation Strength from 0 (raw distorted colors) to 1 (fully corrected), and switch Display Mode between Color Constancy, Simultaneous Contrast, Dress Illusion, and Retinex Patches. P pauses, R resets.

💡 Did you know?

The Dress photo became a global argument because it contains almost no explicit color cues about the light source, forcing different brains to silently guess different illuminants — some assumed warm indoor light and subtracted yellow to see blue/black, others assumed cool shade and saw white/gold.

Frequently asked questions

Why does dragging Adaptation Strength to 0 make everything look tinted?

At strength 0 the simulation shows the raw result of applyIlluminant() — each patch's RGB simply multiplied by the illuminant's RGB — with no von Kries correction applied at all, so the whole scene looks bathed in whatever color you set with the Illuminant Hue slider.

How does the von Kries correction actually undo the illuminant tint?

vonKries() divides each color channel by that same illuminant channel (r/illumR, g/illumG, b/illumB), which is mathematically the inverse operation of the tinting step — at strength 1 this fully cancels the illuminant's multiplicative effect, recovering colors close to the patches' true reflectances.

Why is there a separate Grey patch among the nine color patches?

A zero-saturation grey patch has no hue to distort, so its color under a tinted illuminant directly reveals the illuminant's own color — this is exactly the "grey world" cue the brain (and this simulation's math) uses to estimate what light is falling on the scene.

What does Simultaneous Contrast mode demonstrate that Color Constancy mode doesn't?

Color Constancy varies the illuminant across the whole scene at once; Simultaneous Contrast instead keeps lighting uniform but changes surrounding colors, showing that identical patches can look different purely from local context — a separate but related mechanism from illuminant estimation.

Why does the Dress Illusion mode produce two believable readings of the same image?

Because the image is deliberately built so that neither a warm-illuminant nor a cool-illuminant interpretation is clearly wrong — depending on which the visual system silently assumes, the von-Kries-style correction it applies internally shifts the perceived hue in opposite directions, splitting viewers into two camps.