/** * Computes the hamming score between two descriptions. Larger the number better the fit */ protected int hamming(short[] a, short[] b) { int distance = 0; for (int i = 0; i < a.length; i++) { distance += DescriptorDistance.hamming((a[i]&0xFFFF) ^ (b[i]&0xFFFF)); } return distance; }
@Override public double score(TupleDesc_B a, TupleDesc_B b) { return DescriptorDistance.hamming(a,b); }
/** * Computes the hamming distance between two binary feature descriptors * * @param a First variable * @param b Second variable * @return The hamming distance */ public static int hamming( TupleDesc_B a, TupleDesc_B b ) { int score = 0; final int N = a.data.length; for( int i = 0; i < N; i++ ) { score += hamming(a.data[i] ^ b.data[i]); } return score; }