Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The complexity of the pixel-access in Mat.

Hello!

I am new in openCV and try to change colour of some pixels my matrix. if i work with new "Mat::zeros" matrix created by me, my code works (type of elements is CV_8UC1). image description

If i work with some image, code does not work correct. image description

But why? is it specific trait of image's depth or channels? can t get some properties of image like depth and number of channels.

The original image is here.

Please help me to make it clear.

The code for changing colour is:

for (int i = 0; i < img.rows; i++)
        for (int j = 0; j < img.cols; j++)
            if ((i % 20 == 10 && j % 2 == 1) ||
                (j % 50 == 25 && i % 2 == 1))
            {
                img.at<uchar>(i, j) = 255;
            }