How to filter 3D array with a 2D mask

I have a (m,n,3) array data and I want to filter its values with a (m,n) mask to receive a (x,3) output array. The code below works, but how can I replace the for loop with a more efficient alternative? import numpy as np data = np.array([ [[11, 12, 13], [14, 15, 16], [17, 18,… Read More How to filter 3D array with a 2D mask