I am trying to write an imageJ macro that will
1) Open and split an image into two channels 2) Perform particle analysis on each image and save measurements 3) Save the original image with the particle outlines overlayed
So far I have realised I need to first duplicate the original image so that the ROI can later be saved on top of this. However I at the moment I can't figure out how to rename this duplicated image so I can later select it for flattening:
dir=getDirectory("Choose a Directory");
print(dir);
greenDir=dir + "/Green/";
blueDir=dir + "/Blue/";
print(greenDir);
print(blueDir);
File.makeDirectory(greenDir);
File.makeDirectory(blueDir);
list = getFileList(dir);
for (i=0; i<list.length; i++) {
if (endsWith(list[i], ".tif")){
print(i + ": " + dir+list[i]);
open(dir+list[i]);
imgName=getTitle();
baseNameEnd=indexOf(imgName, ".tif");
baseName=substring(imgName, 0, baseNameEnd);
run("Split Channels");
selectWindow("C1-" + imgName);
run("Duplicate...", "title= imgName + "original");
selectWindow("C1-" + imgName);
setAutoThreshold("Default dark");
//run("Threshold...");
//setThreshold(1, 255);
run("Convert to Mask");
run("Analyze Particles...", "size=60-Infinity pixel show=Outlines display exclude summarize add");
selectWindow(imgName + "original");
roiManager("Show All without labels");
run("Flatten");
saveAs("Tiff", greenDir + baseName + "green.tif");
close();
Sorry in advance if this is something very simple, this is all very new to me and learnt off googling!