General RGB color mixing is very different from painting color mixing, it is light blending instead of pigment blending.
For example:
Blue (0,0,255) + Yellow (255,255,0) = Grey (128,128,128)
(It should be blue + yellow = green)
Is there any known color mixing algorithm that works like mixing real colors?
My approach
I have already tried the following:
Converting both colors to HSV and mixing colors (multiplied by a coefficient calculated from saturation) and a simple average for saturation channels and values. Then I calculated the average brightness from both colors and adjusted the resulting color according to this brightness. This worked pretty well, but mixing shades was sometimes wrong, for example. g :.
Red (Hue 0°) + Blue (Hue 240°) = Green (Hue 120°)
I found out that sometimes I need to shift the hue value by 360 ° (when the difference between the hues is more than 180 °).
Red (Hue 360°) + Blue (Hue 240°) = Magenta/fuchsia (Hue 300°)
But this bias was not very good, for example:
Cyan (Hue 179°) + Red (Hue 0°) = Hue 89.5° Cyan (Hue 181°) + Red (Hue 0°) --> shifting is performed (the difference is greater than 180°) Cyan (Hue 181°) + Red (Hue 360°) = Hue 270.5°
(Hue 179 + Red) and (Hue 181 + Red) leads to two completely different colors.
Then I tried the CIE Lab color space (as in Photoshop), which is designed to be closer to how people perceive colors.
I used a simple average for each corresponding two channels, but the results did not satisfy, for example, I got pink (64, 26, -9.5) from blue (98, -16, 93) and yellow (30, 68, -112) . These coefficients were taken from Photoshop.
Perhaps if I used some other operation than the average, it could work, but I do not know what.
CMYK does not work either , the results are similar to RGB or LAB.
Neither trivial incremental nor subtractive color mixing in any of these color spaces seems to produce natural results.
Working implementations
Krita - Paint Mixer
Raster graphics editor At some point, Krita implemented a more realistic color rendering: http://commit-digest.org/issues/2007-08-12/ (plug-in for a smooth mixer)
They say that this is the first public application that implements a special technology using the Kubelka and Munk equations describing the behavior of pigments.
Here's a Krita color mixing video: https://www.youtube.com/watch?v=lyLPZDVdQiQ
FiftyThree Paper
There's also an article on color mixing in the Paper for iOS app developed by FiftyThree . They describe how they innovate and experiment in the area, and also offer patterns of mixing blue and yellow, which leads to green. However, the actual process or algorithm is not described here.
Citation:
“In search of a good blending algorithm, we first tried to interpolate different color spaces: RGB, HSV and HSL, then CieLAB and CieLUV. The results were disappointing,” Chen said. “We know that red and yellow must be orange or red and blue must be purple, but there is no way to achieve these colors no matter what color space you use. There’s a technical axiom: do the simplest thing that might work. Well, now we tried the simplest approaches, and they didn’t even feel remotely. "
It seems that just like Crete, Paper implements the Kubelka-Munk model:
[...] the Kubelka-Munk model had at least six values ​​for each color, including reflection and absorption values ​​for each of the RGB colors. “While the appearance of color on the screen can be described in three dimensions, color mixing occurs in fact in six-dimensional space,” explains Georg Peternigg, co-founder and CEO of FiftyThree. The Kubelka-Munk document allowed the team to translate the aesthetic problem into a mathematical foundation. [...]
From all this information, it seems that an implementation based on the Kubelka-Munk model can be a way to move forward and offer results that are much closer to reality.
Despite the fact that this looks like a complicated process, I have not yet seen much good information on how to implement something like this.
Related Questions
These questions were published after everything was connected with the same.
None of them have an answer.
- Mixed color calculation in RGB
- A color search algorithm between two others - in the color space of painted colors
- Introducing Kubelka-Munk as Krita to mix colors like paint
Other related links and resources