In the program, I read the brightness of the image obtained using imread("img.jpg ", IMREAD_GRAYSCALE), so:
int beg = (int)img.at<uchar>(x, y);
The brightness is read normally. Now I would like to set the brightness of the point, for example to zero (make the point black):
img.at<uchar>(x, y) = (uchar) 0;
I get an error:
OpenCV(4.5.5) Error: Assertion failed ((unsigned)(i 1 * DataType<_Tp>::channels) < (unsigned)(size.p[1] * channels())) in cv::Mat::at, file C:\opencv\build\include\opencv2\core\mat.inl.hpp, line 899
OpenCV(4.5.5) C:\opencv\build\include\opencv2\core\mat.inl.hpp:899: error: (-215:Assertion failed) (unsigned)(i 1 * DataType<_Tp>::channels) < (unsigned)(size.p[1] * channels()) in function 'cv::Mat::at'
As I understand it, there is an assignment error, but I don’t know how to fix it. Please help me.