Median filter#

Description

Median filter is a part of the module httomolibgpu.misc.corr for data correction. Median filter is a non-linear noise removing technique with edge-preserving properties, see more on it here. Mathematically, one can express the median filter as:

\[ \begin{align}\begin{aligned}f \in \mathrm{R}^{N}: \textit{input}\\g \in \mathrm{R}^{N}: \textit{output}\\g_{i} = \textit{median}(f_{j}), \textrm{where} \ j \in \mathrm{N}_{i}\end{aligned}\end{align} \]

Where \(\mathrm{N}_{i}\) is the symmetric neighbourhood (e.g. 3 x 3) of the pixel \(j\).

Where and how to use it:

Median filter can be used in post-processing, e.g., after the reconstruction to remove the noise and prepare the image for further analysis. Applying edge-preserving noise correction can simplify segmentation.

What are the adjustable parameters:

  • kernel_size defines the neighborhood size, see \(\mathrm{N}_{i}\) in the equations above. For instance, for 2D image kernel_size = 3 defines the neighborhood of 3 by 3 pixels (one needs to use only odd numbers). Increasing kernel_size results in more smoothing applied, it is recommended to use the higher values when the level of noise is high. As a rule of thumb, keeping kernel_size within 3-5 range is a good trade-off to avoid destroying important data features.

Practical example:

In this example we demonstrate how to apply median filter to projection data to demonstrate its noise removing properties.

Warning

It is not recommended to apply median filter to projection data as any modification of the data itself can result in further problems, e.g., the loss of the resolution and the presence of artifacts in the reconstruction step.

../../_images/normalisation_sino.png

Fig. 1 Input (sinogram view)#

../../_images/normalisation_proj.png

Fig. 2 Input (projection view)#

../../_images/median_filter_sino.png

Fig. 3 After applying median filter (sinogram)#

../../_images/median_filter_proj.png

Fig. 4 After applying median filter (projection)#

../../_images/median_filter_res_sino.png

Fig. 5 Sinogram view of absolute residual between input and output#

../../_images/median_filter_res_proj.png

Fig. 6 Projection view of absolute residual between input and output#