Last active
December 22, 2015 03:59
-
-
Save gwygonik/6414176 to your computer and use it in GitHub Desktop.
Basic exponentially reducing circle image processing for Processing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PImage imgOriginal, imgNew; | |
color c; | |
void setup() { | |
imgOriginal = loadImage("IMG_6319.jpg"); // load image here | |
hint(DISABLE_DEPTH_TEST); | |
blendMode(MULTIPLY); | |
imgNew = new PImage(1200,600); | |
imgNew.copy(imgOriginal,0,0,imgOriginal.width,imgOriginal.height,0,0,1200,600); // stretch original image to size | |
size(imgNew.width,imgNew.height); | |
background(255); | |
for (int i=0;i<5;i++) { | |
int sz = (int)(80/pow(2,i)); | |
for (int y=0;y<height+40;y+=40) { | |
for (int x=0;x<width+40;x+=40) { | |
color c1 = imgNew.get(x-sz,y); | |
color c2 = imgNew.get(x+sz,y); | |
color c3 = imgNew.get(x,y-sz); | |
color c4 = imgNew.get(x,y+sz); | |
// use average if not the smallest dot, in which case use the color at the center point | |
if (i != 4) { | |
c = color((red(c1)+red(c2)+red(c3)+red(c4))/4,(green(c1)+green(c2)+green(c3)+green(c4))/4,(blue(c1)+blue(c2)+blue(c3)+blue(c4))/4); | |
} else { | |
c = imgNew.get(x,y); | |
} | |
fill(c,200); | |
noStroke(); | |
ellipse(20+x,20+y,sz,sz); | |
} | |
} | |
} | |
} | |
void draw() { | |
} | |
void keyPressed() { | |
if (key == ' ') { | |
save("image_"+millis()+".png"); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment