automated commit by check50 [check50=True]

This commit is contained in:
kukemuna 2024-03-08 14:29:01 +02:00
parent e12dfebf58
commit 01b1cf22da
1 changed files with 7 additions and 12 deletions

View File

@ -91,22 +91,17 @@ void blur(int height, int width, RGBTRIPLE image[height][width])
float sumRed = 0, sumGreen = 0, sumBlue = 0; float sumRed = 0, sumGreen = 0, sumBlue = 0;
int count = 0; int count = 0;
for (int k = -1; k < 2; k++) for (int k = (i - 1); k <= (i + 1); k++)
{ {
for (int l = -1; l < 2; l++) for (int l = (j - 1); l <= (j + 1); l++)
{ {
if (i + k <= 0 || i + k >= height) if ((k >= 0 && k <= (height - 1)) && (l >= 0 && l <= (width - 1)))
{ {
continue; sumRed += copy[k][l].rgbtRed;
} sumGreen += copy[k][l].rgbtGreen;
if (j + l <= 0 || j + l >= width) sumBlue += copy[k][l].rgbtBlue;
{
continue;
}
sumRed += copy[i + k][j + l].rgbtRed;
sumGreen += copy[i + k][j + l].rgbtGreen;
sumBlue += copy[i + k][j + l].rgbtBlue;
count++; count++;
}
} }
} }
image[i][j].rgbtRed = round(sumRed / (float) count); image[i][j].rgbtRed = round(sumRed / (float) count);