宏,可在计算器中进行多张图像分析

时间:2018-11-19 23:38:44

标签: macros imagej imagej-macro

我在一个文件夹中有一组图像,它们的名称是:2 days.bmp 3 days.bmp ..... 28 days.bmp。另外,我还有一个文件夹,其中的背景图片名称完全相同。我想使用计算器加号并将每个图像划分为其相关背景。我想节省时间并同时进行操作,而不是针对每个图像一一进行。有什么想法我该怎么做?我已经写了一个宏,但是对我没用。

macro "Batch calculate images [1]" {

LocationOfFiles = getDirectory("Select Folder");

LocationOfbackgrounds = getDirectory("Select Folder of backgrounds");

LocationOfSave = getDirectory("Select Save Location");


setBatchMode(true);

FileList = getFileList(LocationOfFiles);

NumberOfFiles = FileList.length;

for (i=0; i<NumberOfFiles; i+=1) {

FileName = FileList[i];

pathtofile1 = LocationOfFiles+FileName;

open(pathtofile1);

name1 = getTitle();

pathtofile2 = LocationOfbackgrounds+FileName;

open(pathtofile2);

name2 = getTitle();

run("Calculator Plus", "i1="+name1+" i2="+name2+" operation=[Divide: i2 = (i1/i2) x k1 + k2] k1=255 k2=0 create");

selectWindow("Result");

SaveName = replace(name, ".bmp", "_backgroud subtracted.jpg");

saveAs("BMP", LocationOfSave+SaveName);

selectWindow(BackgroundImage);

close("\\Others");

0 个答案:

没有答案