So for some reason neither sepia or blur is returning a picture that has been altered at all. I think this has to do with my storing values in a new RGBTRIPLE called newimage and then after all fo the work is done trying to set the original image value to the newimage value.
I came to this conclusion because sepia was returning a super green image and I guessed that must be because I was changing the value of each pixel and that change was then affecting the next pixel calculation and so on. I figured I needed a place holder in which to store the new calculated pixel values, but for whatever reason I seem to be returning nothing at all now.
Can someone help me or point me in the right direction for how to correct this. Thanks, Rob.
void sepia(int height, int width, RGBTRIPLE image[height][width])
{
float red = 0;
float green = 0;
float blue = 0;
RGBTRIPLE newimage[height][width];
for (int i = 0; i < height; i++)
{
for(int j = 0; j<width; j++)
{
red =((.393 * image[i][j].rgbtRed) + (.769 * image[i][j].rgbtGreen) + (.189 * image[i][j].rgbtBlue));
green = ((.349 * image[i][j].rgbtRed) + (686 * image[i][j].rgbtGreen) + (.168 * image[i][j].rgbtBlue));
blue = ((.272 * image[i][j].rgbtRed) + (.534 * image[i][j].rgbtGreen) + (.131 * image[i][j].rgbtBlue));
if (red>255)
{
red=255;
}
if(green>255)
{
green=255;
}
if(blue>255)
{
blue=255;
}
newimage[i][j].rgbtRed = round(red);
newimage[i][j].rgbtGreen = round(green);
newimage[i][j].rgbtBlue = round(blue);
}
}
image = newimage;
return;
}
// Blur image
void blur(int height, int width, RGBTRIPLE image[height][width])
{
RGBTRIPLE newimage[height][width];
float red = 0;
float blue = 0;
float green =0;
int counter = 0;
//height loop
for(int i=0; i<height; i++)
{
//width loop
for(int j=0; j<width; j++)
{
//loop to search row of 3 elements
for (int k=-1; k<2; k++)
{
//loop to search column of 3 elements
for(int l=-1; l<2; l++)
{
if(k-1<0 || l-1<0 || k+1>=height || l+1>=width)
{
continue;
}
else
{
red = red+image[k][l].rgbtRed;
green = green+image[k][l].rgbtGreen;
blue = blue + image[k][l].rgbtBlue;
counter++;
}
}
}
newimage[i][j].rgbtRed=round(red/counter);
newimage[i][j].rgbtGreen=round(green/counter);
newimage[i][j].rgbtBlue=round(blue/counter);
}
}
image = newimage;
return;
}