Take a look at the Bar>Segmentation>Threshold From Background
you can get this by selecting the Bar update site in Fiji. You can then
look at the source, which is a few lines of macro code that get the
relevant statistics. You can modify the setThreshold line to set the
threshold to twice the mean.
For your convenience I pulled out from the Bar_.jar file.
/* Threshold_From_Background.ijm
* IJ BAR:
https://github.com/tferr/Scripts#scripts *
* Sets the threshold as the ROI average plus a factor of its standard
deviation. To call it from
* other scripts (see
http://imagej.net/BAR for details):
*
* tfbpath =
call("bar.Utils.getSegmentationDir")+"Threshold_From_Background.ijm";
* runMacro(tfbpath, 3);
*
* TF 2014.06
*/
if (selectionType==-1)
exit("A background-defining ROI is\nrequired but none was found.");
factor = getArgument();
if (factor=="")
factor = getNumber("Multiplier (Mean + ??*SDeviation):", 3);
getStatistics(area, mean, min, max, std);
setThreshold(mean+factor*std, pow(2, bitDepth));
--aryeh
On 17/07/2019 9:05, Mymy wrote:
> Hi all, I am writing a macro where measurements are made after thresholding
> using 2 times the mean of a specific ROI. Does anyone know what code I could
> use where the mean gray value of an ROI (8-bit image) is measured and
> sequentially is used for setting the threshold limit? Thanks in advance!
>
>
>
> --
> Sent from:
http://imagej.1557.x6.nabble.com/>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>
--
Aryeh Weiss
Faculty of Engineering
Bar Ilan University
Ramat Gan 52900 Israel
Ph: 972-3-5317638
FAX: 972-3-7384051
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html