Cedric
Image Mosaic
Feb 7th , 2009, 5:53am
As i have never worked with images before i thought i give it a try and make some image Mosaic creator... Just brightness, not in color this time... What i came up with until now is, filling the sketch with tiles and taking the brightness out of the source image and recreate it with recangles... Now I have to bring these two things together... Actually i think i know what i have to do right now, but i just dont know how. i guess i have to read through all my images at first and get the average brightness and save it somehow so that i can easily choose the right image corresponding to the "gray" value, i use right now to fill the rect. How would i do that, and doesnt it take very longt? Im planning to use about 2500 tiles... Wouldnt it be better to precalculate the brightness rename the images like : no1_value256.gif and so one? Just dont know how to go on at this point. Would be thankful for some hints and help. You can download it with some tiles here: http://www.dec32.de/public/mosaic.zip And here is the Source -------------------------------------------- Cube[] cube = new Cube[100000]; int tileCount = 6; //tiles in data folder PImage[] tile = new PImage[tileCount]; float[] tileValue= new float[tileCount]; PImage seed; int colCount; int rowCount; int cubeCount = 0; void setup(){ size( 500, 500 ); frameRate( 24 ); smooth(); background(255); noLoop(); noStroke(); seed = loadImage("20x20.gif"); // image to resemble colCount= seed.width; rowCount= seed.height; //loading tiles for ( int i = 0; i< tile.length; i++ ){ tile[i] = loadImage( i + ".gif" ); } for(int i = 0; i < rowCount;i++){ for(int j = 0; j < colCount;j++){ cube[cubeCount] = new Cube(i*width/colCount,j*width/rowCount,width/colCount,height/rowCount,brightness (seed.get(int(i),int(j)))); cubeCount+=1; } } } void draw(){ background(255); for(int i = 0; i< rowCount*colCount; i++){ cube[i].display(); } } class Cube{ float x; float y; float w; float h; float gray; Cube(float _x, float _y, float _h, float _w, float _gray) { x = _x; y = _y; w = _w; h = _h; gray = _gray; } void display() { //just for testing fill(gray,100); rect(x,y,w,h); // image(tile[int(random(tileCount))],x,y,w,h); } }