Hi,
I’m trying to figure out how to change the saturation of an image, I can change its brightness, hue, invert it, but just can’t wrap my head around changing saturation (in the hope that i can put it on a slider, and have it with a load of other effects, to create a basic image processor)
Could someone give me a nudge in the right direction?
My current idea is this:
img.loadPixels();
imgCopy.loadPixels();
for (int i = 0; i <= img.width * img.height - 1; i=i+1) {
s = 20;
r = red(img.pixels[i]);
g = green(img.pixels[i]);
b = blue(img.pixels[i]);
if (r > g && r > b){
r += s;
g -= s;
b -= s;
}
if (g > b && g > r){
r -= s;
g += s;
b -= s;
}
if (b > r && b > g){
r -= s;
g -= s;
b += s;
}
imgCopy.pixels[i] = color(r, g, b);
}
img.updatePixels();
imgCopy.updatePixels();
}
Thanks for the help.