Image hash length

I’m interested to use the image hashes supported in OpenCV. Looking at the documentation here:

am I understanding correctly that all hashes except colorMomentHash() are 64 bits in length?

What’s the length of the colorMomentHash()? The doc seems to say it’s 42 double values, so is it 42*64 bits?

What’s the length of the radialVarianceHash()? The doc does not seem to indicate this.


no, not correct (printing out type() and size()):

=== AverageHash ===
type: 0 [8 x 1]

=== PHash ===
type: 0 [8 x 1]

=== MarrHildrethHash ===
type: 0 [72 x 1]

=== RadialVarianceHash ===
type: 0 [40 x 1]

=== BlockMeanHash ===
type: 0 [32 x 1]

=== ColorMomentHash ===
type: 6 [42 x 1]

please also note, that ColorMomentHash and RadialVarianceHash are not binary, so you cannot simply apply hamming norm, and it also does not make much sense to count bits for those

same question: opencv - Lengths of image hashes - Stack Overflow

@berak Thanks.

For the non-binary hashes (ColorMomentHash and RadialVarianceHash), what distance is recommended for comparing 2 hashes? Euclidean distance?

well, you should use the supplied compare() function, no ?

please have a look at the src code for this
(ColorMomentHash is using L2 norm)

1 Like