Combine 3 separate numpy arrays to an RGB image in Python

前端 未结 5 722
遥遥无期
遥遥无期 2020-12-02 10:19

So I have a set of data which I am able to convert to form separate numpy arrays of R, G, B bands. Now I need to combine them to form an RGB image.

I tried \'Image\

5条回答
  •  一整个雨季
    2020-12-02 11:02

    I don't really understand your question but here is an example of something similar I've done recently that seems like it might help:

    # r, g, and b are 512x512 float arrays with values >= 0 and < 1.
    from PIL import Image
    import numpy as np
    rgbArray = np.zeros((512,512,3), 'uint8')
    rgbArray[..., 0] = r*256
    rgbArray[..., 1] = g*256
    rgbArray[..., 2] = b*256
    img = Image.fromarray(rgbArray)
    img.save('myimg.jpeg')
    

    I hope that helps

提交回复
热议问题