Image Thru A Non Linear Filter example essay topic

2,758 words
University of Texas at San Antonio College of Engineering EE 4623 Digital Filtering Project #3 Develop a Program that will implement the non-linear filters Adriana Juarez December 3, 2002 Abstract: The purpose of this project is to develop a program that implements non-linear filters. For this project we will research the mean filter and the Median filter. Introduction: The Idea of this project is to generate and image and implement different types of noise, then add them together and run them through a non-linear filter and see how the filter affects the output image. First we must locate and image then add the noise and run the image thru a non-linear filter to successfully remove all sort of noise corruption. We will compare two filters, the mean filter and the median filter, for a few simple cases.

The purpose of the filtering operation is assumed to be an effective elimination or attenuation of the noise that is corrupting the desired images. In this report we will consider only the two-dimensional cases (image). The effects are better visualized with images. Background on non-linear filters: Non-linear filtering has been considered even in the fifties, since then, the field has seen a rapid increase of interest indicated. In our case the Multistage medians and median filters have been rather extensively studied from the theoretical point of view in the beginning of the seventies in the Soviet Union. These filters have been independently reinvented and put into wide practical use around 15 years later by western researchers.

Non-linear FIR filters cannot be expressed as a linear combination of the input, but as some other (non-linear) function on the inputs. A simple example of a useful non-linear filter is a 5th order median filter. This is the filter represented by: This type of filter is extremely useful for data with non-Gaussian noise, removing outliers very efficiently. A significant amount of research effort has gone into the development of appropriate filters for various purposes.

Statistics has taken a different tack to the problem: early approaches were similar to moving average filters. However, rather than using a simple moving average, the early work realized that linear regression could be used around the point we were trying to estimate; in other words, rather than simply averaging the five values around a point, a linear fit of the points, using a least squares estimate, could be used to give a better-looking result. Furthermore, we realized that 1) Linear regression could be applied, so could other shapes, in particular splints. 2) The weights for the instances used in regression could be changed.

Each of filtering and smoothing has their advantages. Filter design allows the use of domain knowledge to overcome domain-specific problems, while smoothing is flexible enough to be used more independently of the domain. The main reason that smoothing is useful is that it allows the met feature extraction functions to be simpler. Rather than a lot of effort being devoted towards making the met feature extraction functions robust to noise, and simplify their implementation. Convolution: Convolution is a simple mathematical operation, which is fundamental to many common image-processing operators. Convolution provides a way of multiplying together two arrays of numbers, generally of different sizes, but of the same dimensionality, to produce a third array of numbers of the same dimensionality.

This can be used in image processing to implement operators whose output pixel values are simple linear combinations of certain input pixel values. In an image-processing context, one of the input arrays is normally just a gray level image. The second array is usually much smaller, and is also two dimensional, and is known as the kernel. The figure below will shows us an example image and kernel that we will use to illustrate convolution.

Image Kernel The convolution is performed by sliding the kernel over the image, generally starting at the top left corner, so as to move the kernel through all the positions where the kernel fits entirely within the boundaries of the image. Each kernel position corresponds to a single output pixel, the value of which is calculated by multiplying together the kernel value and the underlying image pixel value for each of the cells in the kernel, and then adding all these numbers together. So in our example, the value of the bottom right pixel in the output image will be given by: If the image has M rows and N columns, and the kernel has m rows and n columns, then the size of the output image will have M-m+1 rows, and N-n+1 columns. Mathematically we can write the convolution as: Where i runs from 1 to M-m+1 and j runs from 1 to N-n+1. Note that many implementations of convolution produce a larger output image than this because they relax the constraint that the kernel can only be moved to positions where it fits entirely within the image. Instead, these implementations typically slide the kernel to all positions where just the top left corner of the kernel is within the image.

Therefore the kernel overlaps the image on the bottom and right edges. One advantage of this approach is that the output image is the same size as the input image. Unfortunately, in order to calculate the output pixel values for the bottom and right edges of the image, it is necessary to invent input pixel values for places where the kernel extends off the end of the image. Typically pixel values of zero are chosen for regions outside the true image, but this can often distort the output image at these places. Therefore in general if you are using a convolution implementation that does this, it is better to clip the image to remove these spurious regions. Removing n-1 pixels from the right hand side and m-1 pixels from the bottom will fix things.

Kernel: A kernel is a usually smallish matrix of numbers that is used in image convolutions. Different sized kernels containing different patterns of numbers give rise to different results under convolution. For example, below we have a 3 x 3 kernel that implements a mean filter. The word kernel is also commonly used as a synonym for structuring element.

A structuring element differs from a kernel in that it also has a specified origin. This sense of the word 'kernel' is not used in HIP. Mean Filter: Mean filtering is a simple, intuitive and easy to implement method of smoothing images, and to reduce the amount of intensity variation between one pixel and the next. We will use this filter to reduce noise in images. The idea of mean filtering is simply to replace each pixel value in an image with the mean value of its neighbors, including itself. This has the effect of eliminating pixel values which are unrepresentative of their surroundings.

Mean filtering is usually thought of as a convolution filter, which will be explained below. Like other convolutions it is based around a kernel, which it will be explain below as well, which represents the shape and size of the neighborhood to be sampled when calculating the mean. Often a 3 x 3 square kernel is used, as shown below, although larger kernels, 5 x 5 squares, can be used for more severe smoothing. Computing the straightforward convolution of an image with this kernel carries out the mean filtering process. Mean filtering is most commonly used as a simple method for reducing noise in an image. We illustrate the filter using and image, located on the next page.

We can see the original image being smooth and without noise, then we apply Gaussian noise with a zero mean and we immediately see the difference in the image. We then show the effect of applying a 3 x 3 mean filter. Note that the noise is less apparent, but the image has been softened a little. If we increase the size of the mean filter to 5 x 5, we obtain a image with less noise and less high frequency detail. To make sure our filter work we added a more challenging task, we added salt and pepper shot, see next page.

This shows the effect of smoothing this image with a 3 x 3 mean filter. Since the shot noise pixel values are often very different from the surrounding values, they tend to distort the pixel average calculated by the mean filter significantly. The result of a 5 x 5 filter is not a significant improvement noise reduction and, furthermore, the image is bow very blurred. These examples illustrate the two main problems with mean filtering, which are: o A single pixel with a very unrepresentative value can significantly affect the mean value of all the pixels in its neighborhood. o When the filter neighborhood straddles an edge, the filter will interpolate new values for pixels on the edge and so will blur that edge. This may be a problem if sharp edges are required in the output. The median filter tackles both of these problems.

The median filter is often a better filter for reducing noise than the mean filter, but it takes longer to compute. In general the mean filter acts as a Low pass filter and, therefore, reduces the spatial intensity derivatives present in the image. We have already seen this effect as a softening of the facial features. Common Variants: Variations on the mean smoothing filter discussed here include Threshold Averaging wherein smoothing is applied subject to the condition that the center pixel value is changed only if the difference between its original value and the average value is greater than a preset threshold. This has the effect that noise is smoothed with a less dramatic loss in image detail. Mean filter example: The mean filter is a simple sliding-window spatial filter that replaces the center value in the window with the average (mean) of all the pixel values in the window.

The window, or kernel, is usually square but can be any shape. An example of mean filtering of a single 3 x 3 window of values is shown below. Unfiltered values 5 3 62 1 98 4 74545 / 9 = 5 Mean filtered 5 Center value, previously 1, is replaced by the mean of all nine values 5. Median Filter: The median filter is normally used to reduce noise in an image, somewhat like the mean filter. However, it often does a better job than the mean filter of preserving useful detail in the image.

Like the mean filter, the median filter considers each pixel in the image in turn and looks at its nearby neighbors to decide whether or not it is representative of its surroundings. Instead of simply replacing the pixel value with the mean of neighboring pixel values, it replaces it with the median of those values. First sorting all the pixel values from the surrounding neighborhood into numerical order and then replacing the pixel being considered with the middle pixel value calculate the median. If the neighborhood under consideration contains an even number of pixels, the average of the two middle pixel values is used. Let me illustrate an example, so we can have a better understanding of what is being said. Calculating the median value of a pixel neighborhood.

As can be seen the central pixel value of 150 is rather unrepresentative of the surrounding pixels and is replaced with the median value: 124. A 3 x 3 square neighborhood is used here -- - larger neighborhoods will produce more severe smoothing. By calculating the median value of a neighborhood rather than the mean filter, the median filter has two main advantages over the mean filter: o The median is a more robust average than the mean and so a single very unrepresentative pixel in a neighborhood will not affect the median value significantly. o Since the median value must actually be the value of one of the pixels in the neighborhood, the median filter does not create new unrealistic pixel values when the filter straddles an edge. For this reason the median filter is much better at preserving sharp edges than the mean filter. We have created some images in mat lab showing us how the Median filters works. We take and original image just like the one we had for the mean filter.

Then we corrupt the image with zero mean Gaussian noise. Then we apply a 3 x 3 median filter, which produces the next image. Note how the noise has been reduced at the expense of a slight degradation in image quality. Just to shows the flaws of the Median filter we took the same image with even more noise added.

Unfortunately the result was not like I spec it to be. The median filter is sometimes not as subjectively good at dealing with large amounts of Gaussian noise as the mean filter. Where median filtering really comes into its own is when the noise produces extreme outlier pixel values, as for instance in we reproduce the salt and pepper noise and added to our original image to see what will happen. We notice that the bits have been flipped with probability 1%.

Median filtering this with a 3 x 3 neighborhood produces a really good image, in which the noise has been entirely eliminated with almost no degradation to the underlying image. In general, the median filter allows a great deal of high frequency detail to pass while remaining very effective at removing noise on images where less than half of the pixels in a smoothing neighborhood have been effected. As a consequence of this, median filtering can be less effective at removing noise from images corrupted with Gaussian noise. One of the major problems with the median filter is that it is relatively expensive and complex to compute. To find the median it is necessary to sort all the values in the neighborhood into numerical order and this is relatively slow, even with fast sorting algorithms. The basic algorithm can however be enhanced somewhat for speed.

A common technique is to notice that when the neighborhood window is slid across the image, many of the pixels in the window are the same from one step to the next, and the relative ordering of these with each other will obviously not have changed. Clever algorithms make use of this to improve performance. Median filter Example: The median filter is also a sliding-window spatial filter, but it replaces the center value in the window with the median of all the pixel values in the window. As for the mean filter, the kernel is usually square but can be any shape. An example of median filtering of a single 3 x 3 window of values is shown below. Unfiltered values 6 2 03 97 419 3 10 In order: 0, 2, 3, 3, 4, 6, 10, 15, and 97.

Median filtered 4 Center value was previously 97 is replaced by the median of all nine values 4. This illustrates one of the celebrated features of the median filter: its ability to remove salt and pepper noise, outlying values, either high or low. The median filter is also widely claimed to be edge preserving since it theoretically preserves step edges without blurring. However, in the presence of noise it does blur edges in images slightly. Conclusion: A single pixel with a very unrepresentative value can significantly affect the mean value of all the pixels in its neighborhood. When the filter neighborhood straddles an edge, the filter will interpolate new values for pixels on the edge and so will blur that edge.

Work Distribution: We all work together in this third project. We all put an input in the Introduction, Research, Examples, and Matlab. We really had to work together this time to come up with the mat lab code.

Bibliography

1] Charles L. Philips, and John M. Parr, Signals, Systems, and Transforms, Marcel Dekker, New York, 1995.
2] Jarkko As tola, Pauli Kuosmanen, Fundamentals of nonlinear digital Filtering, CRC Press, Boca Raton, New York 1997.
3] Sophocles J. Orfanidis, Introduction to signal Processing, Prentice-Hall, Englewood Cliffs, New Jersey, 1989.
4] Richard C. Jaffe, Random Signals and Noise, Addison-Wesley, Reading, MA, 1973 [5] Dr.
Sos Agaian's Notes, 2002 [6] Matlab 6.
1 Help File, 2002.