How can I access the Elements of an IplImage (single channel and IPL_DEPTH_8U depth).
I want to change the pixel value at a particu
Pixels are stored inside imageData array. So, since your image is single channel you just have to do like:
myimage.imageData[y*myimage.width+x] = 100;
This ensure in imageData the right offset from beginning of buffer, and it's more readable than any other pointer algebra operation.
In N-channels images it's enough to multiply by N the array offset, and add the number of channel to read:
i.e. for an RGB image
myimage.imageData[3*(y*myimage.width+x)+0] = 100; //Red
myimage.imageData[3*(y*myimage.width+x)+1] = 100; //Green
myimage.imageData[3*(y*myimage.width+x)+2] = 100; //Blue
Any optimization to avoid to multiply data to obtain index can be done according to the goal you have to achieve.