Partial derivative of a grayscale image using MATLAB

2.9k views Asked by At

While I was searching for Hessian matrix, I read about partial derivative of an image. I am confused and I could not imagine any meaning of a derivative of an image.

How can I calculate the partial derivatives of an image?

enter image description here

1

There are 1 answers

0
AudioBubble On BEST ANSWER

First, your grayscale image should be represented as a matrix, with entries corresponding to brightness.
Then use numerical gradient twice, like this:

I = [1 2 3 4 ; 6 4 2 2 ; 4 5 0 7 ; 2 4 3 1];  % image 
[Ix, Iy] = gradient(I);                       % first order partials
[Ixx, Ixy] = gradient(Ix);                    % second order partials
[Iyx, Iyy] = gradient(Iy);                    % second order partials

Incidentally, Ixy will be the same as Iyx; the mixed partial derivatives are equal (this holds for derivatives in calculus, too).

Matlab documentation explains the meaning of the numerical gradient:

FX corresponds to ∂F/∂x, the differences in x (horizontal) direction. FY corresponds to ∂F/∂y, the differences in the y (vertical) direction.