Hello,

I am trying to impliment a guassian blur filter in C++, but i cannot progress asi keep getting a Floating point exception every time i run it. I am unsure as to why, i have narrowed the error down to somewhere within the function gaussian_mask() which creates the gaussian mask.

Any help will be greatly appreciated :)

/Knad

```
#ifndef CANNY_ALGORITHM
#define CANNY_ALGORITHM
#define pi 3.14159
int mask[5][5];
int max =0;
double temp;
void gaussian_mask(int dev = 1) {
for(int j=-2;j<3;j++) // create the mask for gaussian filter
for(int i=-2;i<3;i++) {
temp = (1 / (dev * sqrt(2 * pi))) * exp(-(pow(i,2) + pow(j,2)) / 2 * pow(dev,2));
mask[i + 2][-j + 2]=int(temp);
}
for(int i=0; i<5;i++) //find max mask value for normalization
for(int j=0;j<5;j++) {
if(i==0 && j==0)
max=mask[i][j];
else if (mask[i][j]>max)
max=mask[i][j];
}
for(int i=0; i<5;i++) //normalize mask
for(int j=0;j<5;j++)
mask[i][j]=mask[i][j] / max;
}
////Convolve algorithm for mask (for multidimensional arrays we must define array size)
int convolve_gauss(BwImage imgGrey, int x, int y, int k[][5]) {
int xx, yy, r=0;
for(xx=-1;xx<=1;xx++)
for(yy=-1;yy<=1;yy++)
r+= imgGrey[x+xx][y+yy] * k[xx+1][yy+1];
return r;
}//convolve gauss
////Main canny algorithm
IplImage* canny (IplImage* img) {
int sx, sy;
BwImage imgGrey (img);
///////////////////////////////////////
////ERROR APPEARS WHEN I CALL THIS/////
///////////////////////////////////////
gaussian_mask();
// get the image data
int height = img->height;
int width = img->width;
//Gaussian Blur
for(int x=1; x < width; x++)
for(int y=1; y < height; y++) {
sx = convolve_gauss(imgGrey, x, y, mask);
sy = convolve_gauss(imgGrey, x, y, mask);
imgGrey[x][y] = (sx+sy)/2;
}
return imgGrey.returnImg();
}
#endif
```