15 September 2008

compiz-fusion color filter for hue inversion

The negative plug-in for compiz fusion can be used to reduce eye straining while reading from screen: it switches black-text-on-white-background to white-text-on-black-background. But such inversion involves also color channels: red appears cyan, green appears magenta, blue appears yellow and so on. Therefore if you want that in your application, for example, your green buttons (which mean "good", "on", "ok"...) will remain green, and for example your red buttons (which mean "alert", "off", "cancel"...) will remain red, you have to resort to an additional hue switching transformation.
The Color Filter plug-in could be used for such a color transformation, but the already available filters do not include such option. Moreover, I couldn't find a similar trasformation through google, so I write it for you. You can find it just below here, it is merely a dozen of lines of OpenGL fragment program: simply copy those lines in a file (to be placed, for example, among the other filters in /usr/share/compiz/filters/) and then select as filter files both the negative filter and my filter (the order is irrelevant).
Enjoy! :)

!!ARBfp1.0
TEMP output, tmp, YPbPr;
TEX output, fragment.texcoord[0], texture[0], RECT;

MOV tmp, output;

DP3 YPbPr.x, tmp, {0.333, 0.333, 0.333, 1};
SUB YPbPr.y, YPbPr.x, tmp.b;
SUB YPbPr.z, YPbPr.x, tmp.r;

ADD tmp.r, YPbPr.x, YPbPr.z; 
ADD tmp.b, YPbPr.x, YPbPr.y;
SUB tmp.g, YPbPr.x, YPbPr.z; 
SUB tmp.g, tmp.g, YPbPr.y;

MOV result.color, tmp;
END

7 comments:

M said...

Ottimo! Davvero una bella idea, lo per le presentazioni, così non serve riscrivere da capo tutto, una volta in nero su bianco per mandare in stampa e una volta in bianco su nero per la presentazione.

grazie,
Marco

M said...

Naturalmente manca un "userò"... la frase era: "... lo USERO' per le presentazioni..."

ciao,
Marco

Anonymous said...

Occhio che il filtro si applica alla finestra "a livello" di composite window manager, la stampante non credo sappia nemmeno cosa sia compiz-fusion... :)

Stefano said...

articolo vecchissimo ma mi è stato utilissimo! grazie

hronir said...

Ma perché, c'è qualcosa di nuovo su questo blog?!? :-)

Prego, grazie a te del feedback!

Edo said...

Adding a warmer (<= 4900 K instead of 6500 K) color temperature profile to my screen I achieve a more relaxing result. White on black can be painful to me. Not quite as black on white, but...

hronir said...

I agree, too much contrast is the problem: the target should be the right light grey on the right dark grey...