The content of this page has not been vetted since shifting away from MediaWiki. If you’d like to help, check out the how to help guide!
Overview
A fundamental benefit to creating scripts and macros in ImageJ is the ability to reuse their functionality on more than one image. Although this can be done manually, there are multiple ways to easily automate this batch processing.
General workflow
- Create a basic macro/script which operates on the active image or on a single file.
- The macro recorder is an excellent way to generate macro code.
- The Introduction into Macro Programming explains the principles of macro writing.
- Apply your macro to a group of images.
- These images do not need to be open in ImageJ already—they will be read in as part of the batch process.
- See below for details.
Option 1 - Process › Batch › Macro…
The fastest way to start batch conversion is via the Process › Batch › Macro… command. This will open a dialog (below) that will allow you to specify an input and output directory. You can select an output file format, and then use the Add Macro Code
drop-down to generate a macro with the desired functionality.
Option 2 - Script Template
This section requires ImageJ2.
Open the script editor, select Templates › ImageJ 1.x › Batch › Process Folder (ImageJ Macro). This will generate the following boilerplate:
Lines 26 and 27 can now be edited, replaced with the functional macro code you would like to apply to all images of a given type in a folder. Furthermore you can now modify the batch processing logic itself, for example if you need to customize what (if any) output information is saved.
Option 3 - Batch Processing with Script Parameters
This section is currently being expanded to document the current state of the SciJava Batch Processor. The Batch Processor is a new addition to the SciJava/ImageJ2 framework. If you encounter any issues, please report/ask on the forum.
See also
- Process › Batch submenu.
- Scripting documentation and tutorials.
- How to apply a common operation to a complete directory
- Assign your own keyboard shortcuts