next up previous contents
Next: Corner detection Up: Feature detection Previous: Displaying an edge map   Contents

The Canny edge detector

      #include <gandalf/vision/canny_edge.h>
The Canny edge detector is described in [#!Canny:PAMI86!#]. It involves three stages:
  1. Directional gradients are computed by smoothing the image and numerically differentiating the image to compute the $x$ and $y$ gradients.
  2. Non-maximum suppression finds peaks in the image gradient.
  3. Hysteresis thresholding locates edge strings.
Here is a code fragment illustrating the use of the Canny edge detector. More example code can be found in the vision_test.c test program.
      Gan_Image *pImage; /* declare image from which edges will be computed */
      Gan_Mask1D *pFilter; /* convolution mask */
      Gan_EdgeFeatureMap EdgeMap; /* declare edge map */

      /* ... fill image ... */

      /* initialise edge map */
      gan_edge_feature_map_form ( &EdgeMap,
                                  10000,   /* initial limit on number of edges */
                                    500 ); /* initial limit on number of edge strings */

      /* create convolution mask */
      pFilter = gan_gauss_mask_new ( GAN_FLOAT, 1.0, 9, 1.0, NULL );
      
      /* apply Canny edge detector */
      gan_canny_edge_q ( pImage, /* input image */
                         NULL, /* or binary mask of pixels to be processed */
                         pFilter, pFilter, /* image smoothing filters */
                         0.008, /* lower edge strength threshold */
                         0.024, /* upper edge strength threshold */
                         10, /* threshold on string length */
                         NULL, /* or affine coordinate transformation */
                         NULL, /* or pointer to camera structure defining
                                  distortion model */
                         NULL, /* or parameters of local feature map */
                         &EdgeMap ); /* result edge map */

      /* free convolution mask and edge map */
      gan_mask1D_free ( pFilter );
      gan_edge_feature_map_free ( &EdgeMap );



2006-03-17