3
$\begingroup$

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) $$

$\endgroup$
3
$\begingroup$

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.

$\endgroup$
3
  • 1
    $\begingroup$ Ah! I was only flipping the kernel on the x axis only... Actually there is no difference between (Iy * Ix) and (Ix * Iy). Thanks! $\endgroup$ – ciel Jan 12 at 6:15
  • 1
    $\begingroup$ The longer it is means the longer its transient as well. $\endgroup$ – David Feb 19 at 6:56
  • $\begingroup$ @David, You're correct. I will add that. $\endgroup$ – Royi Feb 19 at 6:59

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.