Image processing


Gaussian filter

To smooth an image choosing the dimension(s) in which you want to apply the smoothing

c3d <input_image> -smooth <std_dim1>x<std_dim2>x<std_dim3>vox -o <output_image>

where <std_dim1>, <std_dim2> and <std_dim3> are the standard deviation of the Gaussian kernel in each dimension.


c3d t2.nii.gz -smooth 0x0x5vox -o t2_z_smoothed.nii.gz

Smooth the image t2.nii.gz only along the third dimension with a standard deviation of 5 voxels in this dimension.

c3d t2.nii.gz -smooth 1vox -o t2_smoothed.nii.gz

Smooth the image t2.nii.gz in every direction with a standard deviation of 1 voxels.

Median filter

The median filter, contrary to the gaussian filter, smooth an image by preserving the edges. It can be applied using fslmaths:

fslmaths <input_image> -fmedian <output_image>

Intensity correction

It happens that an image has not a homogeneous intensity field. In MRI, the intensity is proportional to the antena proximity.

N3 - nonparametric nonuniform intensity normalization

Information can be found on

This filter can be applied using the following command (MNI tools): (Problem –> lost the image intensity dynamic)

mri_nu_correct.mni --i <input_image> --o <output_image>

Or with c3d:

c3d <input_image> -biascorr -o <output_image>


The N4 algorithm is a variation of the original N3 algorithm with the additional benefits of an improved B-spline fitting routine which allows for multiple resolutions to be used during the correction process.

This algo is implemented on ITK (

or in c3d:

c3d <input_image> -n4 -o <output_image>

Example (before-after N4 corretion):

Manual segmentations