Image Processing With Pixels error

I’ve written this cose:

<void setup(){
size(337,450);
frog=loadImage(“frog.jpg”);
}

void draw(){
image(frog,0,0);

loadPixels();
frog.loadPixels();
for(int x=0; x<width; x++){
for(int y=0; y<height; y++){
int loc=x+y*width;
pixels[loc]=frog.pixels[loc];
}
}
updatePixels();
}>

And I get the following error:
“frog cannot be resolved to a variable”.

I should also add that I have saved the image with correct name frog.jpg in the sketch file.

say PImage frog; before setup()

like you say int loc you need to declare frog as a variable with a type.

Chrisir

1 Like

You’re right my mind got a little stuck there. Thank you!

1 Like