// ImageJ Macro "RandomSamplePerimeterMethod.txt" // // This Macro is a modification of Gabriel Landini's RandomSampleAndMeasure.txt macro. // // The perimeter scan method of the retangle area is implemented here improving the // macro's speed as suggested by Landini. // Now the user can interact with the code by choosing the scan method (for comparison purpose) // and inform the parameters by a Dialog Window. // Another improvement is the use of the setBatchMode command that's really speed up the process. // In this Macro, the process can be monitored by ImageJ progress bar. // // // Author: // Roberto Sotto-Maior Fortes de Oliveira, MSc,PhD // Center of Reproductive Biology // Juiz de Fora Federal University // Brazil // email: roberto@aparelho.com // // *The author was supported by FAPEMIG - // Fundacao de Amparo a Pesquisa de Minas Gerais // var flag=-1; saveSettings(); original=getTitle(); setForegroundColor(255,0,0); setBatchMode(true);// Speed up the entire process // create the Dialog Dialog.create("Random Sample Configuration Dialog"); Dialog.addNumber("Roi Box Size:", 30);// This is a Box Roi; width and height are equal Dialog.addNumber("Number of Samples:", 50); // Number of Samples Dialog.addNumber("Max.Trials:", 1000);// avoid infinite loop Dialog.addCheckbox("Fill Method", false); // Perimeter Method by Default Dialog.addCheckbox("Show Process", false); // No Show by Default Dialog.show(); RoiSize = Dialog.getNumber(); RoisN = Dialog.getNumber(); Trials = Dialog.getNumber(); Method = Dialog.getCheckbox(); ProcessShow = Dialog.getCheckbox(); // width = getWidth()-RoiSize; // width of ROi height = getHeight()-RoiSize; // height of ROI i=0; j=0; xa=newArray(RoisN); ya=newArray(RoisN); if (ProcessShow==true) { setBatchMode(false); } run("Duplicate...", "title=Reference"); run("8-bit"); //make it greyscale run("RGB Color"); //RGB to display colours while (i