Macro for multiple images analysis in the calculator plus

334 views Asked by At

I have a set of images in a folder which their names are: 2 days.bmp 3 days.bmp ..... 28 days.bmp. Also, I have a folder with the background images exactly with the same names. I want to use the calculator plus and divide each image to its relevant background. I want to save time and do that at the same time instead of doing it for each image one by one. Is there any idea how can I do that? I have written a macro but it didn't work for me.

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

There are 0 answers