-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGrayScale_Student.pde
More file actions
42 lines (35 loc) · 945 Bytes
/
GrayScale_Student.pde
File metadata and controls
42 lines (35 loc) · 945 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
PImage img;
void setup()
{
img = loadImage("fwcdlogo.jpg");
size(800,800);
}
void draw()
{
image(img, 0, 0);
}
void mouseClicked()
{
img.loadPixels();
for(int i=0;i<img.pixels.length; i++)
{
color c= img.pixels[i];
int redvar=int(red(c));
int greenvar=int(green(c));
int bluevar=int(blue(c));
// make three containers to store the red, green, and blue
//values from the color variable called c
int avg=average(redvar,greenvar,bluevar);
//make a fourth container called avg
//to remember the average, set this container to
//the result returned when you call your average method. (capture it)
img.pixels[i] = color(avg);
}
img.updatePixels();
}
//write the average method HERE
int average(int first, int second, int third)
{
int returnvar=(first+second+third)/3;
return returnvar;
}