Hide
IJ2 is out
 Part III: Extending IJ Up Part III: Extending IJ Sec. 15: Scripts 

14 Macros

A macro is a simple program that automates a series of ImageJ commands. The easiest way to create a macro is to record a sequence of commands using the command recorder (PluginsMacrosRecord…↓).
A macro is saved as a text file (.txt or .ijm extension) and once installed executed by selecting the macro name in the PluginsMacros submenu, by pressing a key or, in the case of Macro tools, by clicking on an icon in the ImageJ toolbar. In addition, any macro file placed in ImageJ/plugins with an .ijm extension will be installed in the Plugins menu like any other plugin (before version 1.41 only files with an underscore in the name would be listed).
There are more than 300 example macros, on the ImageJ Web site. To try one, open it in a browser window and drag it directly to the Main ImageJ window↓ or, copy it to the clipboard (Ctrl A, Ctrl C), switch to IJ, and run FileNewSystem Clipboard [V]↓ (Ctrl Shift V), pasting the macro into a new Editor↓ window. Run it using the editor’s MacrosRun Macro command (Ctrl R). Most of the example macros are also available in the macros folder, inside the ImageJ folder.

Macro Programming

The ImageJ community has created excellent tutorials on macro programming. These resources are indispensable guides to the ImageJ macro language:
  1. The ImageJ Macro Language — Programmer’s Reference Guide by Jérôme Mutterer and Wayne Rasband. This booklet compiles most of the documentation dispersed throughout the web related to ImageJ’s macro programming. It provides an up to date printable manual for the ImageJ macro language:
    http://imagej.nih.gov/ij/docs/macro_reference_guide.pdf
  2. The Built-in Macro Functions webpage (HelpMacro Functions…↓ and MacrosFunction Finder [F]↓ in the Editor↓) is the indispensable guide to the built-in functions that can be called from the ImageJ macro language. It is thoroughly documented and constantly updated:
    http://imagej.nih.gov/ij/developer/macro/functions.html
  3. Tutorials on the Fiji webpage:
    http://fiji.sc/wiki/index.php/Introduction_into_Macro_Programming
  4. How-tos and tutorials on the ImageJ Documentation Portal
    http://imagejdocu.tudor.lu/
 Part III: Extending IJ Up Part III: Extending IJ Sec. 15: Scripts