I have a 2D array that I would like to down sample to compare it to another.
Lets say my array x
is 512x512
, I'd like an array y
128x128
where the elements of y
are build using an interpolation of the values overs 4x4
blocks of x
(this interpolation could just be taking the average, but other methodes, like geometric average, could be interesting)
So far I looked at scipy.ndimage.interpolation.zoom
but I don't get the results I want
>> x = np.arange(16).reshape(4,4)
>> print(x)
[[ 0 1 2 3]
[ 4 5 6 7]
[ 8 9 10 11]
[12 13 14 15]]
>> y = scipy.ndimage.interpolation.zoom(x, 0.5)
>> print(y)
[[ 0 3]
[12 15]]
I expected y
to be
[[ 2.5 4.5]
[10.5 12.5]]
Note that simply setting dtype=np.float32
doesn't solve that ...