1
$\begingroup$

I want to create a function $f : [0,255]^3 \rightarrow [0,255]^3$ over the integers such that if you pass in three RGB color values, a triple with a darker or lighter color will be returned, and I want the values to increase in some sort of proportion to how dark or light they are already; lightness and darkness being determined by, say, taking the average of the values.

Is there a relatively simple function that will do this? If not, is there a way to emulate it?

  • 0
    @Willie (I apologize for the late response) if you make that an answer I would be happy to accept it as such!2011-03-31

1 Answers 1

3

(This was a comment. Posting as CW answer so the question can be marked as solved.)

There is a bijection used by my dad when he taught elementary school to scale grades, which can be modified to be $h(x)=16 \sqrt{x}$ for $x\in [0,256]$. You can perform this entry-wise on RGB. To change the dependence on the starting value, you can change $\sqrt{x}$ to $|x|^p$ for $p<1$.

(And as Rahul pointed out in the comments, the above is nothing but gamma correction. )