来自维基百科http://en.wikipedia.org/wiki/Hessian_matrix,它被定义为函数的二阶偏导数的方阵。如何在梯度上测量matlab中的梯度和Hessian矩阵?
有人可以告诉我它是否正确吗?
[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;