Let's say I have a 5x5 matrix:
arr = np.arange(25).reshape((5,5))
array([[ 0, 1, 2, 3, 4],
[ 5, 6, 7, 8, 9],
[10, 11, 12, 13, 14],
[15, 16, 17, 18, 19],
[20, 21, 22, 23, 24]])
and I want to make a 3x3 matrix out of it by averaging over it.

this should be done in such a way, that the blue pixel should be made out of the included black pixels, the number weighted with the area within the blue pixel.
That means that of the vlaue of the second black pixel (value 1) 3/5(?) should be added to the first blue pixel, 2/5 to the second blue pixel
thanks