Here is a cleaner approach using [``Developer`PartitionMap``][1].

(`m` as defined in my first answer.)

 fn[b_] := If[# != 0, #, Total[1 - Unitize[b + 2], 2]] & @ b[[2, 2]]
 
 Developer`PartitionMap[fn, m, {3, 3}, 1, 2] // MatrixForm

$\left(
\begin{array}{cccccccccc}
 -1 & -1 & -1 & -1 & -1 & -1 & -1 & -1 & -1 & -1 \\
 -1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & -1 \\
 -1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & -1 \\
 -1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & -1 \\
 -1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & -2 \\
 -1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & -1 \\
 -1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & -1 \\
 -1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & -1 \\
 -1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & -1 \\
 -1 & -1 & -1 & -1 & -1 & -1 & -1 & -1 & -1 & -1 \\
\end{array}
\right)$




 [1]: http://reference.wolfram.com/language/Developer/ref/PartitionMap.html