Image Rasterizer
A creative code image visualizer.
Original
Photoshop
Code
PImage img;
void setup() { size(900, 900, P3D); img = loadImage("Brain.jpg"); //img = loadImage("Writing.png"); //img = loadImage("Work.jpg"); //img = loadImage("Toolbox.jpg"); img.resize(900, 900); }
void draw() {
background(0); fill(240); noStroke(); sphereDetail(1); float tiles = 300; float tileSize = width/tiles; push(); translate(width/2,height/2); rotateY(radians(frameCount)*2);
for (int x = 0; x < tiles; x++) { for (int y = 0; y < tiles; y++) { color c = img.get(int(xtileSize),int(ytileSize)); float b = map(brightness(c),0,255,1,0); float z = map(b,0,1,-75,75);
push(); translate(xtileSize - width/2, ytileSize - height/2, z); sphere(tileSizeb1.25); pop();
} }
pop();
int tilesX = 20; int tilesY = 20;
int tileW = int(width/tilesX); int tileH = int(height/tilesY);
for (int x = 0; x < tilesX; x++) { for (int y = 0; y < tilesY; y++) {
// source int sx = xtileW + int(random(-3, 3)); int sy = ytileH + int(random(-3, 3)); int sw = tileW; int sh = tileH;
// destination int dx = xtileW; int dy = ytileH; int dw = tileW; int dh = tileH;
copy(sx, sy, sw, sh, dx, dy, dw, dh);
} } //saveFrame("Brain-######.png"); }