How to Correctly mask 3D Array with numpy

后端 未结 2 1282
野的像风
野的像风 2021-01-02 23:36

I\'m trying to mask a 3D array (RGB image) with numpy.

However, my current approach is reshaping the masked array (output below). I have tried to follow the approach

2条回答
  •  梦谈多话
    2021-01-02 23:57

    After finding the following post on loss of dimensions HERE, I have found a solution using numpy.where:

    masked_array = np.where(mask==1, a , 0)

    This appears to work well.

提交回复
热议问题