# Second order directional derivative in image processing

it is all about valley detection in image processing. I would like to find, for a given pixel, direction for higher second order derivative. I am not quite sure what discrete mask/filter I can use to compute directional derivative, along xx, yx, xy, yy. What should I understand with 'direction of higher second order derivative'? is it one of the four xx, yx, xy, yy with maximum filter value? In the end, I am to found loci of extremal height for the signal, in direction along which second order derivative is of greatest magnitude. How to do so? Could you hint at relevant doc?

• Direction for second-order derivative? – meawoppl Sep 7 '12 at 19:08
• Lxx is derivative along direction xx, Lxy along diagonal xy etc... – kiriloff Sep 7 '12 at 19:18
• I'm not sure to understand your question, but I suspect you are looking for eigenvalues and eigenvectors of the Hessian matrix. – Stefano M Sep 7 '12 at 22:14

## 1 Answer

You are looking for the directions of the eigenvectors of the Hessian matrix (i.e., the matrix of second derivatives) that correspond to the largest and smallest eigenvalues. At a local minimum, any function can be developed into a Taylor series $$f(x) \approx f(x_0) + \frac 12 (x-x_0)^T H (x-x_0) = m_2(x)$$ where $H=\nabla^2 f(x_0)$ and where $m_2(x)$ is this local approximation. The directions where $m_2$ curves up the quickest are the directions that correspond to the eigenvectors of the largest eigenvalue of $H$. The directions where $m_2$ grows the slowest (the "valley floor") correspond to the direction of the eigenvector with the smallest eigenvalue of $H$.

• Thanks! my idea is: compute det and trace for hessian, deduce the eigenvalues, compute eigenvectors, and find max on directions of smallest eigenvector. However, to compute det and trace, I need to compute Lxx, Lyy, Lxy, Lyx from the image. This is a very basic question: what filters (in sense of image processing) should I use to get Lxx, Lyy... What is a quick way to find eigenvectors in this simple case? Thanks again. – kiriloff Sep 8 '12 at 10:37
• This should be a standard question for image processing books. For example, you should be able to get $L_{xx}$ as (right neighbor pixel - 2*this pixel + left neighbor pixel) and similar for the other pixels. – Wolfgang Bangerth Sep 8 '12 at 11:51
• : ) yes, sounds good. thanks. would you agree on my method: compute determinant, compute trace, find $\lambda_{1},\lambda_{2}$ and associated eigenvectors (how to do that quickly?), and keep direction of smallest eigenvector, as you mentionned? – kiriloff Sep 8 '12 at 11:59
• Yes, that sounds reasonable. As for computing eigenvalues/eigenvectors, every textbook on linear algebra will do. You only have 2x2 matrices, you can write down by hand the eigenvectors. – Wolfgang Bangerth Sep 9 '12 at 2:37