Skip to content

Commit 510da90

Browse files
committed
Reverting XOR changes in the getHammingDistance() method in the Image class
1 parent 1fa4082 commit 510da90

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/javaxt/io/Image.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,9 +1748,21 @@ public boolean isSimilarTo(Image image, int threshold){
17481748
* perceptual hash values for the images.
17491749
*/
17501750
public int getHammingDistance(Image image){
1751+
/*
17511752
long hash1 = getPHash();
17521753
long hash2 = image.getPHash();
17531754
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;
17541766
}
17551767

17561768

0 commit comments

Comments
 (0)