0

我在一个文件夹中有一组图像,它们的名称是: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");
4

0 回答 0