diff --git a/fastimagehash.cpp b/fastimagehash.cpp index 185dcd6..3356645 100644 --- a/fastimagehash.cpp +++ b/fastimagehash.cpp @@ -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); diff --git a/fastimagehash.h b/fastimagehash.h index ec62585..a4e40f5 100644 --- a/fastimagehash.h +++ b/fastimagehash.h @@ -1,7 +1,7 @@ #ifndef FASTIMAGEHASH_FASTIMAGEHASH_H #define FASTIMAGEHASH_FASTIMAGEHASH_H -#define FASTIMAGEHASH_VERSION "4.0" +#define FASTIMAGEHASH_VERSION "4.1" #include diff --git a/imhash.c b/imhash.c index 35d31c8..9609860 100644 --- a/imhash.c +++ b/imhash.c @@ -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); } }