How to extract R,G,B values with numpy into seperate arrays

后端 未结 3 798
眼角桃花
眼角桃花 2021-01-02 16:37

Suppose I have a image with some dimension (1920, 1080, 3) , I want to extract out R,G,B values into separate arrays R , G, B . I tried to do it li

3条回答
  •  时光说笑
    2021-01-02 16:58

    dsplit it.

    import numpy as np
    
    def channelSplit(image):
        return np.dsplit(image,image.shape[-1])
    
    [B,G,R]=channelSplit(image)
    

    This works for RGB or RGBA images.

提交回复
热议问题