all pixels are 255.0
in
Programming Questions
•
19 days ago
here is the image i use:
In the console are pixels are 255.0 for red. But when i mouse click around, none of the pixels are 255.0.
Maybe i made a vey stupid mistake?
- PImage img;
- void setup() {
- img = loadImage("0_24.png");
- size(img.width, img.height);
- img.loadPixels();
- }
- void draw() {
- background(0);
- image(img, 0, 0);
- int index;
- //color black = color(0);
- float threshold = 0.75;
- // doesnt matter if it's red green or blue since they have the same values
- float minV = 255 * threshold;
- println("minV: "+minV);
- float red;
- for (int y = 0; y < img.height; y++) {
- for (int x = 0; x < img.width; x++) {
- index = x + img.width * y;
- red = red(img.pixels[index]);
- print(index+" "+red+" ");
- //if( ((img.pixels[index] >> 16) & 0xFF) >= minV) {
- /// set(x, y, color(255, 0, 0));
- //}
- }
- }
- println("done");
- noLoop();
- }
- void mousePressed() {
- //color c=
- println(red(get(mouseX, mouseY)));
- println(green(get(mouseX, mouseY)));
- println(blue(get(mouseX, mouseY)));
- println(alpha(get(mouseX, mouseY)));
- println();
- }
1