flavour404
flavour404

Reputation: 6312

Fastest way to compare two images

I need to compare two images as fast as possible. I don't need to know the differences or anything else I just need to know if they are the same, yes/no, awesome. What is the fastest way to do this?

Thanks, R.

Upvotes: 1

Views: 2099

Answers (2)

Joey Sanchez
Joey Sanchez

Reputation: 11

tldr;

  1. image hashing ( phash, dhash, colorhash, average_hash etc)
  2. Feature detection using computer vision (opencv)
  3. bitwise operations against pixel arrays(opencv)

UPDATE 2023: Since this is the top search on google currently I figured I would answer this. There are many ways to do this depending on the image type. Hashing is very quick to do image comparisons. However, each hashing technique differs.

You can look at the imagehash library (python) to get an example of the various hashes you can leverage and see similarities it finds based on the type of hashes such as phash, dhash, colorhash, average_hash etc.

However, sometimes you want to compare features in an image and you should leverage something like opencv to get contours or features to compare images against each other.

Upvotes: 0

Stefan Mai
Stefan Mai

Reputation: 23939

If they are expected to be the same, byte-by-bye like @NullUserException mentioned, the easiest solution is to use a hash like Md5. If you'd like to get more advanced, you can get the RGB values of each pixel in the first image and calculate the euclidean distance from the pixels in the second image checking to see if it's below some threshold. Everything is else is not fast :)

Upvotes: 1

Related Questions