evaluate(abc);or
evaluate(aaa==12);
The command whatis is synonymous with evaluate. Another use of whatis is in conjunction with print. Normally, print would iterate over all the pixels, creating a long printout. However, if you were to enter
whatis(print("The pixel is ", image[0][2][200][200]));
the value of a single pixel would be printed.
Evaluate and whatis should not be used in loops.
Comments and multiline equations
Any line that starts with the # character is a comment and is ignored. Similarly, blank lines and carriage returns in equations are ignored. Thus you could have:
i = image[0][0][x][y] +
image[2][0][x+4][y+4];
However, comments cannot appear in the middle of an expression.
Relationship between image math and macros
Although pixel math equations and macros use a `C'-like syntax, the main difference is that, by default, all math commands iterate over all the pixels in the currently-selected image or selected area. This makes it consistent with the fact that macro commands such as `filter' and `fft' also work on entire images, even though they are only executed once. Some other commands, such as fopen and fclose are also only executed once. Thus if you have:
fopen("test");
write("test","the answers are i=",i," x=",x," y=",y,"\n");
fclose("test");
the write statement is iterated over all the pixels, while the fopen and fclose are only executed once.
A number of sample macros (*.macro) are included with imal.
Mixing image math and macros
The fact that imal commands and image math can appear in the same macro is a tremendous convenience in writing macros. For example, here is a sample macro:
# 1.macro - Simple macro open(gray); if(x>50) i+=27; if(y>x) i+=66;
This macro opens the image file gray, and applies two equations to it. The variable ``i'' is used instead of r,g, and b because gray happens to be a grayscale image. However, imal has to check each statement to determine whether it is a macro or a math equation. Slightly greater speed can be obtained by enclosing the math equations in a ``loop'':
# 1.macro - Simple macro
open(gray);
loop
{
if(x>0) i+=27;
if(y>x) i+=66;
}
In this macro, the ``loop'' keyword tells imal that the statements enclosed in braces are mathematical equations and not macro statements, so no checking is done against macro names. This has several advantages: