Page 90 -
P. 90
64 Chapter 2 ■ Edge-Detection Techniques
}
float meanGauss (float x, float sigma)
{
float z;
z = (gauss(x,sigma)+gauss(x+0.5f,sigma)+gauss(x-0.5f,sigma))/3.0f;
z = z/(PI*2.0f*sigma*sigma);
return z;
}
/* First derivative of Gaussian */
float dGauss (float x, float sigma)
{
return -x/(sigma*sigma) * gauss(x, sigma);
}
/* HYSTERESIS thersholding of edge pixels. Starting at pixels with a
value greater than the HIGH threshold, trace a connected sequence
of pixels that have a value greater than the LOW threhsold. */
void hysteresis (int high, int low, IMAGE im, IMAGE mag, IMAGE oriim)
{
int i,j;
printf (“Beginning hysteresis thresholding...\n“);
for (i=0; i<im->info->nr; i++)
for (j=0; j<im->info->nc; j++)
im->data[i][j] = 0;
if (high<low)
{
estimate_thresh (mag, &high, &low);
printf (“Hysteresis thresholds (from image): HI %d LOW %D\n“,
high, low);
}
/* For each edge with a magnitude above the high threshold, begin
tracing edge pixels that are above the low threshold. */
for (i=0; i<im->info->nr; i++)
for (j=0; j<im->info->nc; j++)
if (mag->data[i][j] >= high)
trace (i, j, low, im, mag, oriim);
/* Make the edge black (to be the same as the other methods) */
for (i=0; i<im->info->nr; i++)
for (j=0; j<im->info->nc; j++)
if (im->data[i][j] == 0) im->data[i][j] = 255;
else im->data[i][j] = 0;
}