0
:) sepia correctly filters single pixel
:) sepia correctly filters simple 3x3 image
:( sepia correctly filters more complex 3x3 image
    expected "25 22 17\n66 5...", not "25 22 17\n66 5..."
:( sepia correctly filters 4x4 image
    expected "25 22 17\n66 5...", not "25 22 17\n66 5..."

Any tips?

void sepia(int height, int width, RGBTRIPLE image[height][width])
{
    for (int h = 0; h < height; h++)
    {
        for (int w = 0; w < width; w++)
        {
            int originalBlue = image[h][w].rgbtBlue;
            int originalGreen = image[h][w].rgbtGreen;
            int originalRed = image[h][w].rgbtRed;
            
            float sepiaRed = round(.393 * originalRed + .769 * originalGreen + .189 * originalBlue);
            float sepiaGreen = round(.349 * originalRed + .686 * originalGreen + .168 * originalBlue);
            float sepiaBlue = round(.272 * originalRed + .534 * originalGreen + .131 * originalBlue);
            
            image[h][w].rgbtBlue = sepiaBlue;
            image[h][w].rgbtGreen = sepiaGreen;
            image[h][w].rgbtRed = sepiaRed;
        }
    }
    return;
}

Thanks.

1 Answer 1

2

You did not add the condition "if the value exceeds 255".. If this answers your question, please mark it as answered. Let's keep up on forum maintenance!

1
  • Oh ok thank you Commented Jul 10, 2020 at 14:15

You must log in to answer this question.

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