is it possible to change the saturation or brightness of a jpg without going into pixels[]?
in
Programming Questions
•
5 months ago
Hi everyone,
currently, I'm doing it by running through pixels[] with a for loop, breaking apart each color into hue, saturation and brightness, affecting saturation or brightness, sending it back into pixels[], then doing an updatepixels(), like so:
- loadPixels();
- for (int i = 0; i < pixels.length; i++){
- // get values from pixels[]
- color c;
- float h = hue(pixels[i]);
- float s = saturation(pixels[i]);
- float b = brightness(pixels[i]);
- if (s > mod){ // we are changing saturation
- s += mod;
- }
- // put values back in pixels
- c = color(h, s, b);
- pixels[i] = c;
- }
- updatePixels();
The main reason I would like to find another way to do this is to be able to progressively reverse the process. Going back and forth with this method slowly takes out information until the image is gone. Is there something equivalent to tint(), but for saturation and/or brightness?
Thanks for your help!
N.
1