Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

asked 2017-03-28 06:27:05 -0600

Nbb gravatar image

how to efficiently scan matrix this way ?

For each point, I scan the right and bottom all the way down, then I move diagonally and continue. It is extremely difficult to do this with pointer access. I was wondering if anyone has any suggestion.

image description

how to efficiently scan matrix this way ?

For each point, I scan the right and bottom all the way down, then I move diagonally and continue. It is extremely difficult to do this with pointer access. I was wondering if anyone has any suggestion.

//diagonal scan
for (int i = 0; i < std::min(n_cols, n_rows); i = i + n_rows*n_channels + 1)
{
    uchar*p = color.ptr<uchar>(i / 3);
    int* l = label.ptr<int>(i / 3);

    cout << l[0] << " "; cin.get();

    ////right scan
    //for (int j = 0; j < n_cols - i; j++)
    //{

    //}

    ////bottom scan
    //for (int j = 0; j < n_rows - i; j++)
    //{

    //}
}

image description

how to efficiently scan matrix this way ?

For each point, I scan the right and bottom all the way down, then I move diagonally and continue. It is extremely difficult to do this with pointer access. I was wondering if anyone has any suggestion.

//diagonal scan
for (int i = 0; i < std::min(n_cols, n_rows); n_cols * n_rows * n_channels; i = i + n_rows*n_channels + 1)
{
    //pointer to color mat (cv::Vec3b)
    uchar*p = color.ptr<uchar>(i / 3);
    //pointer to label mat (int)
    int* l = label.ptr<int>(i / 3);

    cout << l[0] << " "; cin.get();

    ////right scan
    //for (int j = 0; j < n_cols - i; j++)
    //{

    //}

    ////bottom scan
    //for (int j = 0; j < n_rows - i; j++)
    //{

    //}
}

image description