The structure tensor T of an image I is defined to be the outer product of the image gradient vector with itself:
Then this structure tensor is blurred with an averaging filter A to form the linear structure tensor L:
Finally, the robust-to-noise gradient direction can be computed by finding the eigenvector corresponding to the larger eigenvalue of the 2x2 matrix L.
This tutorial will do the above computation of the gradient direction using three SLIMpy linear operators - one that adds noise to the original image, another which takes averages across the image in local windows, and the third which finds a preliminary estimate to the gradient direction using a special 3x3 filter.