Comment

Comment by meindnoch

Mostly correct, but I don't understand what the author is trying to do in the last section, where they try to fill the locus by generating spectra with two peaks and projecting it into the chromaticity diagram. Why do it like that?

This is how you should do it:

- You pick a Y value. This is going to be the luminance of your diagram.

- For each pixel inside the area bounded by the spectral locus (and the line of purples - the line connecting the two endpoints of the locus) you take its x, y coordinates.

- Together these 3 values specify your color in the CIE xyY color space. Converting from xyY to XYZ is trivial: X = Y / y * x, Y = Y, Z = Y / y * (1 - x - y)

- You map these XYZ values into your output image's color space (e.g. sRGB). If a given XYZ value maps outside the [0,1] interval in sRGB, then it's outside the sRGB gamut, and you may clip the values to the closest valid value inside the gamut.

parent meindnoch 2 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton