6

I am looking for a program that can compare two images, and return the rate of similarity (e.g., in %).

Any license, price, and operating system is fine. I mostly interested in the quantity of the image similarity algorithm.

6
  • What do you define as similarity? (Roughly the) same colo(u)r pixel in (roughly) the same place? Feb 22, 2018 at 9:36
  • @Mawg ideally, the algorithm should match similarity as judged by humans, which I am aware is partly subjective Feb 22, 2018 at 16:07
  • Lol - make that entirely subjective :-) Can we try to define it? Roughly the same shapes/colo(u)rs in roughly the same places? I am hoping to get am answer to this question, btw Feb 22, 2018 at 20:53
  • Similarity as judged by humans sounds like a difficult research problem, not something you're going to find an accurate shrink-wrapped tool for. Feb 26, 2018 at 18:50
  • @Kodiologist some relatively subjective take such as automated summarization or content aware filling have some decently well packaged code/program taking care of it. Feb 26, 2018 at 20:08

3 Answers 3

3

You could use the morphing distance as calculated by https://github.com/kallaballa/Poppy (I am the author)

e.g. when running poppy as follows, the last line denotes the distance between the circle and square image.

image of a black filled circle image of a black filled square

src/poppy -n images/circle.png images/square.png

Which gives 0.0257155 in this example.

When comparing something more similar, like e.g. two faces:

Picture of a face Picture of another face

src/poppy -n images/some1.png images/some2.png

It gives 0.00411874, which is way lower.

1
  • 1
    You are the author of this tool, right? A rule of this site is that you must disclose any affiliation, so please state it clearly. Thanks!
    – Nicolas Raoul
    Jun 17 at 6:32
2

You can see the difference of two images using imagemagick.

Use ImageMagick® to create, edit, compose, or convert bitmap images. It can read and write images in a variety of formats (over 200) including PNG, JPEG, GIF, HEIC, TIFF, DPX, EXR, WebP, Postscript, PDF, and SVG. Use ImageMagick to resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves.

imagemagick homepage

It works fine on Windows. See this answer at stackoverflow.com about comparing two images If the output is "1161" it's 50%. See @Mark Setchell's comment about his own answer.

@echo off
FOR /F %%G IN ('magick.exe compare -metric ae PATH_TO_YOUR_IMAGE\a.jpg PATH_TO_YOUR_IMAGE\b.jpg null:') DO @SET n=%%G 
echo %percent%

Save this file as "percent.bat" or whatever you like in the same directory of magick.exe. Run it on command line. (I had to add "magick.exe" above code)

Virustotal.Com results for executables are fine, I only tested setup program and magick.exe

2

I have developed an image comparison algorithm for near duplicate search, which you can try online on the web-site. The corresponding program func EucMetric (Github code) returns 3 similarity metrics (one per color channel).

Current implementation is relatively strict on position/rotation/distortion etc. But by adding a sliding window with scale/position variations, it is possible to apply this algorithm to sub-regions, so that you can get a cumulative metric based on similarity of image parts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.