title: Comparing two images using their RGB values. (Java)
body: <p>I am trying to compare two images using their RGB values. </p>
  
  <p>The code below is pulling the same RGB values for the unfiltered and filtered. I want the values to be different for the two images. (unfiltered and filtered are previously defined). The idea is that the greater the difference between the two images (before and after filtering) the poorer the filtered image is. </p>
  
  <p>As my result I would expect two different sets of RGB values (1 for unfiltered and 1 for filtered). I get two sets of RGB values, however, both are identical.</p>
  
  <p>I am creating a colour blind simulator and want to compare the value from both. Below is an example of a "Normal" vision image and a "Colour Blind" vision image. </p>
  
  <p><a href="http://i.stack.imgur.com/hZsyL.jpg" rel="nofollow">Unfiltered Image</a> |
  <a href="http://i.stack.imgur.com/SEFna.jpg" rel="nofollow">Filtered Image</a></p>
  
  <pre><code>filteredImage = unfilteredImage = Img;
  </code></pre>
  
  <p>...</p>
  
  <pre><code>ImageDisplay = new JLabel(new ImageIcon(filteredImage));
  </code></pre>
  
  <p>...</p>
  
  <pre><code>private void TypeButtonPressed()
  {
      filteredImage(GetType());
  }
  </code></pre>
  
  <p>...</p>
  
  <pre><code>int GetType()
  {
      int type = 0;
      for (int i=0; i&lt;numberOfTypes; i++)
      {
          JToggleButton TypeButton = TypeButtons[i];
          if (TypeButton.isSelected()) type = i;
      }
  
      TypeListener.SetType(type);
      return type;
  }
  </code></pre>
  
  <p>...</p>
  
  <pre><code>        BufferedImage unfiltered = unfilteredImage;
          BufferedImage filtered = filteredImage;
  
          //unfilteredImage
          int ufwidth = unfiltered.getWidth();
          int ufheight = unfiltered.getHeight();
  
          Color unfilteredRGBValue = new Color(unfiltered.getRGB(ufwidth / 2, ufheight / 2));
  
          int ufred = unfilteredRGBValue.getRed();
          int ufgreen = unfilteredRGBValue.getGreen();
          int ufblue = unfilteredRGBValue.getBlue();
  
          System.out.println("Unfiltered Red: " + ufred);
          System.out.println("Unfiltered Green: " + ufgreen);
          System.out.println("Unfiltered Blue: " + ufblue);
  
          System.out.println("Unfiltered Score: " + ufred + ufgreen + ufblue);
  
          //filteredImage
          int fwidth = filtered.getWidth();
          int fheight = filtered.getHeight();
  
          Color filteredRGBValue = new Color(filtered.getRGB(fwidth / 2, fheight / 2));
  
          int fred = filteredRGBValue.getRed();
          int fgreen = filteredRGBValue.getGreen();
          int fblue = filteredRGBValue.getBlue();
  
          System.out.println("Filtered Red: " + fred);
          System.out.println("Filtered Green: " + fgreen);
          System.out.println("Filtered Blue: " + fblue);
  
          System.out.println("Filtered Score: " + fred + fgreen + fblue);
  </code></pre>
  
  <p>Thank you!</p>
  
  <p>Ed.</p>