Page 98 -
P. 98

72    Chapter 2 ■ Edge-Detection Techniques



                             /* now apply the filter in the horizontal direction (to the columns) and */
                             /* apply this filter to the results of the previous one */
                                  apply_ISEF_horizontal (y, y, A, B, nrows, ncols);
                                /* free up the memory */
                                    free (B[0]); free(B);
                                    free (A[0]); free(A);
                             }

                             void apply_ISEF_vertical (float **x, float **y, float **A, float **B,
                                                   int nrows, int ncols)
                             {
                                    register int row, col;
                                    float b1, b2;

                                    b1 = (1.0 - b)/(1.0 + b);
                                    b2 = b*b1;

                             /* compute boundary conditions */
                                    for (col=0; col<ncols; col++)
                                    {

                             /* boundary exists for 1st and last column */
                                       A[0][col] = b1 * x[0][col];
                                       B[nrows-1][col] = b2 * x[nrows-1][col];
                                    }
                             /* compute causal component */
                                    for (row=1; row<nrows; row++)
                                      for (col=0; col<ncols; col++)
                                        A[row][col] = b1 * x[row][col] + b * A[row-1][col];

                             /* compute anti-causal component */
                                    for (row=nrows-2; row>=0; row--)
                                      for (col=0; col<ncols; col++)
                                        B[row][col] = b2 * x[row][col] + b * B[row+1][col];

                             /* boundary case for computing output of first filter */
                                    for (col=0; col<ncols-1; col++)
                                      y[nrows-1][col] = A[nrows-1][col];

                             /* now compute the output of the first filter and store in y */
                             /* this is the sum of the causal and anti-causal components */
                                    for (row=0; row<nrows-2; row++)
                                      for (col=0; col<ncols-1; col++)
                                        y[row][col] = A[row][col] + B[row+1][col];
                             }
                             void apply_ISEF_horizontal (float **x, float **y, float **A, float **B,
                                                     int nrows, int ncols)
   93   94   95   96   97   98   99   100   101   102   103