Visualizations
346 / 500

346 · Type and image

Through Other Eyes

A fruit market, a metro map and test plates as dichromats see them.

Each generated scene is decoded to linear sRGB and taken into LMS cone space. A dichromat lacks one cone type, so Brettel's method projects every color along that missing axis onto two half-planes through white, anchored on monochromatic lights computed from CIE color matching functions (Vienot's single-plane variant is one click away), and achromatopsia keeps only luminance. The chain collapses to two 3x3 matrices and a sign test per pixel, and a severity slider blends toward the projection. The plate generator runs the math backwards: dart-thrown dots are colored by shifting the ground's colors along a single cone axis, so each plate's big digit vanishes for exactly one kind of dichromat.

Try it. Drag the lens around (or anywhere on the scene). Pick a scene with the top chips or the left and right arrow keys, and a type of vision with the bottom chips or keys 1 to 5. Drag the severity slider (or use up and down), switch between the lens and a full view with L, toggle Brettel and Vienot with V, and press N or Space for new plates.

  • LMS cone space
  • Brettel dichromat projection
  • Per-pixel ImageData
  • Circle packing

View the source · one module, plus a small shared runtime for sizing, the animation loop and input

Build your own

Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.

Build a color vision deficiency simulator with JavaScript and the HTML canvas element: a colorful scene with a draggable lens that shows how people with protanopia, deuteranopia or tritanopia see it. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.

Start simple:
- Make a canvas that fills the window and draw a colorful scene into an offscreen canvas: a grid of fruit crates (red apples, green apples, oranges, limes, strawberries, blueberries) made of shaded circles.
- Read its pixels with getImageData. For each pixel, decode sRGB to linear light, convert to LMS cone space (sRGB to XYZ, then the Hunt-Pointer-Estevez matrix, normalized so white has equal L, M and S), and simulate a dichromat with the Vienot method: replace the missing cone's response with a combination of the other two chosen so that white and the sRGB blue primary are unchanged. Convert back and gamma encode into a second canvas.
- Precompute the whole chain as one 3x3 matrix in linear RGB for each deficiency, and use lookup tables for the sRGB curves so it runs fast.
- Draw the original scene, then the simulated one clipped to a circle that follows the pointer.

Once that works, make it beautiful:
- Add buttons for typical vision, protanopia, deuteranopia, tritanopia and achromatopsia, and a severity slider that blends between the original and the simulation in linear light.
- Give the lens a dark rim, a glassy highlight and a label.
- Add a second scene, such as a metro map with eight colored lines.

Explain the color science in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as Brettel's two half-plane method (better for tritanopia), Ishihara-style plates whose numbers vanish for one kind of dichromat, or comparing a rainbow colormap with viridis.
PreviousSorting NetworkA sorting network as a wooden marble run: brass gates swap marbles into order. NextSolar SurfaceGranulation, sunspots and flaring magnetic loops at the Sun's limb, in three wavelengths.

Related visualizations

  • AfterimageIllusions Stare at a surreal landscape, then see full color in a picture that is pure gray.
  • Foveated VisionIllusions What one eye really captures: a sharp fovea, a blurry gray periphery and a blind spot.
  • Chromaticity LabMath Draw any light's spectrum and watch it land on the CIE 1931 horseshoe.
  • Dandelin Spheres3D Two spheres wedged in a sliced cone prove the focus property, with no algebra.
  • Dither LabRetro Seven dithering algorithms race on a moving scene in 1-bit, handheld green, CGA and EGA.
  • Bokeh CameraType and image A night street shot through a simulated lens, with polygonal bokeh and cat's eyes.
  • Hidden 3DIllusions A live magic eye picture: a turning 3D sculpture hidden in colorful noise.
  • Aperture DiffractionPhysics Draw any aperture and see its diffraction pattern in true spectral color.
  • Hidden in PixelsType and image A treasure map hides in a landscape's lowest bits. Peel the bit planes to find it.

Use ← and → to move between demos. While the canvas has focus, keys go to the demo instead.

← More from Emergent Mind Labs