This is the output and input image that my code generates: https://i.sstatic.net/Y2Gpg.jpg
void blur(int height, int width, RGBTRIPLE image[height][width])
{
RGBTRIPLE newImage[height][width];
for (int h = 0; h < height; h++)
{
for (int w = 0; w < width; w++)
{
BYTE redAvg = 0;
BYTE greenAvg = 0;
BYTE blueAvg = 0;
double count = 0.0;
for (int y = -1; y <= 1; y++)
{
for (int x = -1; x <= 1; x++)
{
int h_1 = h + y;
int w_1 = w + x;
if (h_1 >= 0 && h_1 < height && w_1 >= 0 && w_1 < width)
{
RGBTRIPLE img = image[h_1][w_1];
count++;
redAvg += img.rgbtRed;
greenAvg += img.rgbtGreen;
blueAvg += img.rgbtBlue;
}
}
}
newImage[h][w].rgbtRed = round(redAvg/count);
newImage[h][w].rgbtGreen = round(greenAvg/count);
newImage[h][w].rgbtBlue = round(blueAvg/count);
}
}
for (int x = 0; x < height; x++)
{
for (int y = 0; y < width; y++)
{
image[x][y] = newImage[x][y];
}
}
return;
}