International Journal of Engineering Trends and Technology (IJETT) - Volume4Issue5- May 2013 The Component Median Filter for Noise Removal in Digital Images Harish 1 and M.R.Gowtham2 1 Department of Electronics and Communication Engineering, Priyadarshini College of Engineering, NELLORE – 524 004, A. P., INDIA 2 Department of Electronics and Communication Engineering, Priyadarshini College of Engineering, NELLORE – 524 004, A. P., INDIA Abstract The objective of the project is to develop a Component filtering algorithm to reconstruct noise affected images. The purpose of the algorithm is to remove noise from a signal that might occur through transmission of an image. This algorithm can be applied to one dimensional as well as two dimensional signals. In the component Median Filter each scalar component is treated independently. A filter mask is placed over a point in the signal. For each component of each point under the mask, a single median component is determined. These components are then combined to form to a new point, which is then used to represent the point in the signal studied. When working with color images, however, this filter regularly out performs the simple Median filter. When noise affects a point in a gray scale image, this result is called “salt and pepper” noise. In color images, this property of “salt and pepper” noise is typical of noise models where only one scalar value of point is affected. For this noise model, the Component Median Filter is more accurate than the Simple Median Filter. Keywords— Image Enhancement, Component Median Filter, Mean Square Error, Root Mean Square Error, Peak to Signal Noise Ratio, Noise. 1. INTRODUCTION In image processing it is usually necessary to perform high degree of noise reduction in an image before performing higher-level processing steps, such as edge detection. In software, a smoothing filter is used to remove noise from an image. Each pixel is represented by three scalar values representing the red, green and blue chromatic intensities. At each pixel studied, a smoothing filter takes into account the surrounding pixels to design a move accurate version of this pixel. By taking neighboring pixels ISSN: 2231-5381 into considerations, extreme ‘noisy’ pixels can be replaced. However, outlier pixels may represent in corrupted fine details, which may be lost due to the smoothing process. The median filter [2] is a non-linear digital filtering technique, often used to remove noise from images or other signals. The idea is to examine a sample of the input and decide if it is representative of the signal. This is performed using a window consisting of an odd number of samples. The values in the window are sorted into numerical order; the median value, the sample in the center of the window, is selected as the output. The oldest sample is discarded, a new sample acquired, and the calculation repeats. The Component Median Filter defined in (1) also relies on the statistical median concept. CMF(x1…,xN)= ( 1 …. ( 1 … ( 1 … ) ) ) (1) When transferring an image, sometimes transmission problems cause a signal to spike, resulting in one of the three point scalars transmitting an incorrect value. This type of transmission error is called “salt and pepper” noise due to the bright and dark spots that appear on the image as a result of the noise. The ratio of incorrectly transmitted points to the total number of points is referred to as the noise composition of the image. The goal of a noise removal filter is to take a corrupted image as input and produce an estimation of the original with no foreknowledge of the noise composition of the image. http://www.ijettjournal.org Page 1830 International Journal of Engineering Trends and Technology (IJETT) - Volume4Issue5- May 2013 2. NOISE REMOVAL IN DIGITAL IMAGES The input to the filter is 3*3 sized mask noisy images. In the next step it is applied to a respective filter. By simulation we get the output of the filter is noise eliminated image. from the data instead of adding artificial noise to the data. 4) Speckle: It is a type of multiplicative noise. It is added to the image using the equation J=I+n*I, where n is uniformly distributed random noise with mean 0 and variance V. Noise can generally be grouped in two classes: 1) independent noise, and 2) Noise which is dependent on the image data. Image independent noise can often be described by an additive noise model, where the recorded image f(i,j) is the sum of the true image s(i,j) and the noise n(i,j): ( , ) = ( , ) + ( , )(2) Fig.1: Block Diagram 2.1 Noise Types In common use the word noise means unwanted sound or noise pollution. In electronics noise can refer to the electronic signal corresponding to acoustic noise (in an audio system) or the electronic signal corresponding to the (visual) noise commonly seen as 'snow' on a degraded television or video image. In signal processing or computing it can be considered data without meaning; that is, data that is not being used to transmit a signal, but is simply produced as an unwanted by-product of other activities. In Information Theory, however, noise is still considered to be information. In a broader sense, film grain or even advertisements in web pages can be considered noise. Noise can block, distort, or change the meaning of a message in both human and electronic communication. In many of these areas, the special case of thermal noise arises, which sets a fundamental lower limit to what can be measured or signaled and is related to basic physical processes at the molecular level described by well known simple formulae. 2.1.1 Types of noise 1) Salt & Pepper: As the name suggests, this noise looks like salt and pepper. It gives the effect of "On and off" pixels. 2) Gaussian: This is Gaussian White Noise. It requires mean and variance as the additional inputs. 3) Poisson: Poisson noise is not an artificial noise. It is a type of noise which is added ISSN: 2231-5381 The noise n(i,j) is often zero-mean and described by its variance . The impact of the noise on the image is often described by the signal to noise ratio (SNR), which is given by = = − 1(3) Where and are the variances of the true image and the recorded image, respectively. In many cases, additive noise is evenly distributed over the frequency domain (i.e. white noise), whereas an image contains mostly low frequency information. Hence, the noise is dominant for high frequencies and its effects can be reduced using some kind of low pass filter. This can be done either with a frequency filter or with a spatial filter. (Often a spatial filter is preferable, as it is computationally less expensive than a frequency filter.) In the second case of data dependent noise, (e.g. arising when monochromatic radiation is scattered from a surface whose roughness is of the order of a wavelength, causing wave interference which results in image speckle), it can be possible to model noise with a multiplicative, or non-linear, model. These models are mathematically more complicated, hence, if possible, the noise is assumed to be data independent. 2.2 Salt and Pepper Noise Another common form of noise is data drop-out noise (commonly referred to as intensity spikes, speckle or salt and pepper noise). Here, the noise is caused by errors in the data transmission. The http://www.ijettjournal.org Page 1831 International Journal of Engineering Trends and Technology (IJETT) - Volume4Issue5- May 2013 corrupted pixels are either set to the maximum value (which looks like snow in the image) or have single bits flipped over. In some cases, single pixels are set alternatively to zero or to the maximum value, giving the image a `salt and pepper' like appearance. Unaffected pixels always remain unchanged. The noise is usually quantified by the percentage of pixels which are corrupted. 3. IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN The principal objective of enhancement is to process an image so that the result is more suitable than the original image for a specific application. Image enhancement approaches fall into two broad categories: spatial domain methods[1] and frequency domain methods. The term spatial domain refers to the image plane itself, and approaches in this category are based on direct manipulation of pixels in an image. Frequency domain processing techniques are based on modifying the Fourier transform of an image. Enhancement techniques based on various combinations of methods from these two categories are not unusual. Visual evaluation of image quality is a highly subjective process, thus making the definition of a “good image” an elusive standard by which to compare algorithm performance. The term spatial domain refers aggregate of pixels composing an image. domain methods are procedures that operate on these pixels. Spatial domain processes denoted by the expression g (x,y)=T[f (x,y)] to the Spatial directly will be (4) Where f (x,y) is the input image, g (x,y) is the processed image, and T is an operator on f, defined over some neighborhood of (x,y). In addition, T can operate on a set of input images, such as performing the pixel-by- pixel sum of K images for noise reduction. The principle approach in defining a neighborhood about a point (x,y) is to use a square or rectangular sub image area centered at (x,y). The center of the sub image is moved from pixel to pixel starting, say, at the top left corner. The operator T is applied at each location (x,y) to yield the output, g, at that location. The process utilizes only the pixels in the area of the image spanned by the neighborhood. Although other neighborhood shapes, such as approximations to a circle, sometimes are used, ISSN: 2231-5381 square and rectangular arrays are by far the most predominant because of their ease of implementation. The simplest form of T is when the neighborhood is of size of 1X1 (that is, a single pixel). In this case, g depends only on the value of f at (x,y), and T becomes a gray level ( also called an intensity or mapping) transformation function of the form s = T(r) (5) Where, for simplicity in notation, r and s are variables denoting, respectively, the gray level of f (x,y) and g (x,y) at any point (x,y). For example, if T(r) has the form shown in Fig.(a), the effect of this transformation would be to produce an image of higher contrast than the original by darkening the levels below m and brightening the levels above m in the original image. In this technique, known as contrast stretching, the values of r below m are compressed by the transformation function into a narrow range of s, toward black. The opposite effect takes place for values of r above m. In the limiting case shown in Fig.(b), T (r) produces a two-level (binary) image. A mapping of this form is called a thresholding function. Some fairly simple, yet powerful, processing approaches can be formulated with gray-level transformations. Because enhancement at any point in an image depends only on the gray level at that point, techniques in this category often are referred to as point processing. Larger neighborhoods allow considerable more flexibility. The general approach is to use a function of the values of f in a predefined neighborhood of (x, y) to determine the values of g at (x, y). One of the principle approaches in this formulation is based on the use of so-called masks (also referred to as filters, kernels, templates, or windows). Basically, a mask is a small (say, 3X3) 2-D array, in which the values of mask coefficients determine the nature of the process, such as image sharpening. Enhancement techniques based on this type of approach often are referred to as mask processing or filtering. 3.1 Local enhancement The two histogram processing methods discussed in the previous two sections are global in the sense that pixels are modified by a transformation function based on the gray-level distribution over an entire image. Although this global approach is suitable for overall enhancement, it is often necessary to enhance details small over small areas. The number of pixels in these areas may have negligible influence on the computation of a global transformation, so the use of http://www.ijettjournal.org Page 1832 International Journal of Engineering Trends and Technology (IJETT) - Volume4Issue5- May 2013 this type of transformation does not necessarily guarantee the desired local enhancement. The solution is to devise transformation functions based on the gray-level distribution or other properties in the neighborhood of every pixel in the image. We discuss local histogram processing here for the sake of clarity and continuity. The histogram processing techniques previously described are easily adaptable to local enhancement. The procedure is to define a square or rectangular neighborhood and move the centre of this area from pixel to pixel. At each location, the histogram of the points in the neighborhood is computed and either a histogram equalization or histogram specification transformation function is obtained. This function is finally used to map the gray level of the pixel centered in the neighborhood. The centre of the neighborhood region is then moved to an adjacent pixel location and the procedure is repeated. Since only one new row or column of the neighborhood changes during a pixel-to-pixel translation of the region, updating the histogram obtained in the previous location with the new data introduced at each motion step is possible. This approach has obvious advantages over repeatedly computing the histogram over all pixels in the neighborhood region each time the region is moved pixel location. Another approach often used to reduce computation is to utilize non-overlapping regions, but this method usually produces an undesirable checkerboard effect. 3.2 Enhancement Operations Using Arithmetic/Logic Arithmetic/Logic operations involving images are performed on a pixel-by-pixel basis between two or more images (this excludes the logic operation NOT, which is performed on a single image). As an example, subtraction of two images results in a new image whose pixel at coordinates (x, y) is the difference between the pixels in that same location in the two images being subtracted. Depending on the hardware and/or software being used, the actual mechanics of implementing arithmetic/logic operations can be done sequentially, one pixel at a time, or in parallel, where all operations are performed simultaneously. Logic operations similarly operate on a pixel-by-pixel basis. We need only be concerned with the ability to implement the AND, OR and NOT logic operators because these three operators are functionally complete. In other words, any other logic operator can be implemented by using only these three basic functions. When dealing with logic ISSN: 2231-5381 operations on gray-scale images, pixel values are processed as strings of binary numbers. For example, performing the NOT operation on a black, 8-bit pixel (a string of eight 0’s) produces a white pixel (a string of eight 1’s). Intermediate values are processed the same way, changing all1’s to 0’s and vice versa. Thus, the NOT logic operator performs the same function as the negative transformation. The AND or OR operations are used for masking; that is, for selecting sub images in an image. In the AND and OR image masks, light represents a binary 1 and dark represents a binary 0. Masking sometimes is referred to as region of interest (ROI) processing. In terms of enhancement, masking is used primarily to isolate an area for processing. This is done to highlight that area and differentiate it from the rest of the image. Logic operations also are used frequently in conjunction with morphological operations. Of the four arithmetic operations, subtraction and addition (in that order) are the most useful for image enhancement. We consider division of two images simply as multiplication of one image by the reciprocal of the other. Aside from the obvious operation of multiplying an image by a constant to increase its average gray level, image multiplication finds use in enhancement primarily as a masking operation that is more general than the logical masks discussed in the previous paragraph. In other words, multiplication of one image by another can be used to implement gray-level, rather than binary, masks. 4. COMPONENT MEDIAN FILTER The Component Median Filter [3] also relies on the statistical median concept. In the Simple Median Filter, each point in the signal is converted to a single magnitude. In the Component Median Filter each scalar component is treated independently. A filter mask is placed over a point in the signal. For each component of each point under the mask, a single median component is determined. These components are then combined to form a new point, which is then used to represent the point in the signal studied. When working with color images, however, this filter regularly outperforms the Simple Median Filter. When noise affects a point in a grayscale image, the result is called “salt and pepper” noise. In color images, this property of “salt and pepper” noise is typical of noise models where only one scalar value of a point is affected. For this noise model, the Component Median Filter is more accurate than the Simple Median Filter. The disadvantage of this filter is that it will create a new http://www.ijettjournal.org Page 1833 International Journal of Engineering Trends and Technology (IJETT) - Volume4Issue5- May 2013 signal point that did not exist in the original signal, which may be undesirable in some applications. ( , … . . , )= ∑ (6) The linear MSE estimator is the estimator achieving minimum MSE among all estimators of the form AY + b. If the measurement Y is a random vector, A is a matrix and b is a vector. (Such an estimator would more correctly be termed an affine MSE estimator, but the term linear estimator is widely used. 5.2 Root Mean Square Error (RMSE) 4.1 Algorithm of Component Median Filter Step 1: Select a noisy image. Step 2: If the noisy image is color, separate each plane using MATLAB commands. Step 2(a): Each scalar component is treated in dependently. Step 3: Generate zero arrays around an image based on image mask size using pad array command. Step 4: select 3 * 3 masks from an image and the mask should be odd sized Step 5: Then sort the pixel values within the mask in ascending order. Step 6: For each component of each point under the mask a single median component is determined. Step 7: These components are then combined to form a new point which is then used to represent the point in the signal studied. Step 8: Restore the output image and calculate the Mean Square Error and Peak Signal to Noise Ratio value. 5. ESTIMATION OF QUALITY OF RECONSTRUCTED IMAGES. In mathematics, the root mean square (abbreviated RMS or rms), also known as the quadratic mean, is a statistical measure of the magnitude of a varying quantity. It is especially useful when variations are positive and negative, e.g., sinusoidal. RMS is used in various fields, including electrical engineering; one of the more prominent uses of RMS is in the field of signal amplifiers. It can be calculated for a series of discrete values or for a continuously varying function. The name comes from the fact that it is the square root of the mean of the squares of the values. It is a special case of the generalized mean with the exponent p = 2. The RMS value of a set of values (or a continuous-time waveform) is the square root of the arithmetic mean (average) of the squares of the original values (or the square of the function that defines the continuous waveform). { , In the case of a set of n values, , … , }the RMS value is given by: 5.1 Mean Square Error (MSE) + = In statistics and signal processing, a Mean square error (MSE) estimator describes the approach which minimizes the mean square error (MSE), which is a common measure of estimator quality. − ∫ [ ( )] = (9) And the RMS for a function over all time is (7) Where the expectation is taken over both X (8) The corresponding formula for a continuous function (or waveform) f(t) defined over the interval ≤ ≤ is Let X is an unknown random variable, and let Y be a known random variable (the measurement). An estimator is any function of the measurement Y, and its MSE is given by = +… … … + = lim → ∫ [ ( )] (10) and Y. The MSE estimator is then defined as the estimator achieving minimal MSE. In many cases, it is not possible to determine a closed form for the MMSE estimator. In these cases, one possibility is to seek the technique minimizing the MSE within a particular class, such as the class of linear estimators. ISSN: 2231-5381 The RMS over all time of a periodic function is equal to the RMS of one period of the function. The RMS value of a continuous function or signal can be approximated by taking the RMS of a series of equally spaced samples. http://www.ijettjournal.org Page 1834 International Journal of Engineering Trends and Technology (IJETT) - Volume4Issue5- May 2013 5.3 Peak to Signal Noise Ratio (PSNR) 6.1 Images The phrase peak signal-to-noise ratio, often abbreviated PSNR, is an engineering term for the ratio between the maximum possible power of a signal and the (or codec type) and same content. It is most easily defined via the mean square error (MSE) which for two m×n monochrome images I and K where one of the images is considered a noisy approximation of the other is defined as: = ∑ ∑ [ ( , ) − ( , )] Fig.2: Original image. (11) The PSNR is defined as: = 10. log =20. log √ (12) Here, MAXI is the maximum possible pixel value of the image. When the pixels are represented using 8 bits per sample, this is 255. More generally, when samples are represented using linear PCM with B bits per sample, MAXI is 2B−1. For color images with three RGB values per pixel, the definition of PSNR is the same except the MSE is the sum over all squared value differences divided by image size and by three. Typical values for the PSNR in lossy image and video compression are between 30 and 50 dB, where higher is better. Acceptable values for wireless transmission quality loss are considered to be about 20 dB to 25 dB. When the two images are identical the MSE will be equal to zero, resulting in an infinite PSNR. 6. SIMULATION AND RESULTS Fig.3: Noise corrupted image. Fig.4: Noise removed image. 6.2 Results The results are obtained by calculating the Mean Square Error performance, Peak Signal to Noise Ratio performance and Peak Signal to Noise Ratio performance. These values are to be obtained for Gaussian noise, salt and pepper noise, Speckle noise. Gaussian noise corrupted images have better PSNR. The original image is generally is to be corrupted by adding the noise to it in order to get the noisy image. Filtering technique is applied to the noisy image to obtain the noise eliminated image. ISSN: 2231-5381 http://www.ijettjournal.org Page 1835 International Journal of Engineering Trends and Technology (IJETT) - Volume4Issue5- May 2013 7. Conclusion We have introduced Component Median Filter for removing impulse noise from images and shown how they compare to four well-known techniques for noise removal. In the comparison of noise removal filters, it was concluded that Component Median Filter performed the best overall noise compositions tested. By using the quantitative analysis we proved that most of the in noise digital images is removed with component median filter. 8. References Fig.5: Mean Square Error performance. Fig.6: Peak Signal to Noise Ratio performance. [1] R.Nathan,” Spatial Frequency Filtering,” in Picture Processing and Psychopictrotics,B.S .Lipkin and A.Roswnfeld,Eds., Academic Press, New York. [2] G.A.Mastin ,” Adaptive Filters for Digital Image Noise Smoothing : An Evaluation, “Computer Vision, Graphics , and Image Processing. [3] T.A.Nodes and N.C.Gallagher , Jr.,” Median Filters : Some Manipulations and Their Properties,”IEEE Trans. Acoustics, Speech, and Signal Processing. [4] “Digital image processing” by Rafael C. Gonzalez and Richard E.Woods. [5] “Digital image restoration” by Andrews and Hunt. [6] “Digital image processing” by B.Chanda and D.Dutta Majumder. Fig.7: Root Mean Square Error to Noise Ratio performance ISSN: 2231-5381 http://www.ijettjournal.org Page 1836