This Library calculates the similarity between two images and returns a value in similarity in percentage
- Start
- Open Images to compare
- Decode them using a suitable Decoder(
jpeg
,png
) - Convert them to Grayscale
- Downsize them to a 9x9(faster, less accurate) or 17x17(slightly slower, but more accurate)
- Calculate the
dHash
ordifferenceHash
of each image - Compare the two hashes and then calculate the difference in percentage b/w the two
- End
You can provide hash length to whatever value you want. Keep in mind, that increasing hash length will decrease performance and might increase accuracy.
Say, You provided 512 bits as hash length, Then,
512 / 2 = 256
sqrt(256) = 16
Now the image is downsized to 17x17.
MIT