PImage foto;
int maxImages = 6; // Img in totale
int imageIndex = 0; // Img iniziale
PImage[] images = new PImage[maxImages]; // Serie di Img
void setup() {
size(2300, 1700);
foto = loadImage("Data/nin0.jpg");
for (int i = 0; i < images.length; i ++ ) {
images[i] = loadImage( "nin" + i + ".jpg" );
}
}
void draw(){
noLoop();
noFill();
strokeWeight(.003);
stroke(255,0,0);
foto.loadPixels();
for (int y = 0; y < foto.height; y++) {
for (int x = 0; x < foto.width; x++) {
int loc = x + y*foto.width;
float r = red(foto.pixels[loc]);
float g = green(foto.pixels[loc]);
float b = blue(foto.pixels[loc]);
float c = (0.21*r + 0.72*g + 0.07*b);
float colore = map(c, 0, 255, 0, 10);
ellipse(x*15, y*15, colore, colore);
background(255);
foto.updatePixels();
image(foto, 0, 0);
imageIndex = (imageIndex + 1);
saveFrame("output/file_" + imageIndex + ".png");
exit();
}
}
float colore;
}
You stop the program with exit() inside the inner loop. You don’t need it because noLoop() stops rerunning of draw().
Second problem is that foto is uninitialized variable and should cause null pointer exception