0
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

1 Answer 1

0

I use the first two loops to make a temporary copy of the image RBGTRIPLE tmpimage . The next two loops is used to locate each pixel and within it we then find the dimensions of the box, the subsequent two loops are used to traverse the values of the box and take their sum. Then we take the average of the sum with the cc and put the value back into the original image[i][j] for each color. But still I'm not getting the correct values, only green values are correct. What is it that I am missing?enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .