# Filters (Spatial): Adaptive Noise Reduction

This algorithm reduces noise without blurring the edges by replacing a pixel value with a weighted sum of all local pixels reached by following a path with small pixel intensity values between neighboring pixels.

## Contents

### Background

The Adaptive Noise Reduction algorithm is a port to Adaptive Noise Removal Filter, a software program. This program first transforms RGB color space into YCrCb color space. When the filtering is complete, it then transforms the YCrCb color space into RGB color space. Hence, all of the color operations occur in YCrCb space. However, the program does not transform black-and-white images into another space.

In "Frequently Asked Questions About Color," Charles Poynton reveals that the RGB-to-YCrCb and YCrCb-to-RGB conversion equations used in Adaptive Noise Removal Filter differ significantly from standard ones. First, the program creates an edge graph or pixel neighbor graph using a weakly median-filtered version of the YCrCb space. A weakly median-filter version means that median filtering only occurs if the pixel is not on an edge in Y, Cr, or Cb space. The edge graph is an array of arrays with the first array having a length equal to the number of pixels in the image and the second array having eight edge weights. The eight edge weights are calculated from the intensity differences between the center pixel and one of the eight neighboring pixels:

$E =\sqrt{((dYwY)^2 + (dRwR)^2 + (dBwB)^2)}$

• converting color;

where E is the edge weight; dY, dR, and dB are the Y, Cr, and Cb differences; and wY, wR, and wB are the Y, Cr, and Cb weights derived from the Y, Cr, and Cb radiuses. A bigger relative radius results in a smaller weight for radiuses >= 0.1, which is typically the case.

After the edge graph is created, the program filters the Y, Cr, and Cb spaces separately. It uses the selected pixel as the center of a square with L = 2R 1 where L = sides of length, R = range, and range = (int)(radius 0.999).

The enhancePixel function returns the filtered pixel value at every pixel in the image. If neighboring pixels are connected to the center pixel via a low-cost path, queue elements corresponding to these neighboring pixels are added to the priority queue. If no queue element is retrieved from the queue, then the original pixel value is passed unchanged. If elements are retrieved from the queue, then those Y, Cr, or Cb pixel values that retrieved queue elements are put into a weighted sum. The weight is derived from an index into the filter array given by the queue element key times the invFilterLen. The filter array is generated with a Gaussian function.

Each queue element has a value, a baseKey, and a key. The value gives the location within the local local square where R = range. The baseKey has a sum of the edgeGraph values over the low-cost path from the center pixel to the selected pixel, and key is equal to the sum of baseKey and the distMap value for the selected pixel. The distMap value at a given position inside the local square is equal to the edge preservation strength times the distance from the center pixel. A key is only added to the queue if key < maxDistance:'

$M = (int)(Rd(S+512))$

where M = maxDistance, Rd = radius, and S = edge preservation strength.

The priority queue is implemented as a binary heap and the binary heap is implemented as an array. A binary heap is a nearly full binary tree (only the bottom level may not be complete). This binary heap has the property that for every node other than a leaf, its key value is less than or equal to that of its children. In a binary heap the item of highest priority is always at the root of the tree or at node 0. When the highest priority item at the root is removed, the item of highest priority among the remainder moves into the root position. The children of node i are at and . The parent of node i is at $(int) \left ( \frac {i-1}{2} \right )$.

The filter radius can be separately adjusted for each Y, Cr, and Cb channel for color images. For black-and-white images only, the Y filter radius can be adjusted. A larger radius removes more noise but loses more detail.

The edge preservation strength can be adjusted. Larger values preserve more edges but sacrifice smoothness in low-contrast areas. Very large values may cause banding.

To speed the filtering on color images, you can select the Filter Cr and Cb at halved dimensions check box. When run, the algorithm shrinks the Cr and Cb spaces by a factor of 2, generates an edge table for the shrunken space, filters the image, and then expands the filtered Cr and Cb spaces to their original dimensions. Although the algorithm runs faster, it also loses some details.

The New image option causes MIPAV to place the resulting image in a new image window. The Replace image option causes MIPAV to place the changed image in the same window.

#### Image types

You can apply this algorithm to both color and black-and-white 2D images.

None.