void blur(int height, int width, RGBTRIPLE image[height][width])
{
RGBTRIPLE tmpimage[height][width];
for (int i = 0; i < height ; i++)
{
for (int j = 0; j < width; j++)
{
tmpimage[i][j].rgbtBlue = image[i][j].rgbtBlue;
tmpimage[i][j].rgbtGreen = image[i][j].rgbtGreen;
tmpimage[i][j].rgbtRed = image[i][j].rgbtRed;
}
}
// First need to pull out each pixel
int i_st, i_ed, j_st, j_ed, cc;
for (int i = 0; i < height ; i++)
{
for (int j = 0; j < width; j++)
{
//image[i][j] pxiel.
float newblue = 0;
float newgreen = 0;
float newred = 0;
//create the dimensions of the box.
i_st = i - 1;
if (i_st == -1)
{
i_st = i;
}
i_ed = i + 1;
if (i_ed == height)
{
i_ed = i;
}
j_st = j - 1;
if (j_st == -1)
{
j_st = j;
}
j_ed = j + 1;
if(j_ed == width)
{
j_ed = j;
}
cc = 0;
// Sum the BGR Values inside the box.
for (int row = i_st; row <= i_ed; row ++)
{
for (int col = j_st; col <= j_ed; col++)
{
newblue += tmpimage[row][col].rgbtBlue;
newgreen += tmpimage[row][col].rgbtGreen;
newred += tmpimage[row][col].rgbtRed;
cc++;
}
}
newblue = round(newblue/cc);
newgreen = round(newgreen/cc);
newblue = round(newred/cc);
image[i][j].rgbtBlue = newblue;
image[i][j].rgbtGreen = newgreen;
image[i][j].rgbtRed = newred;
//printf("new val = %i %i %i\n", image[i][j].rgbtBlue, image[i][j].rgbtGreen, image[i][j].rgbtRed);
}
}
return;
}
BLUR FILTER CODE.enter image description here