Ask Your Question

Revision history [back]

I don't think you can do it with only one function in opencv but you can do like this:

    Mat a = (Mat_<float>(3, 3) << 1, 2, 3, 4, 5, 6, 7, 8, 9);
    Mat b = (Mat_<float>(3, 3) << 9, 8, 7, 6, 5, 4, 3, 2, 1);
    Mat mask=a<b;
    Mat dst;
    min(a, b, dst);
    cout << " a = " << a << "\n";
    cout << " b = " << b << "\n";
    cout << " mask = " << mask << "\n";
    cout << " dst = " << dst << "\n";

and results are

a = [1, 2, 3; 4, 5, 6; 7, 8, 9] b = [9, 8, 7; 6, 5, 4; 3, 2, 1] mask = [255, 255, 255; 255, 0, 0; 0, 0, 0] dst = [1, 2, 3; 4, 5, 4; 3, 2, 1]

I don't think you can do it with only one function in opencv but you can do like this:

    Mat a = (Mat_<float>(3, 3) << 1, 2, 3, 4, 5, 6, 7, 8, 9);
    Mat b = (Mat_<float>(3, 3) << 9, 8, 7, 6, 5, 4, 3, 2, 1);
    Mat mask=a<b;
    Mat dst;
    min(a, b, dst);
    cout << " a = " << a << "\n";
    cout << " b = " << b << "\n";
    cout << " mask = " << mask << "\n";
    cout << " dst = " << dst << "\n";

and results are

 a = [1, 2, 3;
 4, 5, 6;
 7, 8, 9]
 b = [9, 8, 7;
 6, 5, 4;
 3, 2, 1]
 mask = [255, 255, 255;
 255,   0,   0;
   0,   0,   0]
 dst = [1, 2, 3;
 4, 5, 4;
 3, 2, 1]

1]