title: Filter difference between 2 images?
body: <p>I am trying to filter out the difference between 2 images (Screenshots).
  Unfortunately I have absolutely no experience in Java and images and have no real idea what to look for.</p>
  
  <p>Are there ready-to-use classes for that?</p>
  
  <p>What I am expecting is something like:</p>
  
  <pre><code>Image imgA = new (pathToA);   // Image with for instance 500kb
  Image imgB = new (pathToB);   // Image with for instance 500kb
  Image imgC = ImageFilter.filterDifference(imgA, imgB);   // Only the difference between imgA and imgB and therefore for instance 20kb
  </code></pre>
  
  <p><strong>Edit:</strong></p>
  
  <p>Example: Anyway, what I mean with difference is the visual difference between the to images (Screenshots). If I have one screenshot with 5 icons in a folder and then do another screenshot with 1 icon more, then I want imgC to only show this new icon.</p>
  
  <p><strong>Edit 2:</strong></p>
  
  <p>Clarification: I only want the difference between 2 Screenshots in a new image.</p>
  
  <p><strong>Edit 3:</strong></p>
  
  <p>Some kind of code that would look like this one (Code does not work):</p>
  
  <pre><code>private BufferedImage getImageDifference(BufferedImage img1, BufferedImage img2) {
      if (img1.getWidth() == img2.getWidth() &amp;&amp; img1.getHeight() == img2.getHeight()) {
          BufferedImage img3 = new BufferedImage(img1.getHeight(), img1.getWidth(), img1.getType());
          for (int x = 0; x &lt; img1.getWidth(); x++) {
              for (int y = 0; y &lt; img1.getHeight(); y++) {
                  if (img1.getRGB(x, y) != img2.getRGB(x, y))
                      //return false;
                      img3.setRGB(x, y, img2.getRGB(x, y));
              }
              return img3;
          }
      } else {
          return false;
      }
  }
  </code></pre>