Combine 3 separate numpy arrays to an RGB image in Python

rgb = np.dstack((r,g,b))  # stacks 3 h x w arrays -> h x w x 3

To also convert floats 0 .. 1 to uint8 s,

rgb_uint8 = (np.dstack((r,g,b)) * 255.999) .astype(np.uint8)  # right, Janna, not 256

Leave a Comment