diff --git a/helpers.c b/helpers.c index 8275ef6..c3201bb 100644 --- a/helpers.c +++ b/helpers.c @@ -9,12 +9,21 @@ int max(int a,int b){ return b; } void grayscale(int height, int width, RGBTRIPLE image[height][width]){ - return; - -// Convert image to grayscale - + + for(int i = 0; i < height; i++){ + for(int j = 0; j < width; j++){ + int red = image[i][j].rgbtRed; + int green = image[i][j].rgbtGreen; + int blue = image[i][j].rgbtBlue; + int avg = (red + green + blue) / 3; + image[i][j].rgbtRed = avg; + image[i][j].rgbtGreen = avg; + image[i][j].rgbtBlue = avg; + } + } } + void invert(int height, int width, RGBTRIPLE image[height][width]){ for(int i = 0; i