source: class DCTImageHashAlgorithmTest {
  
      private static final double DEFAULT_THRESHOLD;
  
      @Test
      public void testEqual() throws IOException {
  
target:         BufferedImage png = ImageIO.read(getClass().getResource("/sample/IMG_1548.png"));
          String[] resources = new String[]{
                  "/sample/IMG_1548.jpg", //just recompressed
                  "/sample/IMG_1548_crayon.jpe", //edited with crayon
                  "/sample/IMG_1548_scaled.jpe", //scaled back a lot
                  "/sample/IMG_1548_cropped.jpe", //cropped - this is tough
          };
          ImageHashAlgorithm algorithm = new DCTImageHashAlgorithm();
          OpenBitSet pnghash = algorithm.getHash(png);
          double max = 0;
          for (String resource : resources) {
              BufferedImage jpg = ImageIO.read(getClass().getResource(resource));
              OpenBitSet jpghash = algorithm.getHash(jpg);
              jpghash.xor(pnghash);
              double distance = jpghash.cardinality();
              System.out.printf("Distance for %s = %f\n", resource, distance);
              if (distance > max) max = distance;
              assertThat(distance, lessThanOrEqualTo(DEFAULT_THRESHOLD));
          }
          System.out.println("Maxiumum distance:" + Double.valueOf(max));
      }
  
  }