ImageJ批量图像转换

ImageJ batch image conversion

我正在尝试使用 ImageJ 中的批处理脚本批量转换 200 多个原始 .img 文件。我的脚本:

//-----------Code starts here--------------------- 
dir1 = getDirectory("path/source"); 
dir2 = getDirectory("path/target"); 
list = getFileList(dir1); 
setBatchMode(true); 

 for (i=0; i<list.length; i++) { 
      showProgress(i+1, list.length); 
      if(endsWith(list[i],".IMG")) 
         run("Raw...", open=["+dir1+list[i]+"] image=[16-bit Unsigned] width=2048 height=2048 offset=359 number=1 gap=0"); 
      else 
         open(dir1+list[i]); 
      saveAs(format, dir2+list[i]); 
      close(); 
   } 

但是,当我尝试 运行 时,出现以下错误:

不过我不确定为什么,因为我有一个 ;关闭线路...

该错误消息具有误导性,因为您在 run():

的第二个参数的开头缺少引号 (")
run("Raw...", "open=["+dir1+list[i]+"] image=[16-bit Unsigned] width=2048 height=2048 offset=359 number=1 gap=0");

错误消息中的<>字符表示解析器发现异常的位置。

我编辑了您的原始代码以包括语法突出显示,这有助于查找此类错误。 Fiji 的 script editor 包括语法高亮,在使用 ImageJ 宏时推荐使用。

一般来说,ImageJ 的特定问题在专门的论坛上发布时更有可能得到及时解答:http://forum.imagej.net/