% computes the hessian to determine whether or not row,col is along 
% an edge. 
%  row >= 2 
%  col >= 2
   %  row <= size(DoG,1)
% A = not_an_edge(DoG,row,col,R)
% 

function A = not_an_edge(DoG, row, col, R)

%   dxdx_kernel = 1/3 * [1 -2 1; 1 -2 1; 1 -2 1];
%   dxdy_kernel = 1/4 * [1 0 -1; 0 0 0; -1 0 1];
%   dydy_kernel = 1/3 * [1 1 1; -2 -2 -2; 1 1 1];

  dxdx_kernel = [1 -2 1; 1 -2 1; 1 -2 1];
  dxdy_kernel = [1 0 -1; 0 0 0; -1 0 1];
  dydy_kernel = [1 1 1; -2 -2 -2; 1 1 1];

  function h = hessian(row,col),
     patch = DoG([row-1:row+1,col-1:col+1]);
     dXdX = mean(sum(patch.*dxdx_kernel,2));
     dXdY = mean(patch.*dxdy_kernel,2);
     dYdY = mean(patch.*dydy_kernel,1);
     h = [dXdX dXdY; dXdY dYdY];
  end;

  H = h(row,col);
  A = (trace(H)/det(H)) < ((R + 1)^2)/R;

end;
