File Exchange

image thumbnail

EMD (Earth Movers Distance) mex interface

version 1.0 (14.5 KB) by

emd_mex computes Earth Movers Distance between two signatures.

4.57143
7 Ratings

14 Downloads

Updated

No License

This code is the mex interface for computing Earth Movers Distance between signatures and is based on the Y. Rubner's C Implementation.
(http://ai.stanford.edu/~rubner/emd/default.htm)

For building the mex file you should have setup your mex build environment. Invoke "build_emd" for building and "demo_emd" for a small test.

Comments and Ratings (9)

Ming Cai

The code worked really well on Windows 10. I'm now keen to run the code on Ubuntu 16.0.4 (64 bit) with 2017a and modified the code as suggested by Patrick. Further , I had to install gcc v4.9 and modify the build_emd.m as follows:
mex -v GCC='usr/bin/gcc-4.9' emd_mex.c emd.c -O
The build was successful to yield emd_mex.mexa64. However, running the demo_emd has ended up in "core dump" with termination of Matlab. Does anybody advise me how to debug the mex file?

Patrick

Thanks, Masoud!

I have a 64 bit Linux system. To get this code to work, I needed to make the following modifications.

1. In emd_mex.c line 106: change "//maxsimum size of flow" to "/*maxsimum size of flow*/" since the "//" for single-line C comments are Microsoft only.

2. Add a line break to the end of emd_mex.c and save.

3. Run build_emd.

Thanks, and I hope that was helpful.

Patrick

Csaba Beleznai

Michaels question is justified. The features (bin locations) are computed within the mex as consecutive indices. Thus, for a complete definition of a signature, you have to include the full span of weights for all bins (which is cumbersome if working with multidimensional signatures).

Rajat Sharma

Works really well. Thank you for doing this.

Michael Blighe

Where are the actual features (signatures) defined? The demo only uses the weights and the ground distance matrix?

Amir Anvari

Al Fa

Great, works perfect!!!

Updates

Typo

MATLAB Release
MATLAB 7.2 (R2006a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Win prizes and improve your MATLAB skills

Play today