I haven't followed the whole thread. But looking quickly at the code I found a few "maybe-mistakes". Try using PGraphics instead of PImage. I'm supposing that your image called 'white.jpg' is just a white image.
Code:
//Initialising global variables
PGraphics picture;
int location_x;
int location_y;
int generation=3;
Swarm [] locust;
//Setup of main variables
void setup () {
framerate(1);
size(500,500,P3D);
background(199);
camera(500, 300, (height/2.0) / tan(PI*60.0 / 360.0), width/2.0, height/2.0, 0, 0, 1, 0);
//Loading the image
picture = createGraphics(width,height,P3D);
picture.defaults();
picture.background(255);
//Initial co-ordinates for start of jumps
location_x=100;
location_y=100;
//initialising generation
locust = new Swarm[generation];
for (int i=0; i<generation; i++ ) {
locust[i] = new Swarm(picture);
}
}
//Recursive draw method
void draw () {
//clears the sketch every frame
background(199);
//starts the process
for (int i=0; i<generation; i++ ){
locust[i].live();
println("ok "+i);
}
}
//Swarm class
class Swarm {
PGraphics pic;
//Constructor
Swarm (PGraphics back) {
pic=back;
}
//main method
void live () {
//Loading the image's pixels
loadPixels();
//Initialising variables
int random1=int(random(0,300));
int random2=int(random(0,300));
int random_red=int(random(-255,255));
int random_green=int(random(-255,255));
int random_blue=int(random(-255,255));
//Getting the random pixel
int pixel=pic.pixels[random1+random2*pic.width];
int r=(pixel&0x00FF0000)>>16;
int g=(pixel&0x0000FF00)>>8;
int b=pixel&0x000000FF;
//Setting destination
int destination_x=random1+99;
int destination_y=random2+99;
//Setting stroke properties
int randomstroke=int(random(0,255));
stroke(randomstroke);
//Drawing the line
line(location_x,location_y,0, destination_x,destination_y,0);
location_x=destination_x;
location_y=destination_y;
//Changing the pixel's RGB
r+=random_red;
if(r<0)
r=0;
else if (r>255)
r=255;
g+=random_green;
if(g<0)
g=0;
else if (g>255)
g=255;
b+=random_blue;
if(b<0)
b=0;
else if (b>255)
b=255;
//Storing the change and updating the pixels
pixel=(pixel&0xFF000000)+(r<<16)+(g<<8)+b;
pic.pixels[random1+random2*pic.width]=pixel;
pic.updatePixels();
//Assigning the image to a vertex
beginShape();
noStroke();
texture(pic);
vertex(100, 100, 0, 0);
vertex(400, 100, 300, 0);
vertex(400, 400, 300, 300);
vertex(100, 400, 0, 300);
endShape();
}
}
hope it helps