如何获取auto threshold Plugin使用的阈值

cha*_*ans 1 imagej

我有以下代码,我从目录中读取图像并使用ImageJ Auto Threshold插件来分割我的图像.

dir = getDirectory("path");
list = getFileList(dir);

for (i=0; i<list.length; i++)
{
   if (endsWith(list[i], ".tif")) 
   {
        open(dir + list[i]);
        run("8-bit");
        run("Gaussian Blur...", "sigma=2");
        setAutoThreshold("Otsu dark");
        run("Convert to Mask");
        saveAs("TIFF", dir+list[i]);
        close();
    }
}
Run Code Online (Sandbox Code Playgroud)

我想使用"Otsu dark"方法获取阈值,并修改该值(例如,将其缩放一个因子)并将其应用于我的图像以进行分割.

Jan*_*ger 5

在ImageJ宏中,使用getThreshold(lower,upper)setThreshold(lower,upper)方法(这里是文档).

您的代码如下所示:

dir = getDirectory("path");
list = getFileList(dir);
factor = 1.5;

for (i=0; i<list.length; i++)
{
   if (endsWith(list[i], ".tif")) 
   {
        open(dir + list[i]);
        run("8-bit");
        run("Gaussian Blur...", "sigma=2");
        setAutoThreshold("Otsu dark");
        getThreshold(lower,upper);
        setThreshold(lower,upper*factor);
        run("Convert to Mask");
        saveAs("TIFF", dir+list[i]);
        close();
    }
}
Run Code Online (Sandbox Code Playgroud)

如果您打算做更复杂的事情,请考虑使用斐济提供的其他脚本语言.