From: Ilya Lysenkov Date: Wed, 8 Jun 2011 10:08:24 +0000 (+0000) Subject: Added documenation of the Earth Mover Distance (C++ interface, ticket #696) X-Git-Tag: accepted/tizen/6.0/unified/20201030.111113~7090 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1e945dc9843dc8be64dc668881e16f4abc4d60a9;p=platform%2Fupstream%2Fopencv.git Added documenation of the Earth Mover Distance (C++ interface, ticket #696) --- diff --git a/modules/imgproc/doc/histograms.rst b/modules/imgproc/doc/histograms.rst index befd545..1486578 100644 --- a/modules/imgproc/doc/histograms.rst +++ b/modules/imgproc/doc/histograms.rst @@ -201,7 +201,30 @@ The function returns :math:`d(H_1, H_2)` . While the function works well with 1-, 2-, 3-dimensional dense histograms, it may not be suitable for high-dimensional sparse histograms. In such histograms, because of aliasing and sampling problems, the coordinates of non-zero histogram bins can slightly shift. To compare such histograms or more general sparse configurations of weighted points, consider using the -:cpp:func:`calcEMD` function. +:cpp:func:`EMD` function. + + +.. index:: EMD + +EMD +------ +.. cpp:function:: float EMD( InputArray signature1, InputArray signature2, int distType, InputArray cost=noArray(), float* lowerBound=0, OutputArray flow=noArray() ) + + Computes the "minimal work" distance between two weighted point configurations. + + + :param signature1: The first signature, a :math:`\texttt{size1}\times \texttt{dims}+1` floating-point matrix. Each row stores the point weight followed by the point coordinates. The matrix is allowed to have a single column (weights only) if the user-defined cost matrix is used. + + :param signature2: The second signature of the same format as ``signature1`` , though the number of rows may be different. The total weights may be different, in this case an extra "dummy" point is added to either ``signature1`` or ``signature2`` . + + :param distType: Used metric. ``CV_DIST_L1, CV_DIST_L2`` , and ``CV_DIST_C`` stand for one of the standard metrics; ``CV_DIST_USER`` means that a pre-calculated cost matrix ``cost`` is used. + + :param cost: The user-defined :math:`\texttt{size1}\times \texttt{size2}` cost matrix. Also, if a cost matrix is used, lower boundary ``lowerBound`` can not be calculated, because it needs a metric function. + + :param lowerBound: Optional input/output parameter: lower boundary of distance between the two signatures that is a distance between mass centers. The lower boundary may not be calculated if the user-defined cost matrix is used, the total weights of point configurations are not equal, or if the signatures consist of weights only (i.e. the signature matrices have a single column). The user **must** initialize ``*lowerBound`` . If the calculated distance between mass centers is greater or equal to ``*lowerBound`` (it means that the signatures are far enough) the function does not calculate EMD. In any case ``*lowerBound`` is set to the calculated distance between mass centers on return. Thus, if user wants to calculate both distance between mass centers and EMD, ``*lowerBound`` should be set to 0. + + :param flow: The resultant :math:`\texttt{size1} \times \texttt{size2}` flow matrix: :math:`\texttt{flow}_{i,j}` is a flow from :math:`i` th point of ``signature1`` to :math:`j` th point of ``signature2`` . + .. index:: equalizeHist