The principle is easy to understand and is reliant on what Dr. Neal Krawetz calls a fast algorithm.
Or more specifically, the key technology involved here is called "perceptual hash algorithm." Its role is to generate a "fingerprint" character string for each image and then compare the fingerprints. The closer the comparison result, the more similar the two images are.
Below is a simple implementation:
After you have the fingerprint, you can compare different images to check how many bits in the 64 bits are different. In theory, this is same as calculating the "Hamming distance." If the number of different bits is less than 5, the two images are similar; if the number of different bits exceeds 10, it means the two images are different.
For specific code implementation, see imgHash.py written by Wote in Python. The code is short (only 52 lines). In usage, the first parameter refers to the benchmark image and the second parameter indicates the directory of other images for comparison. The returned result is the number of different bits of the two images (Hamming distance).
This algorithm is advantageous for being easy and quick, irrespective of the size of the image, but its disadvantage is that the image's content cannot change. If you add several texts on the image, the algorithm will not recognize it. It locates the original picture based on a thumbnail.
In practical application, pHash and SIFT use more robust algorithms as they can recognize the variations in images. They can match the original image as long as the deformation is less than 25 percent. These algorithms are more complicated, but they follow the same principle as the simple algorithm explained above, namely converting the image to a hash character value and then making the comparison.
See! Not that complex after all.
Alibaba Clouder - April 14, 2017
Alibaba Clouder - November 27, 2018
Alibaba Clouder - August 19, 2019
Alibaba Clouder - November 25, 2020
Alibaba Clouder - June 22, 2020
Alibaba Cloud Community - February 21, 2022
An intelligent image search service with product search and generic search features to help users resolve image search requests.Learn More
This technology can assist realizing quantitative analysis, speeding up CT image analytics, avoiding errors caused by fatigue and adjusting treatment plans in time.Learn More
Offline SDKs for visual production, such as image segmentation, video segmentation, and character recognition, based on deep learning technologies developed by Alibaba Cloud.Learn More
OpenSearch helps develop intelligent search services.Learn More
More Posts by Alibaba Clouder