// extract frames for the voxel growth movie from the given images and sprocket coordinates // frame dimensions and offset from baseline // (dependent on the resolution of the micrographs) int Width = 320; int Height = 240; int Offset = 72; // these are the names of the micrograph image files, and their asociated sprocket coordinate files String[] filenames = { "IMG_2511", "IMG_2510", "IMG_2509", "IMG_2508", "IMG_2507", "IMG_2506", "IMG_2505", "IMG_2504", "IMG_2503", "IMG_2502", "IMG_2501", "IMG_2500", "IMG_2499", "IMG_2498", "IMG_2497", }; void setup() { int frameNum = 0; for (int i = 0; i < filenames.length; i++) { // load the original image PImage img; img = loadImage("input/" + filenames[i] + ".JPG"); // load its associated sprocket coordinates Table coords = loadTable("input/" + filenames[i] + ".txt", "header, tsv"); for(int j = 0; j < coords.getRowCount(); j += 2) { TableRow left = coords.getRow(j); TableRow right = coords.getRow(j + 1); // find y position of the frame float y = 10.0 - (left.getFloat("y") + right.getFloat("y")) / 2.0; y *= img.height / 10.0; y -= Offset; // find x position of the frame float x = (left.getFloat("x") + right.getFloat("x")) / 2.0; x *= img.width / 10.0; x -= Width / 2.0; // copy the frame into a new image PImage frame = createImage(Width, Height, RGB); frame.copy(img, (int)(x + 0.5), (int)(y + 0.5), Width, Height, 0, 0, Width, Height); // and save it frame.save("output/" + frameNum + ".png"); println(frameNum); frameNum++; } } println("done"); }