# Help on blur function. Correct logic but wont work

So after I passed pset3, I thought things would go easier since my friend said that filter wasn't as complicated as Tideman. Now, I’m doing the blur filter part and stuck on its computation especially determining whether its an edge or sides.

This part of my function acts as scanner for the whole 3x3, if its outside the boundary (-1 for the left and upper side and width for right side), it’ll be skipped, otherwise it will be counted on a variable named counter as well summed by available neighboring pixels. The variable counter then will be act as their denominator for the average calculation.

Yet, after doing check50, it wont work. I dont see any fault on the logics, maybe you guys can give me hint over this problem (because then, the edge filter is only matter of computation).

This is my program, have a look.

``````||// Blur image
void blur(int height, int width, RGBTRIPLE image[height][width])
{
float counter;
float sumRed;
float sumGreen;
float sumBlue;

//Copy of image
RGBTRIPLE copy[height][width];

//Copy all values for dummy image
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++)
{
copy[i][j] = image [i][j];
}
}

//Above copy is meant to be computed as the original one will change over loops

for (int i = 0; i < height; i++)
{

for (int j = 0; j < width; j++)
{
//initialize counter
counter = 0.0;

//initialize sum
sumRed = 0.0;
sumGreen = 0.0;
sumBlue = 0.0;

//Checking surrounding pixels
for (int k = i - 1; k <= i + 2; k++)
{
for (int l = j - 1; l <= j + 2; l++)
{
if (k < 0 (or) k > height + 1 (or) l < 0 (or) l > width + 1 )
{

}
else
{
sumRed += copy[k][l].rgbtRed;
sumGreen += copy[k][l].rgbtGreen;
sumBlue += copy[k][l].rgbtBlue;

counter++;
}
}
}

//compute new values
image[i][j].rgbtRed = round (sumRed/counter);
image[i][j].rgbtGreen = round (sumGreen/counter);
image[i][j].rgbtBlue = round (sumBlue/counter);

}

}
return;
}
``````