Skip to content

Instantly share code, notes, and snippets.

@aaronsherwood
Created December 6, 2012 18:53
Show Gist options
  • Save aaronsherwood/4227060 to your computer and use it in GitHub Desktop.
Save aaronsherwood/4227060 to your computer and use it in GitHub Desktop.
Picture slicing and brightness sorting of those pictures in processing.
// this is where the picture gets sliced up, measured for brightness, and stored in the PicSlice object
slices=new PImage[width];
for (int x=0;x<width;x++) {
slices[x]=createImage(1, height, RGB);
slices[x].loadPixels();
for (int y=0;y<height; y++) {
color colorSlice=img2.get(x, y);
slices[x].pixels[y]=colorSlice;
}
slices[x].updatePixels();
color brightnessColor=img2.get(x, 20);
int brt=int(brightness(brightnessColor));
bars[x]=new PicSlices(slices[x], brt);
}
//here is the PicSlice object
class PicSlices implements Comparable {
PImage img;
int b;
PicSlices(PImage theImg, int brightfulness) {
this.img=theImg;
b=brightfulness;
}
int compareTo(Object p)
{
PicSlices other=(PicSlices)p;
if (other.b>b)
return -1;
if (other.b==b)
return 0;
else
return 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment