The plugin is located in Process › Image Expression Parser .
This plugin parses arbitrary mathematical expressions and compute results using images as variables. For instance:
■ 2*A ■ A*(B+30) ■ sqrt(A^2+B^2)*cos(C) ■ A > B ■ gauss(A, 0.8)
where A,B and C are opened images of the same dimensions.
As of version 2.x, pixel per pixel based operations are supported and Imglib algorithm are supported.
The parsing ability is provided by the JEP library: Java Expression Parser v.jep-2.4.1-ext-1.1.1-gpl. This is the last version released under the GPL by its authors Nathan Funk and Richard Morris, see Singular System. Internally, this plugin uses Imglib to deal with images.
Internally, images are handled by copying them to a new float type image, so as to avoid clipping effect. The result image returned is of float type as well.
The interactive version (launched from ImageJ) uses a GUI.
When launched it displays a window allowing the user to enter a mathematical expression, with variables (capital single letters, so up to 26 variables) and canonical functions. The expression is checked by the parser of the JEP library (http://www.singularsys.com/jep/). If it is not valid, a hopefully useful error message is displayed.
Variables can be added using +/- buttons. They are matched to opened images in ImageJ.
When the images are RGB images, they are processed in a special way:
- they are split in 3 RGB channels;
- each channel is parsed and evaluated separately;
- the 3 resulting images are put back together in a 3 channel composite image.
This GUI was built in part using Jigloo GUI builder http://www.cloudgarden.com/jigloo/.
Here is a list for supported functions and algorithms, as of version 2.1.
Supported ImgLib algorithms
|Gaussian convolution||gauss(img, sigma)|
|Image normalization (sum to 1)||normalize(img)</table> ### Supported functions|
|Standard operators||+, -, \*, /, ^, %|
|Arc Tangent 2 args||atan2(y,x)|
|Boolean operators||!, &&, \|\|, <, >, !=, ==, >=, <=</table> Extending the parser -------------------- It is relatively easy to extends the parser with new functions. Basically, you must write a function that implements *fiji.expressionparser.function.ImgLibFunction*. Once done, it must be added to the parser class, so that it is aware of it. See in *fiji.expressionparser.ImgLibParser* the method *addStandardFunctions()* for an example. However, in the *fiji.expressionparser.function* package lies a few abstract functions made to simplify the extension process: ### *fiji.expressionparser.function.TwoOperandsPixelBasedAbstractFunction* This is the mother class for functions that takes two arguments, and operate on pixel values only. That is: the pixel value on the result image will depend only the pixel values in the source images at the same location. For instance, have a look at *fiji.expressionparser.function.ImgLibArcTangent2* that extends it. New functions will basically just have to implement the actual operation on numbers, in the method *evaluate(final R t1, final R t2)*. ### *fiji.expressionparser.function.SingleOperandPixelBasedAbstractFunction* The same thing, but for function with a single argument. For instance, see *fiji.expressionparser.function.ImgLibAbs*. ### *fiji.expressionparser.function.SingleOperandAbstractFunction* This is a more generic abstract class, allowing to handle whole image operation. There is two method to implement: - *evaluate(Image|