0

For some reason, the image attached below is the output I get with Sepia filter. I don't know where the code is wrong.

void sepia(int height, int width, RGBTRIPLE image[height][width])
{
    int k = 0;
    for (int i = 0; i < height; i++)
    {
        for (int j = 0; j < width; j++)
        {
            int sepiaRed = round((0.393 * image[i][j].rgbtRed) + (0.769 * image[i][j].rgbtGreen) + (0.189 * image[i][j].rgbtBlue));
            int sepiaGreen = round((0.349 * image[i][j].rgbtRed) + (0.686 * image[i][j].rgbtGreen) + (0.168 * image[i][j].rgbtBlue));
            int sepiaBlue = round((0.272 * image[i][j].rgbtRed) + (0.534 * image[i][j].rgbtGreen) + (0.131 * image[i][j].rgbtBlue));
            int SEPIA[] = {sepiaRed, sepiaGreen, sepiaBlue};
            
            if(SEPIA[k] > 255)
            {
                SEPIA[k] = 255;
            }
            image[i][j].rgbtRed = SEPIA[0];
            image[i][j].rgbtGreen = SEPIA[1];
            image[i][j].rgbtBlue = SEPIA[2];
        }
    }
    return;
}

Sepia Output

1

Look at the following code:

        if(SEPIA[k] > 255)
        {
            SEPIA[k] = 255;
        }

What is the value of k? Where is it incremented? Is it possible that some code was forgotten to be added? ;-)

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

1

You must log in to answer this question.

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