How to compare the similarity of two pictures in C++

There are various ways to compare the similarity of two pictures. Here are some common methods:

  1. Perceptual Hashing: convert the image into a hash value, and then compare the difference between the two hash values ​​to measure the similarity between them. The algorithm is robust to operations such as rotation, scaling, and cropping.

  2. Histogram Comparison: Convert the RGB color value of each picture into a histogram, and then use some distance measurement method (such as Euclidean distance or Hamming distance) to calculate the distance between the histograms of two pictures to measure the similarity between them.

  3. Structural Similarity Index (SSIM): By comparing the brightness, contrast and structural features of two pictures, the structural similarity index between them is given. The closer the index is to 1, the more similar the two pictures are.

  4. Average Hashing: Reduce the image to 8x8 size, then calculate the color average of each pixel, and convert it into binary bits. Finally, compare the Hamming distance of the two hash values ​​to measure the similarity between them.

All of the above methods can be written and implemented in C++. For specific implementation methods, please refer to relevant open source libraries and algorithm implementations.

Guess you like

Origin blog.csdn.net/k1419197516/article/details/123134605