Ask Your Question

Revision history [back]

EMD vs EMDL1: who is right?

Hello all,

EMD and EMDL1 seem to provide different values for the same signatures. Can anybody explain? You can find my code below.

Thanks!

int main(int argc, char** argv) {

//make signature  
Mat sig1(4, 3, CV_32FC1);
Mat sig2(4, 3, CV_32FC1);

sig1.at< float>(0, 0) = 0.5;
sig1.at< float>(0, 1) = 0;
sig1.at< float>(0, 2) = 0;

sig1.at< float>(1, 0) = 0.5;
sig1.at< float>(1, 1) = 1;
sig1.at< float>(1, 2) = 1;

sig1.at< float>(2, 0) = 0.0;
sig1.at< float>(2, 1) = 1;
sig1.at< float>(2, 2) = 0;

sig1.at< float>(3, 0) = 0.0;
sig1.at< float>(3, 1) = 0;
sig1.at< float>(3, 2) = 1; 


sig2.at< float>(0, 0) = .25;
sig2.at< float>(0, 1) = 0;
sig2.at< float>(0, 2) = 0;

sig2.at< float>(1, 0) = .25;
sig2.at< float>(1, 1) = 1;
sig2.at< float>(1, 2) = 1;

sig2.at< float>(2, 0) = .25;
sig2.at< float>(2, 1) = 1;
sig2.at< float>(2, 2) = 0;

sig2.at< float>(3, 0) = .25;
sig2.at< float>(3, 1) = 0;
sig2.at< float>(3, 2) = 1; 

float emd = cv::EMD(sig1, sig2, CV_DIST_L1); //emd 0 is best matching.   
printf("similarity emd %5.5f %%\n", (1 - emd) * 100);

emd = cv::EMDL1(sig1, sig2); //emd 0 is best matching.   
printf("similarity emd L1 %5.5f %%\n", (1 - emd) * 100);

waitKey(0); // Wait for a keystroke in the window
return 0;

}

EMD vs EMDL1: who is right?

Hello all,

EMD and EMDL1 seem to provide different values for the same signatures. Can anybody explain? You can find my code below.

Thanks!

int main(int argc, char** argv)
{

{

    //make signature  
 Mat sig1(4, 3, CV_32FC1);
 Mat sig2(4, 3, CV_32FC1);

 sig1.at< float>(0, 0) = 0.5;
sig1.at< float>(0, 1) = 0;
sig1.at< float>(0, 2) = 0;

    sig1.at< float>(0, 1) = 0;
    sig1.at< float>(0, 2) = 0;

    sig1.at< float>(1, 0) = 0.5;
sig1.at< float>(1, 1) = 1;
sig1.at< float>(1, 2) = 1;

    sig1.at< float>(1, 1) = 1;
    sig1.at< float>(1, 2) = 1;

    sig1.at< float>(2, 0) = 0.0;
sig1.at< float>(2, 1) = 1;
sig1.at< float>(2, 2) = 0;

    sig1.at< float>(2, 1) = 1;
    sig1.at< float>(2, 2) = 0;

    sig1.at< float>(3, 0) = 0.0;
sig1.at< float>(3, 1) = 0;
    sig1.at< float>(3, 1) = 0;
    sig1.at< float>(3, 2) = 1; 


 sig2.at< float>(0, 0) = .25;
sig2.at< float>(0, 1) = 0;
sig2.at< float>(0, 2) = 0;

    sig2.at< float>(0, 1) = 0;
    sig2.at< float>(0, 2) = 0;

    sig2.at< float>(1, 0) = .25;
sig2.at< float>(1, 1) = 1;
sig2.at< float>(1, 2) = 1;

    sig2.at< float>(1, 1) = 1;
    sig2.at< float>(1, 2) = 1;

    sig2.at< float>(2, 0) = .25;
sig2.at< float>(2, 1) = 1;
sig2.at< float>(2, 2) = 0;

    sig2.at< float>(2, 1) = 1;
    sig2.at< float>(2, 2) = 0;

    sig2.at< float>(3, 0) = .25;
sig2.at< float>(3, 1) = 0;
    sig2.at< float>(3, 1) = 0;
    sig2.at< float>(3, 2) = 1; 

 float emd = cv::EMD(sig1, sig2, CV_DIST_L1); //emd 0 is best matching.   
 printf("similarity emd %5.5f %%\n", (1 - emd) * 100);

 emd = cv::EMDL1(sig1, sig2); //emd 0 is best matching.   
 printf("similarity emd L1 %5.5f %%\n", (1 - emd) * 100);

 waitKey(0); // Wait for a keystroke in the window
 return 0;
}

}