Have you read reference ?

[> Computes the "minimal work" distance

between two weighted point
configurations base on the papers
"EMD-L1: An efficient and Robust
Algorithm for comparing
histogram-based descriptors", by
Haibin Ling and Kazunori Okuda; and
"The Earth Mover's Distance is the
Mallows Distance: Some Insights from
Statistics", by Elizaveta Levina and
Peter Bickel.](http://docs.opencv.org/master/d1/d85/group__shape.html#gacb101cb63eb94a4a6a61d60e487b18e6)

Abstract.
We propose a fast algorithm, EMD-
L
1
, for computing the
Earth Mover’s Distance (EMD) between a pair of histograms. Compared
to the original formulation, EMD-
L
1
has a largely simplified structure.
The number of unknown variables in EMD-
L
1
is
O
(
N
) that is signifi-
cantly less than
O
(
N
2
) of the original EMD for a histogram with
N
bins ....