Does anyone know how I can compute the jacobian matrix numerically in
matlab?
So, I have the following. A 100x100 image and at each pixel, I have a
2 element gradient vector. What I would like to do is compute the
jacobian at each pixel position.
Does anyone know how I can do that? I do not have the symbolic math
toolbox, so I cannot use the built-in jacobian function :(
Thanks,
Anja
[FX, FY] = gradient(fun); % Gradient of the scalar field
T = cat(3, FX, FY);
[TTX, TTY]=gradient(T); % Compute gradient of the gradient
TT=cat(3, TTX, TTY); % This should be the hessian or jacobian of the
gradient
Does this seem correct?
Thanks,
Anja
% Optimized rotation invariant Hessian 3x3
% Reference: D. Kroon, 2009, Short Paper University Twente, Numerical Optimization of Kernel Based Image Derivatives
Hx = [ 17 61 17 ;
0 0 0 ;
-17 -61 -17 ];
% Calculate image Derivatives
Lx = conv2(img, Hx, 'same');
Ly = conv2(img, Hx', 'same');
Lx and Ly, should be images that contain the derivative values at each pixel position
According to
http://www.mathworks.de/help/techdoc/ref/gradient.html
fun must be a two-dimensional matrix in order to calculate FX and FY.
So evaluate your scalar function on a rectangle with spacings dx and
dy.
Then two subsequent calls to the gradient function
(first with the matrix F and then with the two matrices FX and FY)
will give you the Hessian.
Don't forget to include the spacings dx and dy !
Best wishes
Torsten.
This is sort of what I am doing. fun is an image, so a 2D matrix with
scalar values at each point and the gradient call does the job and
then I am calling gradient again after concatenating FX and FY.
Thanks,
Anja