roiManager("Reset"); run("Clear Results"); run("Set Measurements...", "area display redirect=None decimal=3"); wait(100); waitForUser("Open the correct image and press OK"); imgName=getTitle(); rename("Original") run("Duplicate...", "title=A"); run("Duplicate...", "title=B"); selectWindow("B") setTool("line"); run("Select None"); waitForUser("Select a line in the image with a known distance (only for first video), skip if you know the scale.\nMake sure Global is selected.") run("Set Scale..."); setTool("polygon"); waitForUser("In B, select the floor area around the marbles in the LEFT cage.\nPress and hold shift, then select the floor area around the marbles of the RIGHT cage.\nPress 'OK' when done.") run("Make Inverse"); run("Clear", "slice"); selectWindow("B") // Color Thresholder 1.51j // Autogenerated macro, single images only! min=newArray(3); max=newArray(3); filter=newArray(3); a=getTitle(); run("HSB Stack"); run("Convert Stack to Images"); selectWindow("Hue"); rename("0"); selectWindow("Saturation"); rename("1"); selectWindow("Brightness"); rename("2"); min[0]=5; max[0]=40; filter[0]="stop"; min[1]=0; max[1]=255; filter[1]="pass"; min[2]=1; max[2]=255; filter[2]="pass"; for (i=0;i<3;i++){ selectWindow(""+i); setThreshold(min[i], max[i]); run("Convert to Mask"); if (filter[i]=="stop") run("Invert"); } imageCalculator("AND create", "0","1"); imageCalculator("AND create", "Result of 0","2"); for (i=0;i<3;i++){ selectWindow(""+i); close(); } selectWindow("Result of 0"); close(); selectWindow("Result of Result of 0"); rename(a); // Colour Thresholding------------- //run("Color Threshold..."); //waitForUser("Perform color thresholding. SETTINGS:\nHue:\n5\n40\nDeselect Pass on the right side of the Hue window.\n\nSaturation:\n0\n255\nMake sure Pass has a tickmark next to //it.\n\nBrightness:\n1 (!!!!!!!!!!!!!!!!!!!!!!!!!!!!)\n255\nMake sure Pass has a tickmark next to it.\n\n\nMake sure Dark background has a tickmark next to it.//\nThen press OK to continue."); //run("Convert to Mask"); selectWindow("B") run("Create Selection"); run("Analyze Particles...", "size=60-6000 pixel show=Masks include add"); selectWindow("B") close(); selectWindow("Mask of B") roiManager("Show All"); selectWindow("Original") roiManager("Show All"); setTool("freehand"); waitForUser("1)\n \nLook at the windows 'Original' and 'Mask of B' side by side.\nIn the 'Original' window, draw around any areas you want to add and press 'F'. \nTo remove areas select the area and press edit -> clear") roiManager("Reset"); run("Clear Results"); //NEW wait(100); selectWindow("Original") setTool("polygon"); waitForUser("In Original, select the floor area around the marbles in the LEFT cage.\nPress and hold shift, then select the floor area around the marbles of the RIGHT cage.\nPress 'OK' when done.") run("Make Inverse"); run("Clear", "slice"); selectWindow("Original") // Color Thresholder 1.51j // Autogenerated macro, single images only! min=newArray(3); max=newArray(3); filter=newArray(3); a=getTitle(); run("HSB Stack"); run("Convert Stack to Images"); selectWindow("Hue"); rename("0"); selectWindow("Saturation"); rename("1"); selectWindow("Brightness"); rename("2"); min[0]=5; max[0]=40; filter[0]="stop"; min[1]=0; max[1]=255; filter[1]="pass"; min[2]=1; max[2]=255; filter[2]="pass"; for (i=0;i<3;i++){ selectWindow(""+i); setThreshold(min[i], max[i]); run("Convert to Mask"); if (filter[i]=="stop") run("Invert"); } imageCalculator("AND create", "0","1"); imageCalculator("AND create", "Result of 0","2"); for (i=0;i<3;i++){ selectWindow(""+i); close(); } selectWindow("Result of 0"); close(); selectWindow("Result of Result of 0"); rename(a); // Colour Thresholding------------- //run("Color Threshold..."); //waitForUser("Perform color thresholding. SETTINGS:\nHue:\n5\n40\nDeselect Pass on the right side of the Hue window.\n\nSaturation:\n0\n255\nMake sure Pass has a tickmark next to it.\n\nBrightness:\n1 (!!!!!!!!!!!!!!!!!!!!!!!!!!!!)\n255\nMake sure Pass has a tickmark next to it.\n\n\nMake sure Dark background has a tickmark next to it.\nThen press OK to continue."); //run("Convert to Mask"); selectWindow("Original") run("Create Selection"); run("Analyze Particles...", "size=60-6000 pixel show=Masks include add"); selectWindow("Original") close(); selectWindow("Mask of Original") roiManager("Show All"); selectWindow("A") roiManager("Show All"); waitForUser("succes!!"); selectWindow("Mask of B"); run("Select None"); roiManager("Deselect"); roiManager("Delete"); selectWindow("Mask of Original"); setTool("rectangle"); waitForUser("In Mask of Original, select area around marbles in LEFT cage and press OK"); run("Duplicate...", "title=[Left cage]"); selectWindow("Mask of Original"); setTool("rectangle"); waitForUser("In Mask of Original, select area around marbles of RIGHT cage and press OK"); run("Duplicate...", "title=[Right cage]"); selectWindow("Mask of Original"); close(); selectWindow("Left cage"); run("Analyze Particles...", "size=60-6000 pixel show=Masks display include add"); selectWindow("Right cage"); run("Analyze Particles...", "size=60-6000 pixel show=Masks display include add"); waitForUser("Marble areas are in the results window"); selectWindow("Results"); d = getDirectory("Choose directory where to save output"); saveAs("results", d +"Results_" + imgName + ".txt"); waitForUser("Finished! Move on to the next image :) "); roiManager("Reset"); run("Clear Results"); run("Close All"); wait(100);