I have been stuck on this problem for days and have tried so many ways to write this code, but I continuously get errors. Nothing works. The output file is just returned as a darker image of the input file. I'm not sure what to do, so any tips/suggestions/advice is greatly appreciated!
void blur(int height, int width, RGBTRIPLE image[height][width]) { RGBTRIPLE new_image[height][width];
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++)
{
new_image[i][j] = image[i][j];
int totalRed = 0;
int totalGreen = 0;
int totalBlue = 0;
float counter = 0.00;
for (int a = -1; a <= 1; a++)
{
for (int b = -1; b <= 1; b++)
{
if (i + a < 0 || i + a > height - 1 || j + b < 0 || j + b > width - 1)
{
continue;
}
else
{
totalRed += new_image[i + a][j + b].rgbtRed;
totalGreen += new_image[i + a][j + b].rgbtGreen;
totalBlue += new_image[i + a][j + b].rgbtBlue;
counter++;
}
}
}
new_image[i][j].rgbtRed = round(totalRed / counter);
new_image[i][j].rgbtGreen = round(totalGreen / counter);
new_image[i][j].rgbtBlue = round(totalBlue / counter);
}
}
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++)
{
image[i][j].rgbtRed = new_image[i][j].rgbtRed;
image[i][j].rgbtGreen = new_image[i][j].rgbtGreen;
image[i][j].rgbtBlue = new_image[i][j].rgbtBlue;
}
}
}