0
void blur(int height, int width, RGBTRIPLE image[height][width])

{

RGBTRIPLE holder[height][width];
int red;
int green;
int blue;
float counter;

for (int i = 0; i < height; i++)
{
    for (int j = 0; j < width; j++)
    {
        red = 0;
        green = 0;
        blue = 0;
        counter = 0.0;
        //for the blur box
        //nested loop to check one box around
        for (int a = -1; a < 2; a++)
        {
            for (int b = -1; b < 2; b++)
            {
                if ((i + a) >= 0 && (i + a) <= height && (j + b) >= 0 && (j + b) < width)
                {
                    counter++;
                    red += image[i + a][j + b].rgbtRed;
                    green += image[i + a][j + b].rgbtGreen;
                    blue = image[i + a][j + b].rgbtBlue;

                }
            }
        }
        holder[i][j].rgbtRed = round(red/counter);
        holder[i][j].rgbtGreen = round(green/counter);
        holder[i][j].rgbtBlue = round(blue/counter);
    }
}
for (int i = 0; i < height; i++)
{
    for ( int j = 0; j < width; j++)
    {
        image[i][j] = holder[i][j];
    }
}
return;

}

:( blur correctly filters middle pixel expected "127 140 149\n", not "127 140 28\n"


:( blur correctly filters pixel on edge expected "80 95 105\n", not "80 95 27\n"


:( blur correctly filters pixel in corner expected "70 85 95\n", not "70 85 38\n"


:( blur correctly filters 3x3 image expected "70 85 95\n80 9...", not "70 85 38\n80 9..."


:( blur correctly filters 4x4 image expected "70 85 95\n80 9...", not "70 85 38\n80 9..."


Not sure exactly i am screwing up

1 Answer 1

1

I missed a += on the rgbtGreen :S

You must log in to answer this question.

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