# AniFilters : Anisotropic Diffusion Blur¶

PDE-based algorithm to reduce noise in grey-scale image, while keeping and reinforcing linear or planar structures in 2D or 3D images respectively.

The real-time 3D images obtained by confocal microscopy are noisy. In order to segment them, we need to reduce this noise. The easiest way is to use a gaussian blur, but we might also lose some important informations, as the localization of the cell walls. That's why we implement an anisotropic blur, which reduces the noise without blurring the cell walls.

From left to right : (1) original image ; (2) gaussian blur ; (3) anisotropic blur K=0.1 / sigma=6 / gamma=1 / nb_it=150

## Anifilters tools¶

- ani2D --> anisotropic filter reinforcing linear structures in 2D (any common extension: jpg, png, tif, ...)
- ani3D --> anisotropic filter reinforcing planar structures in 3D (.inr, .inr.gz files)
- ani3D-tiff --> same as ani3D for tiff files

## Usage¶

The syntax of the three tool is the same (you just replace ani3D by ani2D or ani3D-tiff respectively)

ani3D filename K sigma gamma upDiter nb_it


## Parameters¶

### Filename¶

Filename of the image

### K¶

Proportional to the size of the cell walls we want to keep in the image.
Used to compute the diffusion tensor.
Range : 0.1 - 0.3

### Sigma¶

Size of the gaussian blur.
The Hessian and gradient are computed on a blured image, in order to avoid high variation.
Range : 2 - 10

### Gamma¶

Apply a gamma correction to correct contrast.
0.1 -0.9 : more white (the image is too dark)
1 : no correction
1.1 - 1.5 : more black (the image is too white)

### upDiter, div_sigma : update the diffusion tensor¶

The diffusion tensor is updated every upDiter iteration. It is computed on a blurry version of the current image. The first diffusion tensor is computed on the original image with a blur sigma. The next ones are computed on the current image with a blur equal to the previous one, divided by div_sigma. The parameter div_sigma is fixed to 1.5 in the standard version.

### Number of iteration nb_it¶

The longer the algorithm runs, the thinner the cell walls will get and the less noise there will be. If the algorithm runs for too long, some cell walls might disappear.
Range : 25 - 150

### Time step dt=0.1¶

The time step for the discretization of the PDE.

## How does it work?¶

The filter developed by Weickert is a diffusion process using a PDE (Partial Differential Equation).

The image will evolve in time according to its gradient and a diffusion tensor (anisotropic) or a diffusion coefficient (isotropic). The diffusion process is similar to a smoothing or blurring process.

The filter developed by Schmidt is anisotropic and heterogeneous: there is a diffusion tensor D for each voxel of the image. D is computed using the eigenvectors and the eigenvalues of the Hessian matrix (second derivative of the image intensity) with this formula:

D is a 3 by 3 matrix with values between 0 and 1.

Inside the cells, where the image is globally homogeneous, the diffusion is isotropic and equal to 1.
Near the cell walls, the diffusion is anisotropic: it is strong along the walls, and small perpendicularly to the walls.

### Implementation details¶

Both divergence and gradient are computed using finite difference approximations. At first we used central difference ( 0.5*([x+1] - [x-1]) ), but we had numerical issues.
We now use alternatively forward difference ([x+1] - [x]) and backward difference ([x] - [x-1]).

If the iteration step is an even number, the gradient is computed with forward difference and the divergence with backward difference.
Else the gradient is computed with backward difference and the divergence with forward difference.

## References¶

The algorithm is based on a filter developed by Weickert, using a formula from Schmidt
--- J. Weickert. Anisotropic Diffusion In Image Processing. B.G. Teubner Stuttgart, 1998.
--- Schmidt, T., Pasternak, T., Liu, K., Blein, T., Aubry-Hivet, D., Dovzhenko, A., Duerr, J., Teale, W., Ditengou, F. A., Burkhardt, H., Ronneberger, O. and Palme, K. (2014), The iRoCS Toolbox – 3D analysis of the plant root apical meristem at cellular resolution. The Plant Journal, 77: 806–814. doi: 10.1111/tpj.12429