Loops 为什么我的for循环没有增加增量?
我正在imagej中编写一个宏来对文件夹中的照片进行批处理分析。当我运行宏时,代码似乎只运行了一次,而没有移动到下一个文件。我相信这是我的代码块中的一个问题,而不是实际的for语句。如果有人能指出这可能是什么原因,我将不胜感激。代码复制如下。for循环从第23行开始,它运行的函数是第32行Loops 为什么我的for循环没有增加增量?,loops,for-loop,imagej,Loops,For Loop,Imagej,我正在imagej中编写一个宏来对文件夹中的照片进行批处理分析。当我运行宏时,代码似乎只运行了一次,而没有移动到下一个文件。我相信这是我的代码块中的一个问题,而不是实际的for语句。如果有人能指出这可能是什么原因,我将不胜感激。代码复制如下。for循环从第23行开始,它运行的函数是第32行 Dialog.create("Our Batch Analysis"); //providing choises about analysis Dialog.addNumber("Min Size",
Dialog.create("Our Batch Analysis"); //providing choises about analysis
Dialog.addNumber("Min Size", 1000);
Dialog.addNumber("Max Size", 9999999);
Dialog.addCheckbox("View Obect Outlines", false);
smoothArray=newArray("Mean...", "Median...", "None");
Dialog.addChoice("Smooth Filter", smoothArray, "Mean");
Dialog.show();
our_min=Dialog.getNumber(); //assigning the collected values to variables to be used in analyzeImage
our_max=Dialog.getNumber();
our_outlines=Dialog.getCheckbox();
our_smooth=Dialog.getChoice();
our_dir=getDirectory("Choose Source Directory"); //Choosing the folder to analyze
our_list=getFileList(our_dir);
for(i=0; i<our_list.length; i++) //cycling through images in folder
{
if(endsWith(our_list[i],".jpg")) //only analyzing images no text files
{
open(our_dir + our_list[i]);
analyseImage();
}
}
analyseImage(); //declaring function
function analyseImage()
{
origTitle= getTitle () ; //creating a callable title
run("Duplicate...", "title=duplicate"); //making a duplicate file to work with without affecting original
run("Gaussian Blur...", "sigma=2");
if(our_smooth!="None") //making smoothing conditional
{run(our_smooth, "radius=2");
setAutoThreshold("Default"); //setting a threshold to differentiate background
setThreshold(0, 127);
setOption("BlackBackground", true);
run("Convert to Mask"); //turning the image binary
run("Watershed");
run("Set Measurements...", "area mean shate display redirect=[" + origTitle + "] decimal =2");
if(our_outlines==true)
{
run("Analyze Particles...", "size=" +our_min+"-"+our_max+" circularity =0.80-1.00 show=Outlines display exclude");
rename(origTitle+"-outlines");
selectWindow(origTitle+"-outlines");
close();
}
else
{
run("Analyze Particles...", "size=" +our_min+"-"+our_max+" circularity =0.80-1.00 show=Nothing display exclude"); //counting how many particles exist based on given parameters
}
selectImage(origTitle); //closing unwanted tabs
close();
selectImage("duplicate");
close();
}
Dialog.create(“我们的批量分析”)//提供有关分析的选择
对话框.addNumber(“最小尺寸”,1000);
对话框.addNumber(“最大尺寸”,999999);
addCheckbox(“查看对象轮廓”,false);
smoothArray=newArray(“平均值…”、中值…”、无”);
addChoice(“平滑过滤器”、平滑数组、“平均值”);
Dialog.show();
我们的_min=Dialog.getNumber()//将收集的值分配给analyzeImage中使用的变量
我们的_max=Dialog.getNumber();
我们的_outlines=Dialog.getCheckbox();
我们的_smooth=Dialog.getChoice();
我们的_dir=getDirectory(“选择源目录”)//选择要分析的文件夹
我们的目录=getFileList(我们的目录);
for(i=0;i函数没有完成,因此for循环没有增加。您可以在函数末尾添加一个return语句,告诉循环函数已经完成。我还提高了代码的可读性。请注意,不需要额外调用analyseImage()
Dialog.create(“我们的批处理分析”);//提供有关分析的选项
对话框.addNumber(“最小尺寸”,1000);
对话框.addNumber(“最大尺寸”,999999);
addCheckbox(“查看对象轮廓”,false);
smoothArray=newArray(“平均值…”、中值…”、无”);
addChoice(“平滑过滤器”、平滑数组、“平均值”);
Dialog.show();
我们的_min=Dialog.getNumber();//将收集的值分配给analyzeImage中使用的变量
我们的_max=Dialog.getNumber();
我们的_outlines=Dialog.getCheckbox();
我们的_smooth=Dialog.getChoice();
我们的_dir=getDirectory(“选择源目录”);//选择要分析的文件夹
我们的目录=getFileList(我们的目录);
//循环浏览文件夹中的图像
对于(i=0;i