The Mathematica Journal
Feature Articles
New Products
New Publications
News Bulletins
Write Us
About the Journal
Staff and Contributors
Back Issues
Download this Issue

3. Linear Filtering

Many useful image processing operations may be implemented by filtering with a selected FIR filter [2, 3, 4]. This is known as linear filtering and finds application in edge detection, image sharpening, noise reduction, and image matching. According to Equations (2.2), (2.3), (2.7), and (2.8) the output image is obtained by a convolution operation. The choice of filter depends on the desired outcome. Here we demonstrate a number of standard FIR filters commonly used in operations such as blurring, unsharp masking, and edge detection.

We first consider so-called smoothing filters that return the local average of the samples of a signal. Such an operation tends to reduce the local variability of sample values and thus decreases signal noise and smoothes the signal. However, averaging also smears image edges resulting in a blurred picture. The simplest such filter returns a matrix with constant coefficients equal to the inverse of the filter's dimensions. This FIR filter is commonly known as a moving-average filter or box filter.

Here is a [Graphics:../Images/index_gr_104.gif] moving-average filter.


The averaging property of the moving-average filter may be verified by substituting for [Graphics:../Images/index_gr_107.gif] in Equation (2.8) the values of the filter. It is easily seen that the output [Graphics:../Images/index_gr_108.gif] is equal to an average of the sample values in the nine-element neighborhood of sample [Graphics:../Images/index_gr_109.gif].


Averaging operations are useful in removing noise from a signal, however, they also tend to blur the signal, due to smoothing of sharp transitions in image intensity (i.e., edges).

This loads an example image.


This sets some useful display options for ListDensityPlot.


This shows the example image.



Here we demonstrate image smoothing with two moving-average filters of different dimensions. Note that the degree of smoothing is directly related to the dimensions of the moving-average filter.



A standard technique to improve image quality is to enhance the visibility of edges by using a technique called unsharp masking [2]. Unsharp masking introduces overshoots in the vicinity of an edge, effectively simulating a well-documented human visual phenomenon known as the Mach band effect. Mach bands are nonexistent overshoots that we tend to perceive in the vicinity of sharp brightness transitions in a picture. This linear operation may be implemented by convolving an image with an unsharp filter. In unsharp masking, the original image is blurred and a fraction of the unsharp image is subtracted from the original. This can be expressed as


where [Graphics:../Images/index_gr_120.gif] is the original image and [Graphics:../Images/index_gr_121.gif] is the lowpass filtered image, a and b are positive constants with [Graphics:../Images/index_gr_122.gif], and [Graphics:../Images/index_gr_123.gif] is the processed image. Here are some typical impulse responses of unsharp masking filters.


The parameter [Graphics:../Images/index_gr_127.gif] is a real constant in the range [Graphics:../Images/index_gr_128.gif]. Here we define a [Graphics:../Images/index_gr_129.gif] unsharp filter.


Here we demonstrate unsharp masking. First we blur the original books image.


Here we show the result. Note the somewhat improved quality of the unsharp masked image compared to the blurred copy.



Edge detection is a common image processing task [2, 3, 4]. It is well known that edges are important to mammalian vision. In typical images, edges characterize object boundaries and therefore are useful for segmentation, registration, and identification of objects in a scene. The most commonly used edge detection methods are implemented as linear filtering operations with FIR filters that approximate directional derivatives. Specifically, the so-called gradient magnitude of some continuous function [Graphics:../Images/index_gr_134.gif] is defined as


The orientation of an edge is sometimes of interest. The gradient orientation is given by


Local maxima of the gradient magnitude identify edges in [Graphics:../Images/index_gr_137.gif]. In the case of a digital image, the derivatives [Graphics:../Images/index_gr_138.gif] and [Graphics:../Images/index_gr_139.gif] are easily obtained by convolving the image with two FIR differentiators. Here is one frequently used filter pair known as the Sobel edge detector.


This returns the two-directional derivatives of the example image using the Sobel filters.


Here we compute the gradient magnitude and edge direction.


This displays the edge magnitude and the orientation.



Converted by Mathematica     

[Article Index] [Prev Page][Next Page]