Macros 移动到ImageJ宏中的上一个图像

Macros 移动到ImageJ宏中的上一个图像,macros,imagej,Macros,Imagej,我正在使用ImageJ代码测量许多图片中的相同参数。我有一个曾经工作过的ImageJ代码。它要求找到包含图片的文件夹,然后您可以选择当前、下一张或上一张图片进行分析,并混合使用自动和用户界面数据收集项目。“previous”(上一个)选项现在被卡住,当您选择它时,您将停留在“current”(当前)图像上。另一个问题是西班牙的合作者需要手动打开第一个映像。我试着用I(在网上的某个地方见过)和-1替换s,但这并没有解决问题 //code to extract leaf morphology for

我正在使用ImageJ代码测量许多图片中的相同参数。我有一个曾经工作过的ImageJ代码。它要求找到包含图片的文件夹,然后您可以选择当前、下一张或上一张图片进行分析,并混合使用自动和用户界面数据收集项目。“previous”(上一个)选项现在被卡住,当您选择它时,您将停留在“current”(当前)图像上。另一个问题是西班牙的合作者需要手动打开第一个映像。我试着用I(在网上的某个地方见过)和-1替换s,但这并没有解决问题

//code to extract leaf morphology for oak leaves which is the saved as a csv file

//there should be a folder called 'Data' in the folder with the images where the csv file will be saved.
var ps = 1;
folder = getDirectory("Choose the folder with the pictures");
mfiles = getFileList(folder);
time = gettimestamp();
for (s=0; s<mfiles.length; s++) 
{   
open(folder + mfiles[s]);
run("Select None");
Dialog.create("Correct image?");
items = newArray("Next", "Previous","Current");
Dialog.addChoice("choose the image to perform operation", items, "Current")
Dialog.show() 
resp=Dialog.getChoice();
if (resp  == "Previous")
{
    s--;
    close();
}
else if(resp == "Next")
{
s++;
close();    
}
else if  (resp== "Current")
{
       current = mfiles[s];
        measure();
        close();
} 
}

function measure () {
    run("Select None");
     measured();
    savestuff();
}


//records color data about leaf
function measured () 
{
    bd = "[LeafColor]";
run("New... ", "name="+bd+" type=Table");
 // These lines are supposed to set up the table where data will be entered
print(bd, "\\Headings:Directory\tSample");
    wins = bd;
    Dialog.create(getInfo("image.filename"));

Sample=getTitle();



// here the data are supposed to be entered into the table created before
print(wins, getInfo("image.directory")+"\t"+Sample);

};
};

)
// to save everything 
function savestuff()
{
    bdd = "LeafColor";
    
Sample=getTitle(); //only 1 simple trait in this example version being the name of the image file

selectWindow(bdd);
    saveAs("Text", "" + folder + "/"+"Data/" + Sample + "_" + bdd + ".csv");

    if(isOpen("Results")==true){
        selectWindow("Results");
        run("Close");
    }
}

// to get time
function gettimestamp() {
    MonthNames = newArray("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
    getDateAndTime(year, month, dayOfWeek, dayOfMonth, hour, minute, second, msec);
    time = "" + dayOfMonth + "" + MonthNames[month] + "" + year + "_" + hour + "." + minute + "." + second;
    return time;
}
//提取橡树叶形态的代码,该形态保存为csv文件
//文件夹中应该有一个名为“Data”的文件夹,其中包含将保存csv文件的图像。
var-ps=1;
folder=getDirectory(“选择包含图片的文件夹”);
mfiles=getFileList(文件夹);
时间=gettimestamp();

对于(s=0;s,这里是Omkar Pawar的解决方案:

{   
open(folder + mfiles[s]);
run("Select None");
Dialog.create("Correct image?");
items = newArray("Next", "Previous","Current");
Dialog.addChoice("choose the image to perform operation", items, "Current")
Dialog.show() 
resp=Dialog.getChoice();
if (resp  == "Next")
{
    Next=s++;
    close();
}
else if(resp == "Previous")
{
    Previous=s--;
    close();    
}
else if  (resp== "Current")
{
       current = mfiles[s];
        measure();
        close();
} 
}