images are not bidimensional in memory, they are a 1 dimension array and you access them by calculating the position in the array from the x and y, the formula is x + y * w. or simply by incrementing the position by 1 (or the number of channels in the image) to iterate through the whole image,
the easiest way to work with pixels in OF is by using ofPixels to do the allocation and iterate through the pixels:
ofPixels pixColor, pixBlack;
pixColor.allocate(w,h,OF_PIXELS_RGB);
pixBlack.allocate(w,h,OF_PIXELS_GRAY);
for(auto line: pixColor){
for(auto pixel: line){
pixel[0] = // red
pixel[1] = // green
pixel[2] = // blue
}
}
if you want to simply copy an image you can just use =
like pixels1 = pixels2