0

What I tried to do was go to each pixel and see if any neighboring ones existed. If they did, I saved the neighboring pixel's colors. Then I ran a loop to add up all the values in that specific color array for that pixel. Finally, I divided by the length of the array and set the final image colors to the results. However, when I run the program, it compiles but no values are returned. How can I fix it?

    enter code herevoid blur(int height, int width, RGBTRIPLE image[height][width])
{
    //reiterate through each pixel
    for (int j = 0; j < height; j++)
    {
        for (int i = 0; i < width; i++)
        {
            RGBTRIPLE blurimage[j][i]; char cred[100]; char cgreen[100]; char cblue[100]; 
            int sumred; int sumgreen; int sumblue; 
            
            //currently on one pixel
            for (int k = -1; k < 2; k++)
            {
                for (int m = -1; m < 2; m++)
                {
                     if (&image[j + k][i + m] != NULL) //if this pixel does exist 
                    {
                    //save all of its colors 
                    cred[j] = blurimage[j+k][i + m].rgbtRed;
                    cgreen[j] = blurimage[j+k][i + m].rgbtGreen;
                    cblue[j] = blurimage[j+k][i + m].rgbtBlue;
                    }
                    

                }
            }
            //add all of the rgb values in the array up and average them
                    for (int n = 0; n < 10; n++)
                    {
                         sumred = sumred + cred[n];
                         sumgreen = sumgreen + cgreen[n]; 
                         sumblue = sumblue + cblue[n]; 
                    }
                    //add up cred and divide it by its lenth 
                int blurred = (sumred / strlen(cred)) ; 
                int blurgreen = (sumgreen / strlen(cgreen)); 
                int blurblue = (sumblue / strlen(cblue)); 

                //set the pixel original values to these new values
                image[j][i].rgbtRed = blurred;
                image[j][i].rgbtGreen = blurgreen;
                image[j][i].rgbtBlue = blurblue;
        }

    }
    return;
}

You must log in to answer this question.

Browse other questions tagged .