[1044] | 1 | #ifndef _EMD_H |
---|
| 2 | #define _EMD_H |
---|
| 3 | /* |
---|
| 4 | emd.h |
---|
| 5 | |
---|
| 6 | Last update: 3/24/98 |
---|
| 7 | |
---|
| 8 | An implementation of the Earth Movers Distance. |
---|
| 9 | Based of the solution for the Transportation problem as described in |
---|
| 10 | "Introduction to Mathematical Programming" by F. S. Hillier and |
---|
| 11 | G. J. Lieberman, McGraw-Hill, 1990. |
---|
| 12 | |
---|
| 13 | Copyright (C) 1998 Yossi Rubner |
---|
| 14 | Computer Science Department, Stanford University |
---|
| 15 | E-Mail: rubner@cs.stanford.edu URL: http://vision.stanford.edu/~rubner |
---|
| 16 | */ |
---|
| 17 | |
---|
| 18 | /* DEFINITIONS */ |
---|
| 19 | #define MAX_SIG_SIZE 1000 |
---|
| 20 | #define MAX_ITERATIONS 500 |
---|
| 21 | //#define INFINITY 1e20 |
---|
| 22 | #define EPSILON 1e-6 |
---|
| 23 | |
---|
| 24 | /*****************************************************************************/ |
---|
| 25 | /* feature_t SHOULD BE MODIFIED BY THE USER TO REFLECT THE FEATURE TYPE */ |
---|
| 26 | //typedef struct { |
---|
| 27 | // double X,Y,Z; |
---|
| 28 | //} |
---|
| 29 | typedef double feature_t; |
---|
| 30 | /*****************************************************************************/ |
---|
| 31 | |
---|
| 32 | |
---|
| 33 | typedef struct |
---|
| 34 | { |
---|
| 35 | int n; /* Number of features in the signature */ |
---|
| 36 | feature_t *Features; /* Pointer to the features vector */ |
---|
| 37 | float *Weights; /* Pointer to the weights of the features */ |
---|
| 38 | } signature_t; |
---|
| 39 | |
---|
| 40 | |
---|
| 41 | typedef struct |
---|
| 42 | { |
---|
| 43 | int from; /* Feature number in signature 1 */ |
---|
| 44 | int to; /* Feature number in signature 2 */ |
---|
| 45 | float amount; /* Amount of flow from "from" to "to" */ |
---|
| 46 | } flow_t; |
---|
| 47 | |
---|
| 48 | |
---|
| 49 | |
---|
| 50 | float emd(signature_t *Signature1, signature_t *Signature2, |
---|
| 51 | float (*func)(feature_t *, feature_t *), |
---|
| 52 | flow_t *Flow, int *FlowSize); |
---|
| 53 | |
---|
| 54 | #endif |
---|