You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying out the DoubleGradient hash algorithm. I expected the hash_size() passed to HasherConfig to be respected (assuming width and height being multiples of 2), but the resulting hashes have fewer bits than that. Here's a snippet of code and the resulting output:
Both 8 and 16 are multiples of two, so I didn't expect any changes when using DoubleGradient. I think this is a bug, but I wasn't able to pinpoint the problem yet.
I tried both with img_hash 3.2.0 and with the latest commit on the main branch, which seems to be the same.
The text was updated successfully, but these errors were encountered:
Initially I didn't understand how DoubleGradient works. Now I see that it is a concatenation of the Horizontal Gradient and the Vertical Gradient hashes, with both calculated at a smaller size so that the two of them don't exceed the original dimensions.
When given a hash dimension of 8x8 (for example), img_hash resizes the image to 5x5 (8/2-1, 8/2-1). It then applies both gradients to the same resized image, both producing a 5x4 hash. These are then concatenated together and a 40 bit hash is returned.
With this way of constructing a double gradient, it's probably impossible to respect every possible original dimensions. Maybe the documentation could be updated to reflect that the specified dimensions are an upper bound, in this case? Or the hash could be zero padded at the end?
Hi there,
I am trying out the
DoubleGradient
hash algorithm. I expected the hash_size() passed to HasherConfig to be respected (assuming width and height being multiples of 2), but the resulting hashes have fewer bits than that. Here's a snippet of code and the resulting output:I also added a
println
insidehash_image
to printbytes.len()
,resize_width
, andresize_height
.Both 8 and 16 are multiples of two, so I didn't expect any changes when using
DoubleGradient
. I think this is a bug, but I wasn't able to pinpoint the problem yet.I tried both with img_hash 3.2.0 and with the latest commit on the main branch, which seems to be the same.
The text was updated successfully, but these errors were encountered: