First time here? Check out the FAQ!

Ask Your Question
0

EMD vs EMDL1: who is right?

asked Sep 17 '15

updated Apr 27 '18

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;
}
Preview: (hide)

1 answer

Sort by » oldest newest most voted
1

answered Apr 27 '18

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.

Preview: (hide)

Question Tools

1 follower

Stats

Asked: Sep 17 '15

Seen: 373 times

Last updated: Apr 27 '18