I've loaded an RGB image with PIL/OpenCV, and I'd like convert all its channels into a single 1x(3*width*height) sequence into order to feed it to an ANN. I found I can simply do:
rlist = []
glist = []
blist = []
for i in xrange(im.width):
for j in xrange(im.height):
r,g,b = im[i,j]
rlist.append(r)
glist.append(g)
blist.append(b)
img_vec = rlist + blist + glist
But obviously this is horribly inefficient. Is there a faster way with some internal OpenCV/numpy routine?