-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
Description
ImageMagick has different metrics to calculate differences between images: https://www.imagemagick.org/script/command-line-options.php#metric
Might be able to get this running in node and should compare it to our current metrics based on blink-diff
: https://www.npmjs.com/search?q=magick&ranking=popularity
The function is also easily available in R via magick
: https://rdrr.io/cran/magick/man/analysis.html - thanks to @jeroen for the pointer!
library(magick)
> image1 <- image_read("~/Desktop/index1.png")
> image2 <- image_read("~/Desktop/index2.png")
> print(image1)
format width height colorspace matte filesize density
1 PNG 1344 960 sRGB FALSE 84130 76x76
> image_compare_dist(image1, image2)
$distortion
[1] 0.9503712
> image_compare(image1, image2)
format width height colorspace matte filesize density
1 PNG 1344 960 sRGB TRUE 0 76x76
> image_compare(image1, image2, fuzz = 5)
format width height colorspace matte filesize density
1 PNG 1344 960 sRGB TRUE 0 76x76
> image_compare(image1, image2, fuzz = 50)
format width height colorspace matte filesize density
1 PNG 1344 960 sRGB TRUE 0 76x76
> image_compare_dist(image1, image2, fuzz = 50)
$distortion
[1] 0.9503712
> image_compare_dist(image1, image2, metric = "phash")
$distortion
[1] 0.2836806
> image_compare(image1, image2, metric = "phash")
format width height colorspace matte filesize density
1 PNG 1344 960 sRGB TRUE 0 76x76
It has similar challenges though, but the numeric metric could help and be more effective than the current "pixel counting".
- build a test case where the line in the plot differs and has the exact same distortion number than a plot where only the font introduces errors
> metric_types()
[1] "Undefined" "AE" "Fuzz" "MAE" "MEPP" "MSE" "NCC"
[8] "PAE" "PHASH" "PSNR" "RMSE"
> image_compare_dist(image1, image2, metric = "PAE")
$distortion
[1] 1
> image_compare_dist(image1, image2, metric = "PSNR")
$distortion
[1] 25.01049
> image_compare_dist(image1, image2, metric = "MEPP")
$distortion
[1] 1329365910
The different metrics give different output numbers, but the image is not perceivably different.
Used images for testing: