# Filters (Spatial): Mean

This algorithm provides a simple way of reducing noise either in an entire image or in a delineated VOI in the image where

Mean = sum of all pixels in the kernel / total number of pixels in the kernel

This is one method of low-pass filtering, which is sometimes referred to as neighborhood averaging.

## Contents

### Background

In applying this algorithm, MIPAV first defines a region, either in the whole image or in the delineated VOI, over which it replaces a target pixel value with the average value over the kernel of pixels in which the target pixel is at the center. That is, for the target pixel:

$mean = \frac {1} {s} \sum_{i=1}^{i=s} I_i k_i$

where k '= kernel,' s = kernel size, and I = image.

For slice averaging (Figure 1] and (Figure2), the kernels are odd-length squares (for example, 3 x 3). The processing time increases with the square of the kernel length. For volume averaging ( Figure 2), the kernels are odd-length cubes (such as 5 x 5 x 5), and the processing time increases with the cube of the kernel length. Refer to Figure 2 for examples of slice and volume averaging.

Note that the term average does not always represent the mean. If fact, there are three types of average: the commonly used mean, the median, and the infrequently used mode. The mean is defined as the sum of the values in a group divided by the number of values in the group. The median value is the value that has the same number of values greater and less than it. The mode is the value with the greatest number of occurrences.

If part of the neighborhood kernel falls outside the image when the pixel is on or near the boundary, MIPAV only uses that portion of the kernel inside the image.

 Example: Consider the upper right corner pixel in a 2D image if a 3 x 3 kernel is used. In this case, when the algorithm is applied, MIPAV uses only the target pixel and its lower, left, and diagonal left lower neighbors. It then divides the sum of these four pixels by 4.

If you select the New image option, MIPAV places the resulting image in a new image window. If you select the Replace image option, MIPAV returns the changed picture to the same image window. If you delineate a VOI on the image and select VOI regions, then MIPAV replaces the original value of a pixel inside the VOI with the mean value of the kernel that contains the pixel at its center. The pixel values outside the VOI remain unchanged.

Because 2D images contain only one slice, the only option possible under Kernel Thickness in the Mean Filter dialog box is slice averaging-the Apply slice kernel option. The Apply volume kernel option, which performs volume averaging, is dimmed. However, both slice averaging and volume averaging are available for 3D images. Although slice averaging is the default value, users can choose volume averaging instead by selecting the Apply volume kernel option.

For slice averaging, the default kernel size is 3 x 3, but the following kernel sizes are available: 5 x 5, 7 x 7, 9 x 9, or 11 x 11. For volume averaging, the default kernel size is 3 x 3 x 3. However, you can select one of the following sizes instead: 5 x 5 x 5, 7 x 7 x7, 9 x 9 x 9, or 11 x 11 x 11.

For color images the default is to obtain the means of the red, green, and blue channels. However, if users clear the Red channel, Green channel, or Blue channel check boxes, MIPAV only performs mean averaging on the color channels that are selected.

#### Image types

You can apply this algorithm to all image data types and to 2D, 2.5D, and 3D images.

None.