1

I am searching for an example Python implementation to compute the Earth Mover's Distance (EMD) between two histograms (in order to compare the similarity of two images). The answer given in this post Python code for Earth mover's Distance is exactly what I am looking for, but I need it to work with cv2. The new installation of the OpenCV library no longer includes support for cv (the old library). The code in this tutorial http://compvis.readthedocs.org/en/latest/histograms.html#earth-mover-s-distance-emd is also correct, but once again uses the old library.

Any help you could provide would be much appreciated. Thanks!

Community
  • 1
  • 1
user2585945
  • 139
  • 2
  • 14
  • Each of the old functions has a new accompanying `cv2` method associated with it. Just search the documentation for each of the old methods and you'll see the corresponding new method for it. For example, `cv.CvtColor` has `cv2.cvtColor` as the equivalent method: http://docs.opencv.org/2.4/modules/imgproc/doc/miscellaneous_transformations.html#cvtcolor. When you find each of the new methods, replace that bit of code with the new method. – rayryeng Dec 05 '15 at 08:17
  • Hm, thanks. I guess this could work, however I would suspect there is a cleaner way to do this using cv2...maybe not – user2585945 Dec 06 '15 at 21:37
  • OpenCV does have an EMDD method to calculate the distance for you, but you said you wanted an example implementation instead of using the built-in method. If you want to do that, you'll have to do what I said above in the comment. – rayryeng Dec 06 '15 at 21:38
  • 1
    Where is the EMDD method documented? I don't see a way to convert the cv.calcEMD2() function to cv2. There is nothing in the documentation here: http://docs.opencv.org/2.4/modules/imgproc/doc/histograms.html#emd. I don't necessarily want the implementation, I just want to be able to compare two histograms using cv2 – user2585945 Dec 08 '15 at 00:08

0 Answers0