Calculate percentage similarity of two images using OpenCV

前端 未结 2 2015
暗喜
暗喜 2021-01-03 16:13

I am able to find matching features using bewlow shown code. I want to calculate percentage similarity between two images. I am new to OpenCV. Any kind of help will be highl

相关标签:
2条回答
  • 2021-01-03 16:35

    I found two libraries pHash and pdiff offering what I am looking for. I'll evaluate their performance and as well as compatibility with my code and pick the best one.

    0 讨论(0)
  • 2021-01-03 16:53

    I don't think you can compute a percentage per se by using feature points. But you can compute a "score of similarity".

    First of all, you want to filter out the bad matches you have, in some way (I would use a homography transformation to geometrically validate the matches). Then, you can establish your own way of computing this "score of similarity".

    For instance, you can simply sum the hamming distances between the matches you have. And you could also use the position of the feature points: Suppose a feature point Ai on image A has a correspondence Bi on image B. The coordinates of Ai are (Xa, Ya) and those of Bi are (Xb, Yb). For your images to be similar, you possibly want (Xa, Ya) to be as close as possible to (Xb, Yb). The score would then be something like:

    Score = HammingDist / DistanceBetween(Point(Xa, Ya), Point(Xb, Yb))
    

    And of course, you might want to put more weight on HammingDist or on DistanceBetween; you need to experiment.

    0 讨论(0)
提交回复
热议问题