title: How to compute the Structure Tensor of a 2D array?
body: <p>How does one compute structure tensors from a 2D array (i.e., structure tensor field)?</p>
  
  <p>I can't figure out what I'm doing wrong in my implementation.  In my case the 2D array is a 2D grey-scale image, and here is a general overview of what I'm doing using C++ and Eigen:</p>
  
  <pre><code>// the 2D grey-scale image, represented by a 2D array of doubles
  ArrayXXd img;
  
  // compute the gradient vector field, which produces a 2D array of 2D vectors
  typedef Array&lt;Vector2d, Dynamic, Dynamic&gt; ArrayXXv2;
  ArrayXXv2 g = gvf(img);
  
  // compute the outer-product of each element in g to get a 2x2 matrix, e.g.,
  Matrix&lt;double, 2, 2&gt; st00 = g(0,0) * g(0,0).transpose();
  </code></pre>
  
  <p>st00 is now the structure tensor of img(0,0), is that not so?</p>