Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Problem setting pixel value

I know this is a well known topic but for all the solutions I tried (major of them from stack overflow Q&A), I cannot set a pixel value as I want.

Given this code:

Mat sgWs = Mat(frameFixedSize.height * frameFixedSize.width, nColumns, CV_8UC1);
for(uint32_t x = 0; x < (uint32_t) frameFixedSize.height; x++)
{
    for(uint32_t y = 0; y < (uint32_t) frameFixedSize.width; y++)
    {
        if (!y)
            sgWs.at<uchar>(x, y) = 1;
    }
}

the pixel values are not set to one. The istruction:

if (!y)
     sgWs.at<cv::Vec3b>(y,x)[0] = 1;

neither works. So how do I have to change my code to make it works ?