Pixels need help please
in
Programming Questions
•
2 years ago
Please take a look at this code , I have noted and left out the parts I am unsure of. Any assistance would be appreciated!
If (red + green) is greater than blue, replace the pixel with one that is pure red (255,0,0).
PImage pic;
void setup ()
{
size(500, 500);
pic = loadImage("proc.JPG");
mangle();
}
void draw()
{
background(150);
image(pic, 0, 0);
float r = ?? <----------------------------------------------------
float g = ??<----------------------------------------------------
float b = ??<----------------------------------------------------
}
void mangle()
{
pic.loadPixels();
int len = pic.pixels.length;
for (int i = 0; i < len; i++)
{
color pixel = pic.pixels[i];
if (r + g > b)
{
//replace the pixel with one that is pure red (255,0,0) <-----------------------------------------------------
}
pic.pixels[i] = pixel;
}
pic.updatePixels();
}
1