Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implementing Kubelka-Munk like Krita to mix colours (color) like paint

Tags:

colors

Is anyone aware of where to find or implement the Kubelka-Munk function to mix colour like natural paint? Emanuelle Tamponi implemented this function in Krita, an open source project, but I can't find anywhere that this, or a similar method, is shared to 'naturally' mix colours. It may be that it's commercially sensitive or private, but if you don't ask you won't find out!

like image 360
glenstorey Avatar asked Apr 20 '12 21:04

glenstorey


People also ask

What is the color mixing rule?

The cardinal rule of color mixing in painting and drawing media is, “Don't mix too much.” Even if you're using the right colors, overmixing can dull a mixture. A good mixture shows the original colors used and the mixture itself–for example, yellow and blue, as well as green.

How do you mix RGB colors?

To start mixing in RGB, think of each channel as a bucket of red, green, or blue paint. With 8 bits per channel, you have 256 levels of granularity for how much of that color you want to mix in; 255 is the whole bucket, 192 = three quarters, 128 = half bucket, 64 = quarter bucket, and so on.

How do you mix colors?

Mixing primary colors creates secondary colors If you combine two primary colors with each other, you get a so-called secondary color. If you mix red and blue, you get violet, yellow and red become orange, blue and yellow become green. If you mix all the primary colors together, you get black.


3 Answers

Feel free to re-use the code we have in krita. It's in calligra/krita/plugins/extensions/painterlyframework. It does need the pigment library as a back-up, but I guess you can easily abstract away from that.

Note however that the code is under the GPLv2+ license. If you reuse the code or the illuminants files your code also need to be GPL.

(for more info, please contact me -- [email protected] or boud on #krita on irc.freenode.net, I'm the maintainer for Krita).

like image 137
Boudewijn Rempt Avatar answered Jan 04 '23 10:01

Boudewijn Rempt


Here's an implementation I created that uses a simplified Kubelka-Munk model. It assumes assumes all colors have the same concentration when blending and that all colors are opaque. If it is useful feel free to use it in whatever manner you wish.

https://github.com/benjholla/ColorMixer

like image 36
Ben Holland Avatar answered Jan 04 '23 12:01

Ben Holland


There is not enough information provided by RGB values alone to perform a true Kubelka-Munk computation, as you need both absorbance and scattering curves across the visible spectrum. Instead, you could generate representative reflectance curves from RGB values, and then use the reflectance information to perform the subtractive mixture, for example, by computing the weighted geometric mean of the two reflectance curves.

like image 34
Scott Burns Avatar answered Jan 04 '23 10:01

Scott Burns