@Test
public void testGetHash() throws Exception {

    URL url = getClass().getResource("/sample/");
    File dir = new File(url.toURI());
    ImageHashAlgorithm algorithm = new DCTImageHashAlgorithm();
    List<OpenBitSet> results = new ArrayList<OpenBitSet>();
    for (File file : dir.listFiles(new FilenameFilter() {
        public boolean accept(File dir, String name) {
            return name.toLowerCase().endsWith("jpg");
        }
    })) {
        BufferedImage bufferedImage = ImageIO.read(file);
        OpenBitSet hash = algorithm.getHash(bufferedImage);
        System.out.printf("%s\t%x\n", file.toString(), hash.getBits()[0]);
        results.add(hash);
    }
    double min = Double.MAX_VALUE;
    for (int i = 0; i < results.size(); i++) {
        for (int j = i + 1; j < results.size(); j++) {
            OpenBitSet hash1 = results.get(i);
            OpenBitSet hash2 = results.get(j);
            hash1.xor(hash2);
            double distance = hash1.cardinality();
            if (distance < min) min = distance;
            assertThat(distance, greaterThan(DEFAULT_THRESHOLD));
        }
    }
    System.out.println("Minimum distance:" + Double.valueOf(min));
}