Canny Edge Detection



This program implements Canny edge detection with the use OpenCV's cvCanny function. The purpose is to get a glimpse of how low/high thresholds and mask size affect the effect of Canny edge detection, not the implementation of Canny algorithm per se.

1. Code/Program (Usage):





2. Result
































 

3. Discussion.

  • Because of the GUI interface, Canny edge detection has been taken on the two input images under various parameter domains: mask size, low /high thresholds. It can be divided into two cases: mask size with normal value (3), and with a relatively large value (5).
  • Under the case with large mask size, very big high threshold is needed. It is strange that OpenCV has NOT provided help info on how to choose a reasonable low/high threshold domain.  Wild guess seems to be the only way. But with the help of GUI slidebars we can quickly find the best low/high thresholds. Following animated image shows such an effect.
  • Much more detailed (smaller) edge can be detected with a relatively big mask size than with small mask size.
  • For a certain mask size, the high threshold is a more important factor than low threshold.
  • For a certain mask size and a chosen high threshold,  the low threshold can fine-tuen the coarse edge detected from the high threshold.
  • It seems the best edge detection happens at high-threshold = 2 * low-threshold.