The code visually seems to work (the images look blurry on the output) when I run it with all 4 of the pre loaded images, but with Check50 everything is marked as incorrect and I can't figure out why.
void blur(int height, int width, RGBTRIPLE image[height][width])
{
//Create new array
RGBTRIPLE new[height][width];
//Copy image to new
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++)
{
new[i][j] = image[i][j];
}
}
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++)
{
//Create counter and int to store each of the neighbour colors
int counter = 0;
int tempRed = 0;
int tempGreen = 0;
int tempBlue = 0;
//Check for the neighbour pixels
for (int l = -1; l < 2; l++)
{
for (int m = -1; m < 2; m++)
{
//If they are bigger that 0 and smaller than height or width they exist
if (i+l > 0 && i+l < height && j+m > 0 && j+m < width)
{
//Store the value in the temp color int and increase the counter
tempRed += new[i+l][j+m].rgbtRed;
tempGreen += new[i+l][j+m].rgbtGreen;
tempBlue += new[i+l][j+m].rgbtBlue;
counter++;
}
}
}
//Average color value of neighbour pixels and assign it to image
image[i][j].rgbtRed = round(tempRed/counter);
image[i][j].rgbtGreen = round(tempGreen/counter);
image[i][j].rgbtBlue = round(tempBlue/counter);
}
}
return;
}
ERROR
:( blur correctly filters middle pixel
expected "127 140 149\n", not "177 192 201\n"
:( blur correctly filters pixel on edge
expected "80 95 105\n", not "125 145 155\n"
:( blur correctly filters pixel in corner
expected "70 85 95\n", not "120 140 150\n"
:( blur correctly filters 3x3 image
expected "70 85 95\n80 9...", not "120 140 150\n1..."
:( blur correctly filters 4x4 image
expected "70 85 95\n80 9...", not "120 140 150\n1..."
Thanks for your help!