I searched the internet and stackoverflow completely, but I did not find the answer to my question:
How can I get / set (both) the RGB value of the specific (given by x, y coordinates) in OpenCV? What is important - I write in C ++, the image is stored in the variable cv :: Mat. I know that there is an IplImage () operator, but IplImage is not very convenient to use - as far as I know, it comes from the C API.
Yes, I know that this pixel access was already in OpenCV 2.2 , but it was only about black and white bitmaps.
EDIT:
Thanks so much for all your answers. I see that there are many ways to get / set the RGB value of a pixel. I have another idea from my close friend - thanks Benny! It is very simple and effective. I think it is a matter of taste that you choose.
Mat image;
(...)
Point3_<uchar>* p = image.ptr<Point3_<uchar> >(y,x);
And then you can read / write RGB values ββwith:
p->x
c ++ opencv
Wookie88 Jan 19 '12 at 20:35 2012-01-19 20:35
source share