* Sped up perceptual hashing by switching from Gaussian to Box blur.
authorUrban Wallasch <urban.wallasch@freenet.de>
Sun, 6 Jun 2021 13:24:24 +0000 (15:24 +0200)
committerUrban Wallasch <urban.wallasch@freenet.de>
Sun, 6 Jun 2021 13:24:24 +0000 (15:24 +0200)
README.md
db.c

index f8e2ee61d0cf7bfa365ef927a21eda101f8f018f..687107678c2c8d1a530a22597524693f4b5e5f2d 100644 (file)
--- a/README.md
+++ b/README.md
@@ -9,7 +9,7 @@ The perceptual hash for an image is calculated by:
 
   * flattening the image (merging layers/frames)
   * transforming the color space to gray scale
-  * resizing to 16 by 16 pixel while applying Gaussian blur
+  * resizing to 16 by 16 pixel using box blur
   * normalizing contrast and brightness
   * conversion to monochromatic image
   * interpreting the pixel values as 256 bit hash value
diff --git a/db.c b/db.c
index 644a3507284728572430516638fd84b69646e8fa..4990d8ec1615e0d2e0396d2c3a4e7b1e1f539047 100644 (file)
--- a/db.c
+++ b/db.c
@@ -47,7 +47,7 @@ static int phash(db_entry_t *p, double blur) {
         goto ERR2;
     wand2 = MagickFlattenImages(wand);
     MagickSetImageColorspace(wand2, GRAYColorspace);
-    MagickResizeImage(wand2, 16, 16, GaussianFilter, blur);
+    MagickResizeImage(wand2, 16, 16, BoxFilter, blur);
     MagickNormalizeImage(wand2);
     MagickGetImagePixels(wand2, 0, 0, 16, 16, "I", CharPixel, pix);
     uint64_t h = 0;