We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1fa4082 commit 510da90Copy full SHA for 510da90
src/javaxt/io/Image.java
@@ -1748,9 +1748,21 @@ public boolean isSimilarTo(Image image, int threshold){
1748
* perceptual hash values for the images.
1749
*/
1750
public int getHammingDistance(Image image){
1751
+ /*
1752
long hash1 = getPHash();
1753
long hash2 = image.getPHash();
1754
return Long.bitCount(hash1 ^ hash2);
1755
+ */
1756
+
1757
+ String hash = Long.toBinaryString(getPHash());
1758
+ String target = Long.toBinaryString(image.getPHash());
1759
+ int d = 0;
1760
+ for (int i=0; i<hash.length(); i++) {
1761
+ if (hash.charAt(i) != target.charAt(i)) {
1762
+ d++;
1763
+ }
1764
1765
+ return d;
1766
}
1767
1768
0 commit comments