Hi JP,
The macro function getThreshold(lowerTh,upperTh) returns the lower and upper threshold values set in the threshold dialogue.
I then convert the values into a string and use the setMetadata("Info", string) function to add the values to the metadata for the current image. This way, the information is kept with the image for re-use if needed.
Hope this helps,
Volko
-----Original Message-----
From: JP Dustin [mailto:
[hidden email]]
Sent: 22 June 2017 18:55
To:
[hidden email]
Subject: Saving threshold values using macro
I have a macro for analyzing images and would like to add something to save threshold values for each image. Is this possible and does anyone know how to do it? Below is the entire macro I use:
imageTitle=getTitle()
dir=getInfo("image.directory");
run("RGB Split");
selectWindow(imageTitle+" (green)")
if (isOpen(imageTitle+" (red)" ) ) {
close(imageTitle+" (red)" );
}
if (isOpen(imageTitle+" (blue)" ) ) {
close(imageTitle+" (blue)");
}
if (isOpen(imageTitle+" (green)" ) ) {
run("Select All");
run("Copy");
newImage(imageTitle+" Threshold", "8-bit black", 1360, 1024, 1);
run("Paste");
run("Subtract Background...", "rolling=5");
}
//run("Threshold...");
setThreshold(51,255);
waitForUser("Confirm Threshold Value and Select Apply");
run("Watershed");
run("Analyze Particles...", "size=12-100 show=Outlines display clear summarize add"); roiManager("Show None"); roiManager("Show None");
selectWindow(imageTitle+" Threshold");
close();
saveAs("Results", dir+ imageTitle+"_Counts.csv");
Thanks,
JP
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html