I don't know what your image_RGB structure looks like. But the output seems like you mix the image types CV_8UC1 and CV_8UC3 when accessing the individual elements. Try your code with gray-scale images first, then use color images.