Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

"It does not work." -- no wonder. well, almost everything is wrong in you current attempt.

  1. if your Mat is of type 8UC1(single channel), initializing it with a 3 channel Scalar(0,255,0) does not make any sense (only the 1st 0 will be used.)

  2. you must access it as: M.at<uchar>(y,x) , not as M.at<double>()

  3. if your Mat has a single row only, it must be M.at<uchar>(0,i) , using 1 as index is already out of bounds.

  4. " i need to access and change the value one by one." -- this is clearly an anti-pattern in opencv. 99% of all cases can be solved faster and more safe by using a high-level builtin function. try to learn opencv, not to defeat it.