# 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 ?

you simply should

neveriterate over pixelsat all.what is your situation, and what are you trying to achieve ?

what is nColumns, and why is your Mat a large vertical strip ?

Regarding the 1st question: So nColumns is of course the width size. Regarding the 2 last questions: I am trying to translate this line of matlab code:

`ws = [ones(VideoData.Height*VideoData.Width, 1), zeros(VideoData.Height*VideoData.Width, K-1)];`

where K is an integer. That's why I want to set pixels of the 1st column to 1.