title: Comparing pixels in image to RGB color
body: <p>Function parameters: <strong>input image, first color, second color</strong></p>
  
  <p>I am taking an image, looking at the height and width of it then iterating through to find a pixel.  If the pixel color is closest to the first color (<code>color1</code>) then change that pixel color to <code>color1</code>, if the pixel color is closest to <code>color2</code> then change it to <code>color2</code>.  My problem is believed to be at the code <code>abs(color2-color1)/2</code> when trying to compare the two parameter colors.</p>
  
  <pre><code>void Preprocessor(BMP pix, RGB color1, RGB color2) {
      int height = pix.GetHeight();
      int width = pix.GetWidth();
  
      for (int i = 0; i &lt; height; i++) {
          for (int j = 0; j &lt; width; j++) {
              if (pix[i][j]-&gt;red + pix[i][j]-&gt;green + pix[i][j]-&gt;blue &gt;
                  abs(color2 - color1) / 2) { // pixel color closest to color1
  
                  pix[i][j] = color1;
                  pix[i][j] = color1;
                  pix[i][j] = color1;
              } else { // pixel color closest to color2
                  pix[i][j] = color2;
                  pix[i][j] = color2;
                  pix[i][j] = color2;
              }
          }
      }
  }
  </code></pre>