title: Filter by only red values in Processing
body: <p>I'm trying to make a program that uses my webcam in processing 3.x that will filter green and blue, from an image and show either red and black or white. I've tried two ways that I think should work, but I must be missing something here because my whole screen just goes black when I switch to this red mode.</p>
  
  <p>Attempt 1:</p>
  
  <pre class="lang-java prettyprint-override"><code>for(int y = 0; y &lt; height; y++){
     for(int x = 0; x &lt; width; x++){
        set(x,y,color(red(x+(y*width)),0,0));
     }
  }
  </code></pre>
  
  <p>Attempt 2:</p>
  
  <pre class="lang-java prettyprint-override"><code>// inputImage is the image on my screen of type PImage.
  for(int c = 0; c &lt; inputImage.pixels.length; c++){
     inputImage.pixels[c] = color(red(c),0,0);
  }
  </code></pre>
  
  <p>Both attempts resulted in a black screen.</p>