Compute the Second Order Derivative of Digital Image with Finite Differences 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 &amp; 1 \\
 -1 &amp; 1 \\
\end{array}
\right)
$$
Then

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

and

$$
I_{xy} = I_y \cdot I_x = \left(
\begin{array}{cc}
 -1 &amp; -1 \\
 1 &amp; 1 \\
\end{array}
\right)\cdot\left(
\begin{array}{cc}
 -1 &amp; 1 \\
 -1 &amp; 1 \\
\end{array}
\right)=\left(
\begin{array}{ccc}
 1 &amp; 0 &amp; -1 \\
 0 &amp; 0 &amp; 0 \\
 -1 &amp; 0 &amp; 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 &amp; 1 \\
 -1 &amp; 1 \\
\end{array}
\right)\cdot\left(
\begin{array}{cc}
 -1 &amp; -1 \\
 1 &amp; 1 \\
\end{array}
\right)=\left(
\begin{array}{ccc}
 -1 &amp; 0 &amp; 1 \\
 0 &amp; 0 &amp; 0 \\
 1 &amp; 0 &amp; -1 \\
\end{array}
\right)
$$
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.