0

I test it and it works but check50 tell

:( sepia correctly filters single pixel
    expected "56 50 39\n", not "56 62 60\n"          
:( sepia correctly filters simple 3x3 image
    expected "100 89 69\n100...", not "100 35 46\n100..."           
:( sepia correctly filters more complex 3x3 image
    expected "25 22 17\n66 5...", not "25 27 25\n66 6..."         
:( sepia correctly filters 4x4 image
    expected "25 22 17\n66 5...", not "25 27 25\n66 6..."

Where is my mistake ?

    void sepia(int height, int width, RGBTRIPLE image[height][width])
    {

       for (int i = 0; i < height; i++)
       {
            for(int j = 0; j < width; j++)
            {

            int newRed = round(0.393 *image[i][j].rgbtRed+ 0.769 *image[i][j].rgbtGreen + 0.189 *image[i][j].rgbtBlue);
            if(newRed > 255)
            {
                newRed = 255;
                image[i][j].rgbtRed = newRed;
            }else
            {
                image[i][j].rgbtRed  = newRed;
            }

            int newGreen= round(0.349 *image[i][j].rgbtRed+ 0.686 *image[i][j].rgbtGreen + 0.168 *image[i][j].rgbtBlue) ;
            if(newGreen > 255)
            {
                newGreen = 255;
                image[i][j].rgbtGreen = newGreen;
            }else
            {
                image[i][j].rgbtGreen = newGreen;
            }
            int newBlue = round(0.272 *image[i][j].rgbtRed + 0.534 *image[i][j].rgbtGreen+ 0.131 *image[i][j].rgbtBlue);
             if(newBlue > 255)
            {
                newBlue = 255;
                image[i][j].rgbtBlue = newBlue;
            }else
            {
                image[i][j].rgbtBlue = newBlue;
            }

1 Answer 1

1

Each new RGB value should depend on the input value. By assigning the newRed value to the image before calculating the newGreen pixel, the altered red value is used instead.

1
  • I got my mistake and true way. Thanks
    – Ali Kocak
    Commented Apr 11, 2021 at 16:35

You must log in to answer this question.

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