Sorry to reply to my own post, but I'm okay with this now. The script was really quite straightforward to write.
The syntax
B(2,2) = (A(1,2)+A(3,2)+A(2,1)+A(2,3))/4
B(2,3) = (A(1,3)+A(3,3)+A(2,2)+A(2,4))/4
does work fine. It's simple to modify the matrix in this way, and then loop it for...