Biomedical Engineering Reference
In-Depth Information
5.3.1 Macro language in ImageJ
The macro language used by ImageJ is much like Java, so some knowledge
of similar languages will help get a user up and running. There are some
basic elements within the language, which are now discussed, which can
be blended together to provide a sophisticated and fairly rich functionality
dedicated to image processing.
Variables
Variables can be assigned within a macro which are case-sensitive. For
example, counter=0, where 'counter' is the variable and 0 is its initial value.
Variable names must not contain only numbers or any spaces. Variable
values can also be strings, for example, day='Tuesday', in this example the
value is not a number so must be encased in speech marks. Without speech
marks ImageJ would assume that 'Tuesday' was already a variable and if it
has not been defi ned an error message would ensue! Alphanumeric strings
can be constructed in ImageJ as in the following example.
// macro start
year = 2011;
weekday = 'Tuesday';
month = 'August';
day = '20th';
date = 'weekday';
print(weekday + ' ' + day + ' ' + month + ' ' + year);
// macro end
// macro start
year = 2011;
weekday = 'Tuesday';
month = 'August';
day = '20th';
date = 'weekday';
print(weekday + ' ' + day + ' ' + month + ' ' + year);
// macro end
In this case, the variable 'date' is built from a string containing other
variables. When such a macro is run, the result is printed in the log window
as the 'print' command is used. However, the variable can be used for many
other functions such as giving a fi le a name or appearing in a custom results
table. Note in this example it is a true macro and each line is followed by a
semi colon to evaluate this statement. Comments are an important part of
writing a macro to help users understand what the code is doing and are
denoted using '//', whereby the macro language will ignore any following
code in that line. It is good practice to have as many comments as there is
code in a macro, which helps when it comes to debugging!
￿ ￿ ￿ ￿ ￿
For loops
For loops are a long-established programming statement, having been
available in the late 1970s with the Basic language on the Commodore
 
Search WWH ::




Custom Search