4

I was looking for how to compute second order derivative of an image and came across the question kernels to Compute Second Order Derivative of Digital Image. In the top voted answer, it gives an example to get $3\times 3$ kernel $I_{xx}$ and $I_{xy}$. The 1st order derivative filter is defined as $$ \left( \begin{array}{cc} -1 & 1 \\ -1 & 1 \\ \end{array} \right) $$

Then

$$ I_{xx} = I_x \cdot I_x = \left( \begin{array}{cc} -1 & 1 \\ -1 & 1 \\ \end{array} \right)\cdot\left( \begin{array}{cc} -1 & 1 \\ -1 & 1 \\ \end{array} \right)=\left( \begin{array}{ccc} 1 & -2 & 1 \\ 2 & -4 & 2 \\ 1 & -2 & 1 \\ \end{array} \right) $$

and

$$ I_{xy} = I_y \cdot I_x = \left( \begin{array}{cc} -1 & -1 \\ 1 & 1 \\ \end{array} \right)\cdot\left( \begin{array}{cc} -1 & 1 \\ -1 & 1 \\ \end{array} \right)=\left( \begin{array}{ccc} 1 & 0 & -1 \\ 0 & 0 & 0 \\ -1 & 0 & 1 \\ \end{array} \right) $$

The computation of $I_{xx}$ makes sense to me, however, for $I_{xy}$, shouldn't it be defined as below?

$$ I_{xy} = I_x \cdot I_y = \left( \begin{array}{cc} -1 & 1 \\ -1 & 1 \\ \end{array} \right)\cdot\left( \begin{array}{cc} -1 & -1 \\ 1 & 1 \\ \end{array} \right)=\left( \begin{array}{ccc} -1 & 0 & 1 \\ 0 & 0 & 0 \\ 1 & 0 & -1 \\ \end{array} \right) $$

Royi
  • 33,983
  • 4
  • 72
  • 179
ciel
  • 43
  • 4

1 Answers1

4

Pay attention that convolution mean flipping the kernel both on the x and y axis.
Hence the first element is a multiplication of $ -1 \cdot -1 $ which yields $ 1 $ as in the answer in the original post.

Pay attention that this is a discrete approximation of the gradient based on Finite Differences. This specific one is based on the Sobel 1st derivative filter.
In Finite Differences Coefficients you may find more variations.
As usual, the longer the filter the better the accuracy of the approximation with longer tarnsients.

Royi
  • 33,983
  • 4
  • 72
  • 179