I have a sketch that I made based on some code that I found here a while ago. I think this question has a simple answer, bear with me as I'm not great at programming.
frameRate(30);
loadPixels();
for (int y = 0; y<height; y+=1 ) {
for (int x = 0; x<width; x+=1) {
int loc = x + y*img.width;
float r = red (img.pixels[loc]);
float g = green (img.pixels[loc]);
float b = blue (img.pixels[loc]);
float av = ((r+g+b)/3.0);
What I've been doing is manually changing the line with if (r > 100 && r < 255) { and changing the 100 and 255 to smaller ranges, outputting images at the different ranges and making animated GIFs. What I'd like to do is automate this. I tried adding in a for loop, and changing it to
if (r > r1 && r < r2) {
and then having r1+=15 and r2+=15 at the end of the loop... it just doesn't want to run however. I suspect it's the placement of the loop around the loadPixels? I'm not really sure, any guidance would be greatly appreciated!