My sepia code are as follows:
// Convert image to sepia
void sepia(int height, int width, RGBTRIPLE image[height][width])
{
// Comb through each row
for (int i = 0; i < height; i++)
{
// Comb through each column
for (int j = 0; j < width; j++)
{
// Get the original value of each pixel
int originalRed = image[i][j].rgbtRed;
int originalGreen = image[i][j].rgbtGreen;
int originalBlue = image[i][j].rgbtBlue;
// Change the value of each pixel by sepia fomula
image[i][j].rgbtRed = round(.393 * originalRed + .769 * originalGreen + .189 * originalBlue);
image[i][j].rgbtGreen = round(.349 * originalRed + .686 * originalGreen + .168 * originalBlue);
image[i][j].rgbtBlue = round(.272 * originalRed + .534 * originalGreen + .131 * originalBlue);
// Make sur the value is less than 256
if (image[i][j].rgbtRed > 255)
{
image[i][j].rgbtRed = 255;
}
if (image[i][j].rgbtGreen > 255)
{
image[i][j].rgbtGreen = 255;
}
if (image[i][j].rgbtBlue > 255)
{
image[i][j].rgbtBlue = 255;
}
}
}
return;
}
As I tried running it, the original image:
After filtering:
I just don't know what I did wrong.Could u pls help me? Thanks!