Page 92 -
P. 92

66    Chapter 2 ■ Edge-Detection Techniques



                                          x += gau[k]*im->data[i][I1] + gau[k]*im->data[i][I2];
                                        }
                                        smx[i][j] = x; smy[i][j] = y;
                                      }
                             }
                             void dxy_seperable_convolution (float** im, int nr, int nc,  float *gau,
                                          int width, float **sm, int which)
                             {
                                    int i,j,k, I1, I2;
                                    float x;
                                    for (i=0; i<nr; i++)
                                      for (j=0; j<nc; j++)
                                      {
                                        x = 0.0;
                                        for (k=1; k<width; k++)
                                        {
                                          if (which == 0)
                                          {
                                          I1 = (i+k)%nr; I2 = (i-k+nr)%nr;
                                          x += -gau[k]*im[I1][j] + gau[k]*im[I2][j];
                                          }
                                          else
                                          {
                                          I1 = (j+k)%nc; I2 = (j-k+nc)%nc;
                                          x += -gau[k]*im[i][I1] + gau[k]*im[i][I2];
                                          }
                                        }
                                        sm[i][j] = x;
                                      }
                             }

                             void nonmax_suppress (float **dx, float **dy, int nr, int nc,
                                          IMAGE mag, IMAGE ori)
                             {
                                    int i,j;
                                    float xx, yy, g2, g1, g3, g4, g, xc, yc;

                                    for (i=1; i<mag->info->nr-1; i++)
                                    {
                                      for (j=1; j<mag->info->nc-1; j++)
                                      {
                                        mag->data[i][j] = 0;
                             /* Treat the x and y derivatives as components of a vector */
                                        xc = dx[i][j];
                                        yc = dy[i][j];
                                        if (fabs(xc)<0.01 && fabs(yc)<0.01) continue;

                                        g  = norm (xc, yc);
   87   88   89   90   91   92   93   94   95   96   97