title: Non-max suppression
body: <p>We've learned that you can get the gradient direction with <code>atan(dy/dx)</code> which is the direction orthogonal to the edge.
  Now we had a homework where we were supposed to discretize this direction into four classes (x- and y-direction and both diagonals) and then check both pixel neighbors in the best matching direction for <strong>non-max suppression</strong>.</p>
  
  <p>I didn't fully get the solution though. Obviously we had four cases:</p>
  
  <ol>
  <li><p><code>abs(angle) &lt; pi/8</code>, so the gradient (roughly) points in x-direction, thus we check <code>img(i, j-1)</code> and <code>img(i, j+1)</code> (assuming the image origin is in the top left)</p></li>
  <li><p><code>angle &gt; pi/8 &amp;&amp; angle &lt;= 3*pi/8</code>, so the gradient points to the top right. Now I thought we need to check <code>img(i-1, j+1)</code> and <code>img(i+1, j-1)</code> but instead we check <code>img(i-1, j-1)</code> and <code>img(i+1, j+1)</code> which seems like the orthogonal diagonal.</p></li>
  </ol>
  
  <p>The other two cases are equivalent. I tried to change this but then the edges really look weird so this seems correct but I don't understand why.</p>
  
  <p>Can someone explain this to me?</p>