| MIL 10 User Guide
| Customize Help

Denoise using spatial filtering and area open and close operations



See also
Availability
Not available in MIL-Lite

Available in MIL

Spatial filtering and area open and close operations are effective ways to reduce noise. Spatial filtering operations determine each pixel's value based on its neighborhood values. They allow images to be separated into high-frequency and low-frequency components. There are two main types of spatial filters that can remove noise: low-pass linear filters and rank filters. Area open and close operations are efficient in removing salt-and-pepper noise in an image.

Spatial filtering and area open and close operations are not especially effective at removing Gaussian noise or minimizing Mean Square Errors (MSE). In these cases, try using MimWaveletDenoise(). For more informaiton, see the Wavelet denoising subsection of the Transform and denoise images using wavelets section of Chapter 4: Advanced image processing.

Low-pass spatial linear filters

Low-pass spatial linear filters are effective in reducing Gaussian random noise (and high-frequency systematic noise), provided that the noise frequency is not too close to the spatial frequency of significant image data. These filters replace each pixel with a weighted sum of each pixel's neighborhood. Note, these filters have the side-effect of selectively smoothing your image and removing edge information.

You can apply low-pass spatial linear filters using the MimConvolve() function. MIL provides a predefined low-pass linear filter called M_SMOOTH, which you will find satisfies most applications. If you want to control the degree of smoothness (strength of denoising) applied by the neighborhood operation, use MimConvolve() with the M_SHEN_FILTER() or M_DERICHE_FILTER() macro, set its FilterSmoothness macro parameter to the required smoothness value, and set its FilterOperation macro parameter to M_SMOOTH. The M_DERICHE_FILTER() macro applies a Canny-Deriche filter, and the M_SHEN_FILTER() macro applies a Shen-Castan filter. For the Shen-Castan filter, the neighborhoods' influence decreases much faster as the distance from the central pixel increases, and it tends to produce more enhanced or sharpened edges, compared to the Canny-Deriche filter.

Earlier in the chapter, we looked at a cell-analysis application that determined the number of cell nuclei in a tissue sample. Since Gaussian noise is generally introduced when digitizing, we performed a smoothing operation prior to performing the analysis.

Rank filters

Rank-filter operations are more suitable for removing salt-and-pepper type noise since they replace each pixel with a pixel in its neighborhood rather than a weighted sum of its neighborhood. The weighted sum generally creates a blotchy effect around each noise pixel.

You can perform a rank-filter operation using MimRank(). In most cases, it is best to use a rank that is half of the number of elements in the neighborhood. This effectively replaces each pixel with the median of the neighborhood and is therefore called a median filter. To perform a median filter, use MimRank() with M_MEDIAN. You will find that the median filter will most often suit your application needs.

Area open and area close

To eliminate salt-and-pepper noise in your image, you can perform an area open or area close operation, using MimMorphic() with M_AREA_CLOSE or M_AREA_OPEN. Area open can be used to eliminate small regions of light noise pixels, while area close can do the same to small regions of dark noise pixels.

To understand what the area open and area close operations do, it is useful to think of an image as a topographic surface with hills and valleys. The value of each pixel represents a certain height, with the lowest pixel value (the darkest pixel) representing the point of lowest elevation and the highest pixel value (the brightest pixel) representing the point of highest elevation. The area open operation clips the peaks of hills until each has a plateau with an area equal to or greater than the specified minimum area. If an area of this size never occurs, the peak will be clipped until all the pixels in the hill have the same intensity as the background pixels. The area close operation is similar to the area open operation, except the clipping of intensity levels begins at the lowest level. In this case, you can imagine the bottom of the basins being filled until they have a flat surface area equal to or greater than the specified minimum area.

To implement the area open operation, MIL analyzed the image and clips off peaks one intensity level at a time, starting at the highest pixel intensity level (255 for an 8-bit image). At each intensity level, the following steps are performed:

  • Pixels with an intensity level greater than the current intensity level and that have not been previously locked are set to the current intensity level.

  • The algorithm then considers all pixels with a value equal to or less than the current value to be foreground pixels, and connected foreground pixels as part of the same object.

  • The area of each object is compared to the specified minimum area. If it is greater or equal to the specified minimum area, the pixels in the object are locked at their current value for the remainder of the algorithm. If the current intensity level is 0, the operation is complete. If not, the algorithm proceeds to the next lower intensity level, and returns to step 1.

In the event that the area of an object at every pixel intensity level never equals or exceeds the specified minimum area, its pixels will eventually be clipped to the background pixel intensity level. Also, it is possible that distinct objects at one pixel intensity level merge together at a lower pixel intensity level. This situation is illustrated in the following images, which depict a few steps in the area open operation.

As was mentioned earlier, an object is composed of connected foreground pixels. Determining which pixels are connected depends on the selected structuring element, M_3X3_RECT or M_3X3_CROSS. These are the only two structuring elements that can be used with the area open and area close operations.