// This macro takes an image with a ".tif" extension, // inverts it, converts it to an 8-bit black and white format // and applies the automatic threshold called "Triangle", // saving the resulting image in another file with a ".tif" // extension and with the same name as the original file, // adding the suffix "_BN". // Then, it performs an automatic count of the particles // represented in the image and saves the result // in a file with a .csv extension with the same name // as the original file, adding the suffix "_DT". // ATTENTION // In the ImageJ program, the following settings for "Meassure" // and "Analyze particles" must have been established: // Set Measurments: "Area"(tick) and "Fit ellipse"(tick), "decimal places" = 3 // Analyze particles: 0-infinity; 0.00 - 1.00; "Show": Nothing; // Display results (tick) //RUN THIS MACRO FROM Process/Batch/Macro //Obtaining data from the image to be processed imagen=getTitle(); // Save the name of the active image // in the "imagen" variable procede = getDir("image"); // Save the path of the active image // in the "procede" variable //Gets the length of the source path (tricky) Trs=replace(procede, ":", "X"); Trs2=Trs+procede; longitud = indexOf(Trs2, procede); //Sets the path name where to save the results proc_red = substring(procede, 0, longitud-1); guardar_I_en = proc_red + "_BW"; guardar_D_en = proc_red + "_DT"; //Establishes the path where the results will be saved //and the name that will be given to the file Nimagen = replace(imagen, ".tif", ""); fichero_Im = guardar_I_en + "\\" + Nimagen + "_BN"; fichero_Data = guardar_D_en + "\\" + Nimagen + "_DT.csv"; //Image Processing to obtain the B&W thresholded image run("Invert"); run("8-bit"); run("Auto Threshold", "method=Triangle white"); //Saving the B&W thresholded image (folder "_BW") saveAs(".tif", fichero_Im); //Automatic particle counting run("Analyze Particles...", "display"); //Save the data saveAs("results", fichero_Data); Table.rename("Results", "Results-a"); //Para que no vaya acumulando todos los resultados enla misma tabla close(); run("Close");