We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 2516172 + 7a69c47 commit 9f34e2dCopy full SHA for 9f34e2d
helpers.c
@@ -9,12 +9,21 @@ int max(int a,int b){
9
return b;
10
}
11
void grayscale(int height, int width, RGBTRIPLE image[height][width]){
12
- return;
13
-
14
-// Convert image to grayscale
15
+
+ for(int i = 0; i < height; i++){
+ for(int j = 0; j < width; j++){
+ int red = image[i][j].rgbtRed;
16
+ int green = image[i][j].rgbtGreen;
17
+ int blue = image[i][j].rgbtBlue;
18
+ int avg = (red + green + blue) / 3;
19
+ image[i][j].rgbtRed = avg;
20
+ image[i][j].rgbtGreen = avg;
21
+ image[i][j].rgbtBlue = avg;
22
+ }
23
24
25
26
27
void invert(int height, int width, RGBTRIPLE image[height][width]){
28
for(int i = 0; i<height; i++){
29
for(int j = 0; j<width; j++){
0 commit comments