kernels to compute second order derivative of digital image
Convolution $(*)$ is associative, so

$I_{xx} = K_{sobel} * (K_{sobel} * I) = (K_{sobel} * K_{sobel}) * I$

meaning the convolution of a 1st order Sobel filter kernel with another 1st order Sobel filter gives the filter kernel for a second order filter. So e.g. a 2nd order horizontal Sobel filter kernel is:

$\left(
\begin{array}{ccc}
 -1 &amp; 0 &amp; 1 \\
 -2 &amp; 0 &amp; 2 \\
 -1 &amp; 0 &amp; 1 \\
\end{array}
\right) * \left(
\begin{array}{ccc}
 -1 &amp; 0 &amp; 1 \\
 -2 &amp; 0 &amp; 2 \\
 -1 &amp; 0 &amp; 1 \\
\end{array}
\right)=\left(
\begin{array}{ccccc}
 1 &amp; 0 &amp; -2 &amp; 0 &amp; 1 \\
 4 &amp; 0 &amp; -8 &amp; 0 &amp; 4 \\
 6 &amp; 0 &amp; -12 &amp; 0 &amp; 6 \\
 4 &amp; 0 &amp; -8 &amp; 0 &amp; 4 \\
 1 &amp; 0 &amp; -2 &amp; 0 &amp; 1 \\
\end{array}
\right)$

And for $I_{xy}$:

$\left(
\begin{array}{ccc}
 -1 &amp; 0 &amp; 1 \\
 -2 &amp; 0 &amp; 2 \\
 -1 &amp; 0 &amp; 1 \\
\end{array}
\right) * \left(
\begin{array}{ccc}
 -1 &amp; -2 &amp; -1 \\
 0 &amp; 0 &amp; 0 \\
 1 &amp; 2 &amp; 1 \\
\end{array}
\right)=\left(
\begin{array}{ccccc}
 1 &amp; 2 &amp; 0 &amp; -2 &amp; -1 \\
 2 &amp; 4 &amp; 0 &amp; -4 &amp; -2 \\
 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \\
 -2 &amp; -4 &amp; 0 &amp; 4 &amp; 2 \\
 -1 &amp; -2 &amp; 0 &amp; 2 &amp; 1 \\
\end{array}
\right)$

If you want a 3x3 kernel, you can use the 1st order derivative filter $\left(
\begin{array}{cc}
 -1 &amp; 1 \\
 -1 &amp; 1 \\
\end{array}
\right)$, which leads to the second order filters:

$\left(
\begin{array}{cc}
 -1 &amp; 1 \\
 -1 &amp; 1 \\
\end{array}
\right)*\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

$\left(
\begin{array}{cc}
 -1 &amp; -1 \\
 1 &amp; 1 \\
\end{array}
\right)*\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)$