title: Canny edge detector with kernel size > 7
body: <p>why is it not possible to perform Canny edge detection in OpenCV with a kernel size bigger than 7?</p>
  
  <p>e.g., </p>
  
  <pre><code>// This works
  cv::Canny(src_image, out_edges, th1, 2 * th1, 3);
  cv::Canny(src_image, out_edges, th1, 2 * th1, 7);
  
  // This raises an exception
  cv::Canny(src_image, out_edges, th1, 2 * th1, 9);
  </code></pre>
  
  <p>I know Sobel only takes kernel sizes of 1, 3, 5 or 7. But I've seen papers using kernel size of 9. Is this not possible in OpenCV?</p>
  
  <p><strong>* Edit *</strong></p>
  
  <p>I have been editing the Canny code to support larger kernels. The problem resides in here (canny.cpp):</p>
  
  <pre><code>if (L2gradient)
  {
    low_thresh = std::min(32767.0, low_thresh);
    high_thresh = std::min(32767.0, high_thresh);
    if (low_thresh &gt; 0) low_thresh *= low_thresh;
    if (high_thresh &gt; 0) high_thresh *= high_thresh;
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>if (L2gradient)
  {
    low_thresh = std::min(32767.0, low_thresh);
    high_thresh = std::min(32767.0, high_thresh);
  
    if (low_thresh &gt; 0) low_thresh *= low_thresh;
    if (high_thresh &gt; 0) high_thresh *= high_thresh;
  }
  </code></pre>
  
  <p>I guess this is related to the fact that they are using some shift operation,</p>
  
  <pre><code>#define CANNY_SHIFT 15
  const int TG22 = (int)(0.4142135623730950488016887242097*(1&lt;&lt;CANNY_SHIFT) + 0.5);
  </code></pre>
  
  <p>Thus limiting the precision to 16 bits, therefore the 32767 limit.... How could I fix this?</p>