Page 97 -
P. 97
Chapter 2 ■ Edge-Detection Techniques 71
*/
int thinFactor;
void shen (IMAGE im, IMAGE res)
{
register int i,j;
float **buffer;
float **smoothed_buffer;
IMAGE bli_buffer;
/* Convert the input image to floating point */
buffer = f2d (im->info->nr, im->info->nc);
for (i=0; i<im->info->nr; i++)
for (j=0; j<im->info->nc; j++)
buffer[i][j] = (float)(im->data[i][j]);
/* Smooth input image using recursively implemented ISEF filter */
smoothed_buffer = f2d( im->info->nr, im->info->nc);
compute_ISEF (buffer, smoothed_buffer, im->info->nr, im->info->nc);
/* Compute bli image band-limited laplacian image from smoothed image */
bli_buffer = compute_bli(smoothed_buffer,
buffer,im->info->nr,im->info->nc);
/* Perform edge detection using bli and gradient thresholding */
locate_zero_crossings (buffer, smoothed_buffer, bli_buffer,
im->info->nr, im->info->nc);
free(smoothed_buffer[0]); free(smoothed_buffer);
freeimage (bli_buffer);
threshold_edges (buffer, res, im->info->nr, im->info->nc);
for (i=0; i<im->info->nr; i++)
for (j=0; j<im->info->nc; j++)
if (res->data[i][j] > 0) res->data[i][j] = 0;
else res->data[i][j] = 255;
free(buffer[0]); free(buffer);
}
/* Recursive filter realization of the ISEF
(Shen and Castan CVIGP March 1992) */
void compute_ISEF (float **x, float **y, int nrows, int ncols)
{
float **A, **B;
A = f2d(nrows, ncols); /* store causal component */
B = f2d(nrows, ncols); /* store anti-causal component */
/* first apply the filter in the vertical direcion (to the rows) */
apply_ISEF_vertical (x, y, A, B, nrows, ncols);