Kristjan Kannike

Värvide „lahkusegamine“

Scientific figures often employ semitransparency to show overlapping areas. But mixing transparent colours often produces unpleasant tones. Using the transparency formula, we can pick a pleasant mixed colour and background colour to produce the colour that will produce the mixed colour with the background.

The image below shows a light blue square partially overlapping a light red one, yielding an unpleasant reddish gray mixture, while at right we take the mixed colour to be the light blue. Due to that, the upper square at right is brighter.
Vasakul: kaks nurgast kattuvat läbipaistmatut eri värvi ruutu. Keskel: kaks nurgast kattuvat pool-läbipaistvat eri värvi ruutu.Paremal: ruutude värvid on tehtud tumedamaks, et läbipaistvust kompenseerida.

We cal also unblend the background colour:

Vasakul: kaks nurgast kattuvat läbipaistmatut eri värvi ruutu. Keskel: kaks nurgast kattuvat pool-läbipaistvat eri värvi ruutu.Paremal: ruutude värvid on tehtud tumedamaks, et läbipaistvust kompenseerida.

 

In the code, the colour is converted to RGB, unblended, and converted back to its original colour space (we assume that both colours are in the same colour space).