We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Brightness. (Read 621 times)
Brightness.
Apr 12th, 2009, 7:33am
 
Hello.

I have a PImage named image1.
How can I made this image more bright or more dark, please ?

Thank's.
Re: Brightness.
Reply #1 - Apr 12th, 2009, 2:58pm
 
I tried a bit, maybe it helps.
It aint perfect cause it should have somekind of curve in it, right now values will get out of the reach of 255 and if they do they will be set to 255 and I think that aint the best way.

The thing does work better to get a image in a certain tint, for example:
   img.pixels[i] = color(50, S, B);

will give the image a green look.

Code:

PImage img;
int H, S, B;
float B2;

void setup(){
size(300, 300);
img = loadImage("b.png");
colorMode(HSB);
noLoop();
}

void draw(){
image(img, 0, 0);
img.loadPixels();
for (int i =0; i < img.pixels.length; i++){
H = int(hue(img.pixels[i]));
S = int(saturation(img.pixels[i]));
B = int(brightness(img.pixels[i]));
B2 = float(B)*2.5;
if (B2 > 255.0){
B2 = 255.0;
}
println(B2);

// println(H+" "+S+" "+B);
img.pixels[i] = color(H, S, B2);

}
img.updatePixels();

image(img, img.width, 0);
}
Re: Brightness.
Reply #2 - Apr 13th, 2009, 12:23am
 
Thank's, it works very well.
Page Index Toggle Pages: 1