rhsimplex / image-match

🎇 Quickly search over billions of images
2.94k stars 405 forks source link

What's the advantage to using L2 norm instead of Hamming norm? #119

Open Amoko opened 5 years ago

Amoko commented 5 years ago

the code in function ''normalized_distance(_a, _b)'':

        norm_diff = np.linalg.norm(b - a)
        norm1 = np.linalg.norm(b)
        norm2 = np.linalg.norm(a)
        return norm_diff / (norm1 + norm2)
arnavkagrawal commented 5 years ago

As per the paper based on which this code is implemented (An image signature for any kind of image, Wong et al):

Relative to L1 norm(Hamming distance), L2 norm gives greater emphasis to larger differences. This is appropriate because a difference of 1 at a coordinate may be due to roundoff, but a difference of 2 is meaningful.

Amoko commented 5 years ago

As per the paper based on which this code is implemented (An image signature for any kind of image, Wong et al):

Relative to L1 norm(Hamming distance), L2 norm gives greater emphasis to larger differences. This is appropriate because a difference of 1 at a coordinate may be due to roundoff, but a difference of 2 is meaningful.

I got it! thx bro.