function g = neuro(ix,J,w);
kappa=0.3;
[n,m]=size(w);
%c=zeros(n,m);
i=ix(1);
j=ix(2);
g=0;
cnt=0;
for k=max(i-1,1):min(i+1,n),
    for l=max(j-1,1):min(j+1,m),
        iy=[k l];
        if any(iy~=ix),
            dij=iy-ix;
            if dij(1)==dij(2),
                ij=2*min(ix,iy);
            else
                ij=ix+iy;
            end;
            if J(ij(1),ij(2)),
                g=g+kappa*w(k,l);
                cnt=cnt+1;
            end;
        end;
    end;
end;
if cnt,
    g=g./cnt+w(i,j);
else
    g=w(i,j);
end;
fprintf('g=%f  w=%f  cnt=%d\n', g, w(i,j), cnt);
