<p>In mathematics, the structure tensor, also referred to as the second-moment matrix, is a matrix derived from the gradient of a function. It summarizes the predominant directions of the gradient in a specified neighborhood of a point, and the degree to which those directions are coherent. The structure tensor is often used in image processing and computer vision.
For a function  of two variables p=(x,y), the structure tensor is the 2×2 matrix
where  and  are the partial derivatives of  with respect to x and y; the integrals range over the plane ; and w is some fixed "window function", a distribution on two variables. Note that the matrix Sw is itself a function of p=(x,y).
The formula above can be written also as , where  is the matrix-valued function defined by
If the gradient  of  is viewed as a 1×2 (single-row) matrix, the matrix  can be written as the matrix product , where  denotes the 2×1 (single-column) transpose of the gradient. (Note however that the structure tensor  cannot be factored in this way.)
In image processing and other similar applications, the function  is usually given as a discrete array of samples , where p is a pair of integer indices. The 2D structure</p>