I am trying to write a macro for ImageJ that processes the images in the specified folder through the OrientationJ Vector Field plugin, and then saves the outputted results tables into a separate folder. The issue is that when I run the macro, the OrientationJ Vector Field's dialogue box pops up however the results are not saved anywhere. I am not sure what I am doing incorrectly, and it would be much appreciated if someone could help me. The code for my macro is shown below, thanks.
dir1 = getDirectory("Choose Source Directory ");
dir2 = getDirectory("Choose Destination Directory ");
list = getFileList(dir1);
setBatchMode(true);
for (i=0; i<list.length; i++) {
showProgress(i+1, list.length);
filename = dir1 + list[i];
if (endsWith(filename, "tif")) {
open(filename);
run("8-bit");
run("OrientationJ Vector Field");
run("OrientationJ Vector Field", "tensor=2.0 gradient=0 radian=on vectorgrid=50 vectorscale=80.0 vectortype=0 vectoroverlay=off vectortable=on ");
saveAs("Results", dir2+list[i]+".csv");
close();
}
}