PImage b; PFont font; String path = "allimages/"; int episodeNumbers = 1; int episodeLength = 60; String[][] episodeNames = { {"30rock_05", "30 Rock"} ,{"boredtodeath_05", "Bored to Death"} ,{"dexter_05", "Dexter"} ,{"glee_05", "Glee"} ,{"sexandthecity_05", "Sex and the City"} ,{"twinpeaks_05", "Twin Peaks"} }; int imageWidth = 15; int imageHeight = 9; int ypos = 50; int yPosMargin = 10; int xPosMarginText = 20; int xPosMarginImage = 100; int secondRow = 0; String episodeText = "ep."; void setup () { size (900, 175); smooth(); background (225); colorMode(RGB, 255,255,255,100); // setting colormode noLoop(); loadAllEpisodes (); } void loadAllEpisodes () { font = loadFont("DIN-Bold-25.vlw"); textFont(font, 25); fill(0); text ("Series Comparison", xPosMarginText, 30); font = loadFont("DIN-Regular-12.vlw"); textFont(font, 12); for (int i = 0; i < episodeNames.length; i++) { loadImages(i); fill(0); text (episodeNames[i][1], xPosMarginText, ypos + i * (imageHeight + yPosMargin) + imageHeight/2 + 4); } } void loadImages (int episodeNum) { for (int i = 1; i < 60; i++) { String imageNumber = nf (i, 4); //allimages//boredtodeath_05/boredtodeath_05_0002.jpg //boredtodeath_05/boredtodeath_050002 String fileName = episodeNames[episodeNum][0] + "/" + episodeNames[episodeNum][0] + imageNumber + ".jpg"; String modifiedPath = path + "/" + fileName; println (modifiedPath); b = loadImage(modifiedPath); if (b != null) { int xPos = xPosMarginImage + i * imageWidth; int yPos = ypos + episodeNum * (imageHeight + yPosMargin); // image(b, xPosMarginImage + s * imageWidth, ypos + episodeNum * (imageHeight + yPosMargin) , imageWidth, imageHeight); getPixels (b, xPos, yPos + secondRow); } else { break; } } } void getPixels (PImage img, int xPos, int yPos) { float totalR = 0; float totalG = 0; float totalB = 0; for (int x = xPos; x < xPos + imageWidth; x++) { for (int y = yPos; y < yPos + imageHeight; y++ ) { int loc = x + y * imageWidth; loadPixels(); float r = red(img.pixels[loc]); float g = green(img.pixels[loc]); float b = blue(img.pixels[loc]); // int r = (loc >> 16)&0xff; // int g = (loc >> 8) &0xff; // int b = (loc)&0xff; totalR += r; totalG += g; totalB += b; } } int totalPixels = imageWidth * imageHeight; totalR = totalR/ totalPixels; totalG = totalG/ totalPixels; totalB = totalB/ totalPixels; noStroke (); fill(totalR,totalG,totalB,100); rect(xPos, yPos, imageWidth, imageHeight); } void keyPressed() { if (key == 's') { save("results/" + "dexter" + "_" + hour() + "_" + minute() + "_" + second() + ".png"); }; };