Sliding window reduce multidimensional numpy array

Viewed 32

I want to iterate through an MxNxC NumPy array using a size KxKxC sliding window. This window should pass each block to a defined function such that it applies some generic operations to the elements in the slice and return a scalar. Therefore, the output will be MxN, where the last dimension of the input is reduced. Following is an illustration of the process:

Sliding window reduce

During some research, I came across Scipy's generic filter; however, it doesn't reduce the input array; otherwise, it would be perfect. Do you guys have any tips on how I can tackle this?

0 Answers
Related