PImage b, c; float x,y; // variables for position float r, theta; // variables for sacaddic motion // variables for zoom float zoom; float next_z, last_z; static float MIN_ZOOM = 0.75; static float MAX_ZOOM = 1.25; float n; static float n_inc = 1; int win_width; int win_height; // variables for auto-constrast int i_min, i_max; static float discard = 0.0001; PFont fontA; static int JUMP_POINT = 40; int saccade_length; // Set to 4 for 1/4 size Preview static int DIV = 1; // variables for logging of timing String outpath="output\\s_ff_blur_02\\"; PrintWriter output; static boolean writeToFile=false; static boolean repeat=true; void setup() { size(screen.width/DIV, screen.height/DIV);//, 800); background(0); b=loadImage("01_06_western landscape.jpg"); //b=loadImage("/Users/rtwomey/Pictures/scavenging/industry/bethlehem steel works3.jpg"); //b=loadImage("/Users/rtwomey/Pictures/scavenging/industry/akron works 1907 6a34570u.jpg"); // b=loadImage("/Users/rtwomey/Pictures/scavenging/industry/bethlehem steel works 6a19958u.jpg"); //b=loadImage("/home/robert/Desktop/Photos/03_washington dc bedroom 2.jpg"); //b=loadImage("C:\\Swap\\Photos\\03_washington dc bedroom 2.jpg"); //b=loadImage("C:\\Swap\\Photos\\01_06_western landscape.jpg"); win_height=int(b.height*0.4/DIV); win_width=int(b.width*0.4/DIV); x=0; y=int(random(b.height-win_height)); saccade_length=JUMP_POINT; n=JUMP_POINT+1;//0; //theta=(random(-1, 1) > 0) ? HALF_PI : (3*HALF_PI); //r=random(30,80); //zoom=1.0; zoom=random(MIN_ZOOM, MAX_ZOOM); last_z=zoom; next_z=constrain(last_z*random(0.9, 1.1), MIN_ZOOM, MAX_ZOOM); frameRate(24); // for frameRate display fontA = loadFont("CourierNew36.vlw"); textFont(fontA, 32); // store initial auto-contrast params // c = b.get(round(x), round(y+y_corner), win_width, win_height); // calc_contrast(c); if(writeToFile) { // setup up timing log file output = createWriter(outpath+"timing.txt"); }; } void calc_contrast(PImage in) { // adjust contrast in place on input image in.loadPixels(); // loop over pixels to find min and max Intensity int dimension = (in.width*in.height); int [] hist = new int[256]; for(int i=0;i> 16) & 0xFF; // Faster way of getting red(rgb) int g = (argb >> 8) & 0xFF; // Faster way of getting green(rgb) int b = argb & 0xFF; // Faster way of getting blue(rgb) int intensity=int((r+g+b)/3); hist[intensity]++; }; i_min=0; int threshold = int(dimension*discard); int sum=0; while(sum> 24) & 0xFF; //int bin_a = argb & 0xFF000000; int r = (argb >> 16) & 0xFF; // Faster way of getting red(rgb) int g = (argb >> 8) & 0xFF; // Faster way of getting green(rgb) int b = argb & 0xFF; // Faster way of getting blue(rgb) r=int(constrain(map(r, i_min, i_max, 0, 255), 0, 255)); g=int(constrain(map(g, i_min, i_max, 0, 255), 0, 255)); b=int(constrain(map(b, i_min, i_max, 0, 255), 0, 255)); a = (a>>1) << 24; r = r << 16; g = g << 8; b = b; color new_rgb = a | r | g | b; in.pixels[i]= new_rgb; }; in.updatePixels(); }; void draw() { if(n>saccade_length) { r=random(30, 180); theta=(TWO_PI+HALF_PI*random(-0.95, 0.95))%TWO_PI; n=0; saccade_length=int(random(30, 60)); last_z=next_z; next_z=constrain(last_z*random(0.9, 1.1), MIN_ZOOM, MAX_ZOOM); }; // update motion x+=(cos(theta)*(r/(n+1)-1))*n_inc; y+=(sin(theta)*(r/(n+1)-1))*n_inc; //zoom+=d_z; n+=n_inc; zoom=lerp(last_z, next_z, n/saccade_length); y=constrain(y, 0, b.height-win_height); if(x+win_width>b.width) { // end condition if(writeToFile) { output.flush(); // Writes the remaining data to the file output.close(); // Finishes the file }; if(!repeat)exit(); x=0; y=int(random(b.height-win_height)); }; c = b.get(round(x), round(y), round(win_width*zoom), round(win_height*zoom)); calc_contrast(c); adjust_contrast(c); blend(c, 0, 0, win_width, win_height, 0, 0, width, height, BLEND); //filter(ERODE); //saveFrame("/Volumes/Swimming Pool/Processing/west-#####.tif"); //saveFrame("C:\\Data\\01_06_western landscape/01_06_western landscape-#####.tif"); if(writeToFile) { saveFrame(outpath+"03_washington dc bedroom 2-#####.tif"); output.println(frameCount+" "+millis()); }; println(frameCount+" "+millis()); // fill(255); // text(frameRate, 15, 20); //y=random(0,5); //w=random(-5,0); } //void mouseMoved() { // ac_center = int(255.0*float(mouseX)/float(width)); // ac_width= int(255.0*float(mouseY)/float(height)); //}