0

I wrote following code for blur filter . But I can't get the positive result . I want to know what the mistake is .

void blur(int height, int width, RGBTRIPLE image[height][width])
    {
        RGBTRIPLE temp1[height][width];
        RGBTRIPLE temp[height][width];

        for ( int h = 1 ; h < height + 1 ; h++)
        {
            for ( int w = 1 ; w<width + 1 ; w++)
            {
                int i = h - 1 ;
                int j = h + 1 ;
                int k = w - 1 ;
                int l = w + 1 ;

                if (j > height)
                {
                    j = 0 ;
                }
                if (l > width)
                {
                    l = 0 ;
                }

                //image[-1][w].rgb == 0x00 ;
                //image[h][-1] == 0x00 ;
                 //RGBTRIPLE image[-1][w] = 0;
                 //RGBTRIPLE image[h][-1] = 0;
                 image[0][w].rgbtRed = 0;
                 image[0][w].rgbtBlue = 0;
                 image[0][w].rgbtGreen = 0;

                 image[h][0].rgbtRed = 0;
                 image[h][0].rgbtBlue = 0;
                 image[h][0].rgbtGreen = 0;


                temp1[h][w].rgbtRed = (image[i][w].rgbtRed+ image[i][k].rgbtRed+ image[i][l].rgbtRed+ image[h][k].rgbtRed+ image[h][w].rgbtRed+ image[h][l].rgbtRed+ image[j][w].rgbtRed+image[j][k].rgbtRed+image[j][l].rgbtRed);
                temp1[h][w].rgbtGreen = (image[i][w].rgbtGreen+ image[i][k].rgbtGreen+ image[i][l].rgbtGreen+ image[h][k].rgbtGreen+ image[h][w].rgbtGreen+ image[h][l].rgbtGreen+ image[j][w].rgbtGreen+image[j][k].rgbtGreen+image[j][l].rgbtGreen);
                temp1[h][w].rgbtBlue = (image[i][w].rgbtBlue+ image[i][k].rgbtBlue+ image[i][l].rgbtBlue+ image[h][k].rgbtBlue+ image[h][w].rgbtBlue+ image[h][l].rgbtBlue+ image[j][w].rgbtBlue+image[j][k].rgbtBlue+image[j][l].rgbtBlue);

                if (h == 1 || h == height)
                {
                    if (w == 1 || w == width)
                    {
                        temp[h][w].rgbtRed = round(temp1[h][w].rgbtRed / 4.000);
                        temp[h][w].rgbtGreen = round(temp1[h][w].rgbtGreen / 4.000);
                        temp[h][w].rgbtBlue = round(temp1[h][w].rgbtBlue / 4.000);
                    }
                    else
                    {
                        temp[h][w].rgbtRed = round(temp1[h][w].rgbtRed / 6.000);
                        temp[h][w].rgbtGreen = round(temp1[h][w].rgbtGreen / 6.000);
                        temp[h][w].rgbtBlue = round(temp1[h][w].rgbtBlue / 6.000);
                    }
                }
                else if ( h != 1 && h != height)
                {
                    if (w == 1 || w == width)
                    {
                        temp[h][w].rgbtRed = round(temp1[h][w].rgbtRed / 6.000);
                        temp[h][w].rgbtGreen = round(temp1[h][w].rgbtGreen / 6.000);
                        temp[h][w].rgbtBlue = round(temp1[h][w].rgbtBlue / 6.000);
                    }
                    else
                    {
                        temp[h][w].rgbtRed = round(temp1[h][w].rgbtRed / 9.000);
                        temp[h][w].rgbtGreen = round(temp1[h][w].rgbtGreen / 9.000);
                        temp[h][w].rgbtBlue = round(temp1[h][w].rgbtBlue / 9.000);
                    }
                }



                image[h][w].rgbtBlue = temp[h][w].rgbtBlue;
                image[h][w].rgbtGreen = temp[h][w].rgbtGreen;
                image[h][w].rgbtRed = temp[h][w].rgbtRed;


            }
        }
        return;

You must log in to answer this question.

Browse other questions tagged .