Structure Tensor is a matrix in form:

$S=\begin{pmatrix} W \ast I_x^2 & W \ast (I_xI_y)\\ W \ast (I_xI_y) & W \ast I_y^2 \end{pmatrix}$

where $W$ is a smoothing kernel (e.g a Gaussian kernel) and $I_x$ is gradient in the direction of $x$ and so on.

Therefore,size of structure tensor is $2N \times 2M$ (were $N$ is the image height and $M$ is its width). However it is supposed to be $2\times2$ matrix to decompose eigenvalues such that we obtain $\lambda_1$ and $\lambda_2$ as it is mentioned in many papers.

So, how to calculate $S$ matrix?


2 Answers 2


According to this post you have the definition slightly wrong. It's more like:

$$ S(\mathbf{u})=\begin{pmatrix} [W \ast I_x^2](\mathbf{u}) & [W \ast (I_xI_y)](\mathbf{u})\\ [W \ast (I_xI_y)](\mathbf{u}) & [W \ast I_y^2](\mathbf{u}) \end{pmatrix} $$ where $\mathbf{u} = (x,y)$ the location at which $S$ is evaluated.

In other words, the algorithm is to form $W \ast I_x^2$, $W \ast (I_xI_y)$, $W \ast (I_xI_y)$, and $W \ast I_y^2$ which are all $N\times M$ images, and then look at the appropriate pixel in each of them to form the $2\times 2$ matrix $S$.


The $S$ matrix is finally of $2\times2$ the size of the initial image. Gathering it is a bigger image is somehow misleading. You effectively get a $2\times 2$ matrix at each pixel of the original image, by gathering values from the $4$ submatrices at corresponding locations.

Structure tensor provides local information. Do not forget to use smoothed directional derivatives as well when computing $I_x$ and $I_y$. You can for instance compute them with Difference of Gaussians (DoG) operators. More discussion in How do I implement the Structure tensor (in Matlab)? or Structure tensor tutorial.

  • $\begingroup$ Should I calculate the eigenvalues and eigenvectors for each pixel? $\endgroup$
    – Bhoke
    May 26, 2016 at 19:30
  • $\begingroup$ @Bhoke Indeed, orientation is local $\endgroup$ May 26, 2016 at 19:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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