Difference between revisions of "Batch Processing"

(Add link to Process > Batch > Macro... entry in ImageJ manual)
(Pre-requisites)
Line 3: Line 3:
 
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.
 
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.
  
= Pre-requisites =
+
= General workflow =
  
You should have a basic macro or function in mind that you want to apply 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.
+
# Create a basic macro which operates on the active image.
 
+
#* The [[Introduction into Macro Programming#The_recorder|macro recorder]] is an excellent way to generate macro code.
Both batch processing options currently provided involve IJ1 macro code. So, looking through the [[Introduction into Macro Programming]] will be a great help to familiarize yourself with the principles of macro writing. Take particular note of the [[Introduction into Macro Programming#The_recorder|recorder]] section, as this is an excellent way to generate the macro code for your desired functionality.
+
#* 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.
  
 
= Easy option =
 
= Easy option =

Revision as of 11:52, 11 September 2014

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

  1. Create a basic macro which operates on the active image.
  2. 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.

Easy option

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.

BatchProcess.png

Flexible option

Open the script editor, select Templates > IJ1 Macro > Process Folder. This will generate the following boilerplate:

Process folder ij1.png

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.