Converting Numpy Array to OpenCV Array

后端 未结 3 1547
半阙折子戏
半阙折子戏 2020-12-08 04:01

I\'m trying to convert a 2D Numpy array, representing a black-and-white image, into a 3-channel OpenCV array (i.e. an RGB image).

Based on code samples and the docs

3条回答
  •  一个人的身影
    2020-12-08 04:56

    The simplest solution would be to use Pillow lib:

    from PIL import Image
    
    image = Image.fromarray(.astype(np.uint8))
    

    And you can use it as an image.

提交回复
热议问题