I was trying to find a functional form for saturation but didn’t find anything. It can’t be that hard but all my guesses don’t look quite right (the direction towards desaturation seems easier).
I have the pixel data of the image in RGB format. The final image should also be in RGB format. So, how are these functions defined:
r_n = saturation_r(r,g,b,sat);
g_n = saturation_g(r,g,b,sat);
b_n = saturation_b(r,g,b,sat);
Convert the RGB pixel to HLS, scale the S by your
satinput, then convert back to RGB. Pseudo-code, assuming all color components are in the range 0.0 to 1.0:If you need RGB/HLS conversion functions, here they are.