Tuesday, April 7, 2009

Inspired by the averaged google images at the axiom gallery I will now try and recreate the code that built the pictures. (half java half pseudo)


//PRE-CONDITION - All images by default are 100x100 pixels though this can be changed via some codework
//POST-CONDITION - The final image will be an average 100x100 image

Public Class Main
public static void main(String args[]) {

Picture[] picArr = new Picture[100]; //this holds the 100 pictures to be averaged
/* HERE WILL GO A FUNCTION TO FILL picArr WIT PICTURES *\
Picture final; //This holds the final picture


for(int i = 0; i<100; i++) {
//This block of code goes to each pixel in the image and adds its red, green, and blue value to //the appropriate spot in the final image....Each pixel/color will later be averaged
for(into j = 0; j<100; j++) { //FUN NESTED LOOP!
final.red = final.red + picArr[i][j].red
final.blue = final.blue + picArr[i][j].blue
final.blue = final.green + picArr[i][j].green
}
}
final.finalize() //Averages all pixel/colors


}// END MAIN CLASS

Public Class Picture {
int red;
int blue;
int green;
int[][] pixel = new pixel[100][100];

public void finalize(){
for(int i = 0;i<100;i++){
for(int j = 0;j<100;j++){
this.red = this.red / 100;
this.blue = this.blue / 100;
this.green = this.green / 100;
}
}
}




And there you have it. The art would would be stored in the final variable in the main class waiting to be output. Perferable some sort of broader filter would be applied to the final image to make it a little softer but I think that would just dilute the data/art.

No comments:

Post a Comment