The common mixing of RGB colors is very different from mixing colors for paintings, it's mixing of light instead mixing of pigments.
For example:
Blue (0,0,255) + Yellow (255,255,0) = Grey (128,128,128)
(It should be Blue + Yellow = Green)
Is there any known algorithm for color mixing that works like mixing real colors?
I've already tried following:
Converting both colors to HSV and mixing hues (multiplied by coefficient computed from saturation), and simple average for saturation and value channels. Then I computed average luminance from both colors (using Rec. 709 luma coefficients) and adjusted the result color to match this luminance. This worked quite well, but the hue mixing was sometimes wrong, e. g.:
Red (Hue 0°) + Blue (Hue 240°) = Green (Hue 120°)
I've figured out that sometimes I need to shift the hue value by 360° (when the difference between hues is greater than 180°).
Red (Hue 360°) + Blue (Hue 240°) = Magenta/fuchsia (Hue 300°)
But this shifting wasn't very good too, e.g.:
Cyan (Hue 179°) + Red (Hue 0°) = Hue 89.5°
Cyan (Hue 181°) + Red (Hue 0°) --> shifting is performed (difference is greater than 180°)
Cyan (Hue 181°) + Red (Hue 360°) = Hue 270.5°
(Hue 179 + Red) and (Hue 181 + Red) results in two COMPLETELY different colors.
Then I tried CIE LAB color space (like in Photoshop), which is supposed to have realistic colors for human (or something like that). I used just simple average for each corresponding two channels, but the results weren't satisfying, for example I got pink (64, 26, -9.5) out of blue (98, -16, 93) and yellow (30, 68, -112). These coefficients were taken from Photoshop. Maybe if I used some different operation than average, it could work, but I don't know what.
CMYK didn't work too, results are just like in RGB or LAB.
There is piece of working software: http://commit-digest.org/issues/71 (Krita). They say it is the first public application that implements special technology using Kubelka and Munk equations that describe the behavior of pigments. It's two years old, but I couldn't find anything related in the current KOffice 2.0.81 source code.