Method EMD
- Namespace
- OpenCvSharp
- Assembly
- OpenCvSharp.dll
EMD(InputArray, InputArray, DistanceTypes)
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.
public static float EMD(InputArray signature1, InputArray signature2, DistanceTypes distType)
Parameters
signature1InputArrayFirst 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.
signature2InputArraySecond 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.
distTypeDistanceTypesUsed metric.
Returns
EMD(InputArray, InputArray, DistanceTypes, InputArray)
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.
public static float EMD(InputArray signature1, InputArray signature2, DistanceTypes distType, InputArray cost)
Parameters
signature1InputArrayFirst 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.
signature2InputArraySecond 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.
distTypeDistanceTypesUsed metric.
costInputArrayUser-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.
Returns
EMD(InputArray, InputArray, DistanceTypes, InputArray, out float, 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.
public static float EMD(InputArray signature1, InputArray signature2, DistanceTypes distType, InputArray cost, out float lowerBound, OutputArray flow = default)
Parameters
signature1InputArrayFirst 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.
signature2InputArraySecond 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.
distTypeDistanceTypesUsed metric.
costInputArrayUser-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.
lowerBoundfloatOptional 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.
flowOutputArrayResultant size1 x size2 flow matrix: flow[i,j] is a flow from i-th point of signature1 to j-th point of signature2.