strange behaviour
in
Programming Questions
•
2 years ago
My brightness save is fine, but if i uncomment the 2 lines about hue saturation then my brightness save is just a grey image.
- PImage img;
- PImage bImg;
- PImage hsImg;
- void setup(){
- colorMode(HSB);
- img = loadImage("orange_tree2.png");
- size(img.width, img.height);
- bImg = img;
- hsImg = img;
- // hueSaturationIMG(hsImg);
- // hsImg.save("hueSaturation.png");
- brightnessIMG(bImg);
- bImg.save("brightness.png");
- exit();
- }
- void hueSaturationIMG(PImage img){
- for(int i = 0; i < img.pixels.length; i++){
- float h = hue(img.pixels[i]);
- float s = saturation(img.pixels[i]);
- img.pixels[i] = color(h, s, 255);
- }
- }
- void brightnessIMG(PImage img){
- for(int i = 0; i < img.pixels.length; i++){
- float b = brightness(img.pixels[i]);
- img.pixels[i] = color(0, 0, b);
- }
- }
1