Make ImageJ 1.x work in the background

G22nd October 2018

Run ImageJ macro scripts in “batch mode” to improve performance and allow images to be processed in the background.

Macros are interpreted scripts that perform functions in ImageJ. Some macro functions that change pixel data will update the image to show the result. Displaying such updates uses additional memory and slows down the ImageJ macro. Additionally, the screen activity in ImageJ prevents the computer being used for other purposes whilst the macro is run.

The solution to this is to use BatchMode as follows:

setBatchMode(true); //Start batch mode
// do something
setBatchMode(false); //End batch mode


BatchMode should not be confused for batch processing (although I combine both these days).

Once a macro script is past the development stage and has been demonstrated to work reliably, enact BatchMode as this will allow macro functions to operate ‘in the background’ and use less memory.

A headless mode is available for scripts written for ImageJ2, but this is very much a work in progress and won’t work for ImageJ 1.x macro scripts.