Browse Source

minor fix in calc_image_phash

quarrying 3 years ago
parent
commit
5cb0f75564
1 changed files with 4 additions and 3 deletions
  1. 4 3
      khandy/image/image_hash.py

+ 4 - 3
khandy/image/image_hash.py

@@ -58,10 +58,11 @@ def calc_image_phash(image):
 
     dct_coeff = cv2.dct(resized.astype(np.float32))
     reduced_dct_coeff = dct_coeff[:8, :8]
-    
-    # median of coefficients excluding the DC term (0th term)
+
+    # # mean of coefficients excluding the DC term (0th term)
     # mean_val = np.mean(reduced_dct_coeff.flatten()[1:])
-    median_val = np.median(reduced_dct_coeff.flatten()[1:])
+    # median of coefficients
+    median_val = np.median(reduced_dct_coeff)
 
     hash_mat = reduced_dct_coeff >= median_val
     hash_val = _convert_bool_matrix_to_int(hash_mat)