At first, I forgot to cap the RGB values at 255 for sepia, and it resulted in white pixels being blue. But other areas were fine(proper sepia). So additionally, I added the ternary operators to check if the values are greater than 255, if yes, assign 255. This code, unfortunately, made the entire image slighted red tinted. Where did I go wrong? (the ternary operators??)
// Convert image to sepia
void sepia(int height, int width, RGBTRIPLE image[height][width]) {
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
//Store original colours in variables
float blues = image[i][j].rgbtBlue;
float greens = image[i][j].rgbtGreen;
float reds = image[i][j].rgbtRed;
//Store rounded sepia in variables
int sepiaRed = round(.393 * reds + .769 * greens + .189 * blues);
int sepiaGreen = round(.349 * reds + .686 * greens + .168 * blues);
int sepiaBlue = round(.272 * reds + .534 * greens + .131 * blues);
//Check if rounded sepia values larger than 255
int sepiaRedCapped = (sepiaRed > 255) ? 255 : sepiaRed;
int sepiaGreenCapped = (sepiaGreen > 255) ? 255 : sepiaGreen;
int sepiaBlueCapped = (sepiaBlue > 255) ? 255 : sepiaBlue;
//Replace actual pixels with sepia
image[i][j].rgbtBlue = sepiaRedCapped;
image[i][j].rgbtGreen = sepiaGreenCapped;
image[i][j].rgbtRed = sepiaRedCapped;
}
}
return;
}