0

I'm trying to write the part of the code where the surrounding pixels around the main pixel are searched in order to make the average and later replace the main value for the average value. I am thinking about something like the code below. When I try to compile it I get:

error: expression result unused [-Werror,-Wunused-value] for ((x+i-1) ; x<2 ;x++)

Is it possible to use that expression (x+i-1)in a correct way?

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

    RGBTRIPLE image_copy[height][width]
    {
        for (int i=0 ; i<height ; i++)
        {
            for (int j=0 ; j<width; j++)
            {
                int x=0;
                int y=0;
                
                image_copy[i][j].rgbtRed=image[i][j].rgbtRed
                image_copy[i][j].rgbtBlue=image[i][j].rgbtBlue
                image_copy[i][j].rgbtGreen=image[i][j].rgbtGreen
                
                for (x+i-1 ; x<2 ; x++) // Searching loop for surrounding pixels
                {
                    for (y+j-1 ; y<2 ; y++)
                    {
                        if(Not ouside boundaries)
                        {
                        //do average;
                        }
                    }
                }
                
            }
        }
        return;
    }
1

Just get rid of int x=0; and replace x+i-1 with int x = i - 1. Likewise for the variable y. You can put any expression or declaration in the first section of the for loop.

https://en.cppreference.com/w/c/language/for

If this answers your question, please click on the check mark to accept. Don't be shy to ask another question the next time you have an issue!

This site is temporarily in read only mode and not accepting new answers.

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