rendered paste bodyint _w;int _h;PImage img;String path_to_img = "d:\\face.jpg";// display flagboolean display = false;// tile sizeint tile_s = 10;// circle sizeint radius = tile_s / 2 ; int loclr = 0x0;int hiclr = 0xDE2626;float max_bright = 255.0f;void setup(){ background(loclr); // fill(0xde2626); img = loadImage(path_to_img); _w = img.width; _h = img.height; size(_w,_h); img.loadPixels(); process(); //subsample(8,8,8,_w,_h,img.pixels); img.updatePixels(); // debug if(display)image(img);}void draw(){}void process(){ for(int y = 0; y < _h; y += tile_s) { for(int x = 0; x < _w; x += tile_s) { int[] sub = subsample(x,y,tile_s,_w,_h,img.pixels); float c = avg_bright(sub); float f = c / max_bright; float rf = (float)Math.ceil(tile_s * f); int t_half = tile_s / 2; ellipse(x, y ,rf, rf); } }}void image(PImage i){ image(i,0,0);}int[] subsample(int x, int y, int s, int w, int h, int[] img){ if(s > w || s > h) return null; // counters int n = 0; int m = 0; int[] buffer = new int[s*s]; int bpos = 0; // position markers int v_off = (y * w); int pos = x + (v_off); int end = ((s-1) + ((s-1) * w))+pos; //println("pos: "+pos+" end: "+end); // old ((v_off)+(w-s+1)) for(int i = pos; i <= end; i += ((++n) % s) == 0 ? ((w-s)+1) : 1 ) { try { buffer[bpos++] = img[i]; } catch(Exception e) { // out of bounds } } return buffer; }float avg_bright(int[] subsample){ int len = subsample.length; int c = 0; for(int i = 0; i < len; i++) { c += (subsample[i] / len); } return (brightness(c));}int[] subsample(int x, int y, int s, int[] img){ return subsample(x,y,s,_w,_h,img);}