Discarding alpha channel from images stored as Numpy arrays

后端 未结 1 1663
[愿得一人]
[愿得一人] 2021-02-05 02:33

I load images with numpy/scikit. I know that all images are 200x200 pixels.

When the images are loaded, I notice some have an alpha channel, and therefore have shape (20

1条回答
  •  说谎
    说谎 (楼主)
    2021-02-05 03:11

    Just slice the array to get the first three entries of the last dimension:

    image_without_alpha = image[:,:,:3]
    

    0 讨论(0)
提交回复
热议问题