Click or drag to resize

Cv2EMD Method (InputArray, InputArray, DistanceTypes, InputArray, Single, OutputArray)

Computes the "minimal work" distance between two weighted point configurations. The function computes the earth mover distance and/or a lower boundary of the distance between the two weighted point configurations.One of the applications described in @cite RubnerSept98, @cite Rubner2000 is multi-dimensional histogram comparison for image retrieval.EMD is a transportation problem that is solved using some modification of a simplex algorithm, thus the complexity is exponential in the worst case, though, on average it is much faster.In the case of a real metric the lower boundary can be calculated even faster (using linear-time algorithm) and it can be used to determine roughly whether the two signatures are far enough so that they cannot relate to the same object.

Namespace:  OpenCvSharp
Assembly:  OpenCvSharp (in OpenCvSharp.dll) Version: 1.0.0
Syntax
public static float EMD(
	InputArray signature1,
	InputArray signature2,
	DistanceTypes distType,
	InputArray cost,
	out float lowerBound,
	OutputArray flow = null
)

Parameters

signature1
Type: OpenCvSharpInputArray
First signature, a \f$\texttt{size1}\times \texttt{dims}+1\f$ 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.The weights must be non-negative and have at least one non-zero value.
signature2
Type: OpenCvSharpInputArray
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. The weights must be non-negative and have at least one non-zero value.
distType
Type: OpenCvSharpDistanceTypes
Used metric.
cost
Type: OpenCvSharpInputArray
User-defined size1 x size2 cost matrix. Also, if a cost matrix is used, lower boundary lowerBound cannot be calculated because it needs a metric function.
lowerBound
Type: SystemSingle
Optional input/output parameter: lower boundary of a 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(the signature matrices have a single column). You ** 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 you want to calculate both distance between mass centers and EMD, \*lowerBound should be set to 0.
flow (Optional)
Type: OpenCvSharpOutputArray
Resultant size1 x size2 flow matrix: flow[i,j] is a flow from i-th point of signature1 to j-th point of signature2.

Return Value

Type: Single

[Missing <returns> documentation for "M:OpenCvSharp.Cv2.EMD(OpenCvSharp.InputArray,OpenCvSharp.InputArray,OpenCvSharp.DistanceTypes,OpenCvSharp.InputArray,System.Single@,OpenCvSharp.OutputArray)"]

See Also