get_earthmover_distance - Computes the earthmover's distance.
Example compile flags (system dependent):
-DLINUX_X86_64 -DLINUX_X86_64_OPTERON -DGNU_COMPILER
-lKJB -lfftw3 -lgsl -lgslcblas -ljpeg -lSVM -lstdc++ -lpthread -lSLATEC -lg2c -lacml -lacml_mv -lblas -lg2c -lncursesw
int (*distance_fn)(Vector *,Vector *,double *),
First input signature
Second input signature
Output array of flows
Number of valid flows
This routine computes the earthmover's distance between two distributions.
Distributions are stored in "signatures" which consist of an array of
"features" and a corresponding array of feature weights.
In the emd_lib.c module, a "feature" is simply a "Vector".
A "signature" is defined as follows:
| typedef struct Signature
int num_features; Number of features in the signature
Vector** feature_vec; Pointer to array of features
double* weights_vec; Pointer to array of feature weights
Each feature in a signature has a corresponding weight indicating its relative
abundance in the distribution.
A distance function must be supplied that computes the distance between
two features. A function that computes the Euclidean distance between two
features as defined above is provided: See the "distance" function.
This routine will optionally return the flow that was required to map one input
distribution to the other. If "flow_vec" is NULL, then no flow is computed. If
output flows are required, then "flow_vec" must be preallocated, and contain
n1 + n2 - 1 elements, where n1 and n2 are the numbers of elements in the two
Note that the earthmover's distance is a true metric ONLY when the two input
signatures are the same size.
Uses code written by Yosi Rubner. See http://vision.stanford.edu/~rubner
Either NO_ERROR, or ERROR, with an appropriate error message being set.
This software is not adequatedly tested. It is recomended that
results are checked independantly where appropriate.
Yossi Rubner, Lindsay Martin