title: Accessing certain pixel RGB value in openCV
body: <p>I have searched internet and stackoverflow thoroughly, but I haven't found answer to my question:</p>
  
  <p>How can I get/set (both) RGB value of certain (given by x,y coordinates) pixel in OpenCV? What's important-I'm writing in C++, the image is stored in cv::Mat variable. I know there is an IplImage() operator, but IplImage is not very comfortable in use-as far as I know it comes from C API.</p>
  
  <p><strong>Yes, I'm aware that there was already this <a href="https://stackoverflow.com/questions/4742251/pixel-access-in-opencv-2-2">Pixel access in OpenCV 2.2</a> thread, but it was only about black and white bitmaps.</strong></p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Thank you very much for all your answers. I see there are many ways to get/set RGB value of pixel. I got one more idea from my close friend-thanks Benny! It's very simple and effective. I think it's a matter of taste which one you choose.</p>
  
  <pre><code>Mat image;
  </code></pre>
  
  <p>(...)</p>
  
  <pre><code>Point3_&lt;uchar&gt;* p = image.ptr&lt;Point3_&lt;uchar&gt; &gt;(y,x);
  </code></pre>
  
  <p>And then you can read/write RGB values with:</p>
  
  <pre><code>p-&gt;x //B
  p-&gt;y //G
  p-&gt;z //R
  </code></pre>