mirror of https://github.com/me50/kukemuna.git
automated commit by check50 [check50=True]
This commit is contained in:
parent
e12dfebf58
commit
01b1cf22da
19
helpers.c
19
helpers.c
|
|
@ -91,24 +91,19 @@ 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);
|
||||||
image[i][j].rgbtGreen = round(sumGreen / (float) count);
|
image[i][j].rgbtGreen = round(sumGreen / (float) count);
|
||||||
image[i][j].rgbtBlue = round(sumBlue / (float) count);
|
image[i][j].rgbtBlue = round(sumBlue / (float) count);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue