a1 a2 a3
   a8 [color=FF0000]a[/color]  a4
   a7 a6 a5

请问在如上所示的a的邻域窗口内怎么编写求窗口的熵、方差和a在x方向及y方向的梯度的代码?