Ask Your Question
0

EMD vs EMDL1: who is right?

asked 2015-09-17 03:50:11 -0600

updated 2018-04-27 04:24:08 -0600

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;
}
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2018-04-27 03:53:05 -0600

pierre_w gravatar image

Hi,

These two functions do not compute the same thing : cv::EMD(<params>) takes the point's coordinates into account whereas EMDL1(<params>) only uses the weights. Please refer to the documentation: EMDL1, EMD.

Please also read the documentation before posting, as this is a duplicate of this question on the same forum.

Hope this helps.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-09-17 03:50:11 -0600

Seen: 361 times

Last updated: Apr 27 '18