Ask Your Question

Revision history [back]

i want to compare element by element of 2 Mat s1,s2 and put smaller value in 3rd Mat salient. i have put Code below Build Succesfull but then still there is error

Mat downs,ups,s1,s2,m,salient; s1 = ups / downs; s2 = downs / ups;

for (int i = 0; i < ups.cols; i++)
{
    for (int j = 0; j < ups.rows; j++)
    {

        if (s1.at<uchar>(i, j) > s2.at<uchar>(i, j))
        {
            m.at<uchar>(i, j) = s2.at<uchar>(i, j);
        }
        else
        {
            m.at<uchar>(i, j) = s1.at<uchar>(i, j);
        }

        salient.at<uchar>(i, j) = 1 - m.at<uchar>(i, j);
    }
}
click to hide/show revision 2
No.2 Revision

updated 2015-09-13 01:28:50 -0500

berak gravatar image

compare Mat element-wise

i want to compare element by element of 2 Mat s1,s2 and put smaller value in 3rd Mat salient. i have put Code below Build Succesfull but then still there is error

Mat downs,ups,s1,s2,m,salient;
s1 = ups / downs;
s2 = downs / ups;

ups;

    for (int i = 0; i < ups.cols; i++)
{
    {
        for (int j = 0; j < ups.rows; j++)
    {

    {

            if (s1.at<uchar>(i, j) > s2.at<uchar>(i, j))
        {
    {
                m.at<uchar>(i, j) = s2.at<uchar>(i, j);
        }
    }
            else
        {
    {
                m.at<uchar>(i, j) = s1.at<uchar>(i, j);
        }

    }

            salient.at<uchar>(i, j) = 1 - m.at<uchar>(i, j);
    }
    }
    }