ImageJ Macro: Undefined Variable when saving an image to a directory

1.3k Views Asked by At

When I am changing open image window it forgets the directory, how can I retrieve it to save again This is how I create a direcotry in Stack image folder

dir=getDirectory("image");
print(dir)
splitDir= dir + "OneChannel";
File.makeDirectory(splitDir);
print(splitDir); 

This is where I change the active image window to Montage.tiff to save it to splitDir folder

title= getTitle()
saveAs("tiff",splitDir+title);

The error is undefined variable. Should I make global splitdir to keep it when I change the active image window

Error:      Undefined variable in line 2:
        saveAs ( "tiff" , <splitDir> + title ) ; 

Thanks in advance

1

There are 1 best solutions below

1
On

Variables in ImageJ macros are case-sensitive. In your code you have defined splitDir but have not defined splitdir, hence the error. Change the line to saveAs("tiff",splitDir+title); and it should work.