Page 96 -
P. 96

70    Chapter 2 ■ Edge-Detection Techniques



                                    for (i=0; i<WIDTH; i++)
                                      for (j=0; j<im->info->nc; j++)
                                        im->data[i][j] = 255;

                                    for (i=im->info->nr-1; i>im->info->nr-1-WIDTH; i--)
                                      for (j=0; j<im->info->nc; j++)
                                        im->data[i][j] = 255;

                                    for (i=0; i<im->info->nr; i++)
                                      for (j=0; j<WIDTH; j++)
                                        im->data[i][j] = 255;

                                    for (i=0; i<im->info->nr; i++)
                                      for (j=im->info->nc-WIDTH-1; j<im->info->nc; j++)
                                        im->data[i][j] = 255;



                                    display_image (im);
                                    save_image (im, “canny.jpg“);
                                    return 0;
                             }



                           2.10     Source Code for the Shen-Castan

                           Edge Detector


                             /* ISEF edge detector */
                             #include “stdio.h“
                             #include “cv.h“
                             #include “highgui.h“
                             #include <stdio.h>
                             #include <string.h>
                             #include <math.h>
                             #define OUTLINE 25

                             /* globals for shen operator */
                             double b = 0.9;                       /* smoothing factor 0 < b < 1 */
                             double low_thresh=20, high_thresh=22;  /* threshold for hysteresis */
                             double ratio = 0.99;
                             int window_size = 7;
                             int do_hysteresis = 1;
                             float **lap;                  /* keep track of laplacian of image */
                             int nr, nc;                   /* nrows, ncols */
                             IMAGE edges;                  /* keep track of edge points (thresholded)
   91   92   93   94   95   96   97   98   99   100   101