I have a multidimensionnal array "test[:,:,:]" and i would like to get averaged values on the test.shape[0] dimension for every 4 "frames" i would like to keep the same dimensions of my array and substitute the 4 values by the mean value.
As example:
test=np.array([[[ 2., 1., 1.],
[ 1., 1., 1.]],
[[ 3., 1., 1.],
[ 1., 1., 1.]],
[[ 3., 1., 1.],
[ 1., 1., 1.]],
[[ 5., 1., 1.],
[ 1., 1., 1.]],
[[ 2., 1., 1.],
[ 1., 1., 1.]],
[[ 3., 1., 1.],
[ 1., 1., 1.]],
[[ 3., 1., 1.],
[ 1., 1., 1.]],
[[ 5., 1., 1.],
[ 1., 1., 1.]],
[[ 2., 1., 1.],
[ 1., 1., 1.]]])
for i in range(test.shape[0]-1,4):
test_mean = (test[i,:,:]+test[i+1,:,:]+test[i+2,:,:]+test[i+3,:,:])/4.
But, i don't keep the same dimension...what is the best way to do that?
test, do you want a (9, 2, 3) array as a result, a (2, 2, 3) array, or something else? We could help you best if you could explicitly add the correct result fortest_meanfor reference.