Removing pixels

edited July 2015 in How To...

Hi, how can I remove pixels which are over a certain rangre(RGB) from an image?

Tagged:

Answers

  • What do you mean by remove?

  • I am doing blob detection for skin detection. I would like to ignore pixels with RGB values that are outside of the expected range for pixels belonging to the skin.

  • ???

    void setup() {
      size(400, 400);
      background(0);
      noStroke();
      for (int i=0; i<20; i++) {
        fill(random(255), random(255), random(255));
        rect(random(width), random(height), random(width), random(height));
      }
    }
    
    void draw() {
    }
    
    void mousePressed() {
      loadPixels();
      for (int i=0; i<pixels.length; i++) {
        if (red(pixels[i]) > 128){
          pixels[i] = color(0);
        }
        else if (green(pixels[i]) > 128){
          pixels[i] = color(255);
        }
        else if (blue(pixels[i]) < 128){
          pixels[i] = color(128);
        }
      }
      updatePixels();
    }
    
Sign In or Register to comment.