3
$\begingroup$

For an image $I$, its first order derivatives can be computed using several oprators, such as $$K_{sobel} = \left[ \begin{array}{ccc} -1 &0 &1 \\ -2 &0 &2 \\ -1 &0 &1 \end{array}\right]$$ $$I_{x} = I * K_{sobel},\ I_{y} = I * K_{sobel}.T$$. And to compute the second order derivatives $(I_{xx}, I_{yy}, I_{xy})$, I can apply $K_{sobel}$ twice on $I$, however, I wonder are there any kernels which can be applied once to get the second order derivatives.

Here is what I tried, I made up 2 kernels, $$K_{xx} = \left[ \begin{array}{ccc} 0 &0 &0 \\ 2 &-4 &2 \\ 0 &0 &0 \end{array}\right]$$ $$K_{yy} = \left[ \begin{array}{ccc} 0 &2 &0 \\ 0 &-4 &0 \\ 0 &2 &0 \end{array}\right]$$ and $I_{xx} = I * K_{xx},\ I_{yy} = I * K_{yy}$, they look pretty much the same as twice-applied-sobel results, but I failed to find a good kernel for $I_{xy}$, I need your help, any idea is appreciated.

$\endgroup$
5
$\begingroup$

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 & 0 & 1 \\ -2 & 0 & 2 \\ -1 & 0 & 1 \\ \end{array} \right) * \left( \begin{array}{ccc} -1 & 0 & 1 \\ -2 & 0 & 2 \\ -1 & 0 & 1 \\ \end{array} \right)=\left( \begin{array}{ccccc} 1 & 0 & -2 & 0 & 1 \\ 4 & 0 & -8 & 0 & 4 \\ 6 & 0 & -12 & 0 & 6 \\ 4 & 0 & -8 & 0 & 4 \\ 1 & 0 & -2 & 0 & 1 \\ \end{array} \right)$

And for $I_{xy}$:

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

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

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

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

$\endgroup$
  • $\begingroup$ Hi. Would you mind adding a couple of instruction steps for how to get from [K]*[K] to the second order kernel? I tried on paper but could not figure out how to derive the weights in the 5x5 matrix.. $\endgroup$ – Pa_ Mar 1 '15 at 11:48
  • $\begingroup$ This might sound stupid, but this is not matrix multiplication, what is this ?? From the answer post $\endgroup$ – user16217 Jun 11 '15 at 23:56
  • $\begingroup$ @SamChan: It's discrete convolution (en.wikipedia.org/wiki/Convolution#Discrete_convolution) $\endgroup$ – Niki Estner Jun 12 '15 at 6:22
0
$\begingroup$

What you are looking for is the so-called "Laplacian operator" (http://en.wikipedia.org/wiki/Laplace_operator and http://en.wikipedia.org/wiki/Discrete_Laplace_operator). In image processing, people often use the Laplacian of Gaussian, which is simply the difference between the two results of convolving one input image with two different Gaussian kernels. You may check details here (http://fourier.eng.hmc.edu/e161/lectures/gradient/node9.html).

$\endgroup$
  • 3
    $\begingroup$ First: The Laplacian is Lxx + Lyy, not Lxy. Second: Laplacian of Gaussian (LoG) and Difference of Gaussian (DoG) are not the same. DoG can be used to approximate LoG, because the result is similar, but not the same. $\endgroup$ – Niki Estner Sep 4 '13 at 17:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.