Menu

Filtering images

Intro

MIA supports the filtering of 2D images, 3D images, and series of 2D images interpreted as 3D images.
The syntax for filtering a single 2D or 3D images is, essentially, the same, only the program that needs to be called it either mia-2dimagefilter or mia-3dimagefilter. The set of supported filters is different, you may consult the availabe 2D filters and 3d filters.

To understand the syntax of the filter specifications, you might first consult the [Guide to plugin specification].

Single image filter

In the following the examples for filtering a single images are given for 2D images.

Running one filter

The simplest case, running only one filter, is done like:

mia-2dimagefilter -i input.png -o output.v convert:map=linear,repn=float,a=1.5,b=-20

Here, the input image is a PNG image, with 8 or 16 bit unsigned pixel values, and each pixel x is converted to a floating point valued pixel by applying a linear mapping according to 1.5 x - 20.

Note, the output file format must support the pixel type of the filter output. Currently, this will only be checked when the file is actually saved (see also [tickets:#5]).

Specifying a filter chain

Filters can be chained on the command line, e.g to run a median filter followed by a binarization run:

mia-2dimagefilter -i input.png -o output.png median:w=1 binarize:min=100,max=200

Re-using output of earlier filters later in the pipeline

It is also possible to store the result within the filter chain and reload it later, e.g.

mia-2dimagefilter -i input.png -o output.png median:w=1 tee:file=temp.@ \
   binarize:min=100,max=200 close mask:input=temp.@

Here, the input image is filtered by using a median filter, then the result is stored in the internal storage (this is indicated by the suffix .@), and after running a binarization and morphological closing, the so obtained mask is applied to the median filtered image loaded from the internal storage.

Note however, it is not possible to save the file to disk and then load it in the same call to mia-2dimagefilter, i.e. in the following command, the mask filter will try to load temp.png right away, before the tee filter will store it.

mia-2dimagefilter -i input.png -o output.png tee:file=temp.png mask:input=temp.png

Running filters on multiple files

Two options are available to run filters on multiple files:

  1. Each file is filtered individually by using mia-2dimagefilterstack or mia-3dimagefilterstack respectively.
  2. A series of ND images is interpreted as a (N+1)D image. This is currently only implemented for series of 2D images with the program mia-2dstackfilter.

In both cases the image files must be numbered consecutively (see [Interpreting file series]).


Related

Tickets-mia: #5
Wiki: Guide to plugin specification
Wiki: Interpreting file series
Wiki: Tutorials

MongoDB Logo MongoDB