NAME
get_earthmover_distance - Computes the earthmover's distance.
SYNOPSIS
#include "lsm/lsm_emd.h"
Example compile flags (system dependent):
-DLINUX_X86_64 -DLINUX_X86_64_OPTERON -DGNU_COMPILER
-I/home/kobus/include
-L/home/kobus/misc/load/linux_x86_64_opteron -L/usr/lib/x86_64-linux-gnu
-lKJB -lfftw3 -lgsl -lgslcblas -ljpeg -lSVM -lstdc++ -lpthread -lSLATEC -lg2c -lacml -lacml_mv -lblas -lg2c -lncursesw
int get_earthmover_distance
(
Signature *sig1,
Signature *sig2,
int (*distance_fn)(Vector *,Vector *,double *),
Flow *flow_vec,
int *num_flows_ptr,
double *em_distance_ptr
);
PARAMETERS
-
Signature *sig1
-
First input signature
-
Signature *sig2
-
Second input signature
-
Flow *flow_vec
-
Output array of flows
-
int *num_flows_ptr
-
Number of valid flows
-
double *em_distance_ptr
-
Earthmover's Distance
DESCRIPTION
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
} Signature;
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
input signatures.
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
RETURNS
Either NO_ERROR, or ERROR, with an appropriate error message being set.
DISCLAIMER
This software is not adequatedly tested. It is recomended that
results are checked independantly where appropriate.
AUTHOR
Yossi Rubner, Lindsay Martin
DOCUMENTER
Lindsay Martin
SEE ALSO
euclidean_distance
,
get_target_signature
,
free_signature
,
copy_signature
,
set_signature_features
,
set_signature_weights
,
get_target_signature_db