TODO component: `{"content"=>"sc.fiji:Image\\_Expression\\_Parser"}`

## Usage

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.

## User interface

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/.

## Supported functions

Here is a list for supported functions and algorithms, as of version 2.1.

### Supported ImgLib algorithms

</table> ### Supported functionsDescription | Syntax |
---|---|

Gaussian convolution | gauss(img, sigma) |

Floyd-Steinberg dithering | dither(img) |

Image normalization (sum to 1) | normalize(img) |

Description | Syntax |
---|---|

Euler constant | e |

π | pi |

Standard operators | +, -, \*, /, ^, % |

Sine | sin |

Cosine | cos |

Tangent | tan |

Arc Sine | asin |

Arc Cosine | acos |

Arc Tangent | atan |

Arc Tangent 2 args | atan2(y,x) |

Hyperbolic Sine | sinh |

Hyperbolic Cosine | cosh |

Hyperbolic Tangent | tanh |

Natural Logarithm | log |

Exponential | exp |

Power | pow |

Square Root | sqrt |

Absolute Value | abs |

Round | round |

Floor | floor |

Ceiling | ceil |

Boolean operators | !, &&, \|\|, <, >, !=, ==, >=, <= |