title: How to measure gradient and Hessian matrix in matlab over gradient?
body: <p>By wikipedia <a href="http://en.wikipedia.org/wiki/Hessian_matrix" rel="nofollow">http://en.wikipedia.org/wiki/Hessian_matrix</a> , it is defined to be the square matrix of second order partial derivative of a function.</p>
  
  <p>Can anybody tell me if it's correct?</p>
  
  <pre><code>[i,j]=gradient(im);
  filt1=(1./2).*[1,0,-1;0,0,0;1,0,-1];
  filt2=(1./2).*[-1,0,-1;0,0,0;1,0,1];
  ii=(conv2(filt1,i));
  jj=(conv2(filt2,j));
  
  Gx=conv2(ii,im); % Gradient of the image in x-axis
  Gy=conv2(jj,im); % Gradient of the image in y-axis
  
  
  dif_Gx = conv2(f_x,a); % Gradient differentiation of the image in x-axis
  dif_Gy = conv2(f_y,a); % Gradient differentiation of the image in y-axis
  
  % Calculate second derivative
  Gxx = Gx.^2;
  Gyy = Gy.^2;
  Gxy = Gx.*Gy;
  </code></pre>