Add / mix colors in HSV space

I am trying to get visualization for a few days. I am creating a diffraction image and want to color it according to the wavelength of light.
The easiest way to get the right color is to use the HSV space with H varying with the wavelength and S, V set to 1.0 | Alas, I cannot find a formula / algorithm / way of mixing different colors in the HSV space.

Is there a formula for mixing in HSV, or perhaps another clear way?

+6
source share
2 answers

Honestly, I would convert RGB, average the components and convert back to HSV.

This is not the most efficient way, but you probably have or need RGB ↔ HSV code, and RGB calculation is likely to be much simpler.

+6
source

One of the standard references Computer graphics: principles and practice from Foley et al. this can be said in section 13.3.7 "Interpolation in the color space":

β€œWhen two images are mixed [...], the colors can be quite distant, and an added model such as RGB is suitable. If, on the other hand, the goal is to interpolate between the two colors fixed (or saturation) and maintain a fixed hue ( or saturation) for all interpolated colors, preferably HSV or HLS. But note that fixed saturation interpolation in HSV or HSL is not considered as fixed saturation by the viewer [...] "

Therefore, they agree with the @andrewmu proposal, which seems to be the best offer in general.

+5
source

Source: https://habr.com/ru/post/897111/


All Articles