Fix whash

This commit is contained in:
simon987 2020-04-28 10:22:34 -04:00
parent a37c08c11b
commit a0b055cff8
3 changed files with 7 additions and 3 deletions

View File

@ -269,6 +269,9 @@ int whash_mem(void *buf, size_t buf_len, uchar *out, const int hash_size, int im
if (remove_max_ll) {
// Remove low level frequency
wave_object w_haar_tmp = wave_init("haar");
int max_level = (int) (log((double) img_scale / ((double) w_haar_tmp->filtlength - 1.0)) / log(2.0));
ll_max_level = MIN(ll_max_level, max_level);
wt2_object wt_haar_tmp = wt2_init(w_haar_tmp, "dwt", img_scale, img_scale, ll_max_level);
double *coeffs = dwt2(wt_haar_tmp, data);
@ -279,6 +282,7 @@ int whash_mem(void *buf, size_t buf_len, uchar *out, const int hash_size, int im
wt2_free(wt_haar_tmp);
wave_free(w_haar_tmp);
free(coeffs);
}
wave_object w = wave_init(wname);

View File

@ -1,7 +1,7 @@
#ifndef FASTIMAGEHASH_FASTIMAGEHASH_H
#define FASTIMAGEHASH_FASTIMAGEHASH_H
#define FASTIMAGEHASH_VERSION "4.0"
#define FASTIMAGEHASH_VERSION "4.1"
#include <stdio.h>

View File

@ -51,8 +51,8 @@ int main(int argc, char *argv[]) {
}
}
if (do_whash) {
if (whash_file(argv[i], hash, 8, 0, 1, "haar") == 0) {
hash_to_hex_string_reversed(hash, hashstr, 8);
if (whash_file(argv[i], hash, 16, 0, 1, "haar") == 0) {
hash_to_hex_string_reversed(hash, hashstr, 16);
printf("%s\tw:%s\n", argv[i], hashstr);
}
}