Please help with what i did wrong, i cannot seem to find where my logic was wrong and been staring at it for weeks. I've tried to change my approach a few times but does not seem closer at all and unable to pass any of the check 50
RGBTRIPLE newimage[height][width]; //create variables to store the manipulated values of the image int red, green, blue, counter;
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++)
{
//assign original value of the image into the replacement array for manipulation
newimage[i][j] = image[i][j];
//reset values of red,green,blue,counter for this pixel into 0
red = green = blue = counter = 0;
//access the 8 pixels round the piel that you are looking at, continue if the the pixels are outside of the grid
for (int h = -1; h < 2; h++)
{
for (int w = -1; w < 2; w++)
{
if((i + h) > -1 && (i + h) < height && (j + w) > -1 && (j + w) < width)
{
red += newimage[i + h][j + w].rgbtRed;
green += newimage[i + h][j + w].rgbtGreen;
blue += newimage[i + h][j + w].rgbtBlue;
counter++;
}
}
}
image[i][j].rgbtRed = round (red / counter);
image[i][j].rgbtGreen = round (green / counter);
image[i][j].rgbtBlue = round (blue / counter);
}
}
return;
:( blur correctly filters middle pixel expected "127 140 149\n", not "115 119 118\n" :( blur correctly filters pixel on edge expected "80 95 105\n", not "35 43 15\n" :( blur correctly filters pixel in corner expected "70 85 95\n", not "2 5 7\n" :( blur correctly filters 3x3 image expected "70 85 95\n80 9...", not "2 5 7\n22 19 1..." :( blur correctly filters 4x4 image expected "70 85 95\n80 9...", not "34 52 29\n45 3..."