A Spatial Median Filter for Noise Removal in Digital Images
Total Page:16
File Type:pdf, Size:1020Kb
A Spatial Median Filter for Noise Removal in Digital Images James Church, Dr. Yixin Chen, and Dr. Stephen Rice Computer Science and Information System, University of Mississippi [email protected],{ychen,rice}@cs.olemiss.edu Abstract Each of the algorithms coveredcan be applied to one di- mensional as well as two dimensional signals. Figure 1 In this paper, six different image filtering algorithms are demonstrates five common filtering algorithms applied compared based on their ability to reconstruct noise- to an original image. affected images. The purpose of these algorithms is to remove noise from a signal that might occur through the transmission of an image. A new algorithm, the Spatial Median Filter, is introduced and compared with the cur- rent image smoothing techniques. Experimental results demonstrate that the proposed algorithm is comparable (a) (b) (c) to popular image smoothing algorithms. In addition, a modification to this algorithm is introduced to achieve more accurate reconstructions over other popular tech- niques. (d) (e) (f) Figure 1. Examples of common filtering ap- 1. Smoothing Algorithms proaches. (a) Original Image (b) Mean Filtering (c) Median Filtering (d) Root signal of Median The inexpensiveness and simplicity of point-and- Filtering (e) Component-wise Median Filtering shoot cameras, combined with the speed at which bud- (f) Vector Median Filtering ding photographerscan send their photos over the Inter- net to be viewed by the world, makes digital photogra- The simplest of smoothing algorithms is the Mean phy a popular hobby. With each snap of a digital pho- Filter as defined in (1). The Mean Filter is a linear filter tograph, a signal is transmitted from a photon sensor which uses a mask over each pixel in the signal. Each to a memory chip embedded inside a camera. Trans- of the components of the pixels which fall under the mission technology is prone to a degree of error, and mask are averaged together to form a single pixel. This noise is added to each photograph. Significant work has new pixel is then used to replace the pixel in the signal been done in both hardware and software to improve the studied. The Mean Filter is poor at maintaining edges signal-to-noise ratio in digital photography. within the image. 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 chro- 1 N MEANFILTER(x ,...,x )= ∑ x (1) matic intensities. At a pixel studied, a smoothing fil- 1 N i N i=1 ter takes into account the pixels surrounding it in order to make a determination of a more accurate version of The median is a statistical concept whereby in a this pixel. By taking neighboring pixels into considera- given sorted list of numbers, the median is the center tion, extreme “noisy” pixels can be filtered out. Unfor- value of the list. The use of the median in signal pro- tunately, extreme pixels can also represent original fine cessing was first introduced by J. W. Tukey[1]. If the details, which can also be lost due to the smoothing pro- count of the list is even, there could be multiple center cess. This paper will examine four common smoothing values. If the count of the list is odd, there is one unique algorithms and introduce a new smoothing algorithm. median value; therefore, it is convenient to use odd list sizes when looking for a median. The Median Filter is the signal studied. The Vector Median Filter is a well- performed by taking the magnitude of all of the vectors researched filter and popular due to the extensive mod- within a mask and sorting the magnitudes, as defined in ifications that can be performed in conjunction with it. (2). The pixel with the median magnitude is then used to replace the pixel studied. The Simple Median Filter N N has an advantage over the Mean filter in that it relies VMF(x1,...,xN)= MIN(∑ kx1 − xik,..., ∑ kxN − xik) on median of the data instead of the mean. As single i=1 i=1 noisy pixel present in the image can significantly skew (4) the mean of a set. The median of a set is more robust For each of the four algorithms discussed, experi- with respect to the presence of noise. mental results will be shown that indicate which algo- rithm is best suited for the purpose of impulse noise MEDIANFILTER(x1,...,xN)= removal in digital color images. Those results will be 2 2 (2) MEDIAN(kx1k ,...,kxNk ) compared to two new algorithms for noise removal: the Spatial Median Filter and the Modified Spatial Median When filtering using the Simple Median Filter, an Filter. original pixel and the resulting filtered pixel of the sam- In testing, we consider sets of images containing ple studied are sometimes the exact same pixel. A pixel various amounts of artificial noise. Impulse noise rep- that does not change due to filtering is known as the resents random spikes of energy that happen during the root of the mask. It can be shown that after sufficient data transfer of an image. When applying noise, a per- iterations of median filtering, every signal converges to centage of the image is damaged by changing a ran- a root signal[3]. domly selected point channel to a random value from 0 The Component Median Filter, defined in (3), also to 255. The noise model, I , is given by relies on the statistical median concept. In the Simple noisy Median Filter, each point in the signal is converted to a single magnitude. In the Component Median Filter I(i, j) x ≥ p each scalar component is treated independently. A fil- I i, j ,I i, j ,z y < 1 x < p ( r( ) g( ) ) 3 Inoisy(i, j)= 1 2 ter mask is placed over a point in the signal. For each (Ir(i, j),z,Ib(i, j)) 3 ≤ y < 3 x < p component of each point under the mask, a single me- 2 (z,Ig(i, j),Ib(i, j)) 3 ≤ y x < p dian component is determined. These components are (5) then combined to form a new point, which is then used where I is the original image, Ir, Ig, and Ib represent to represent the point in the signal studied. When work- the original red, green, and blue component intensities ing with color images, however this filter regularly out- of the original image, x,y ∈ [0,1] and are randomvalues, performs the Simple Median Filter. When noise affects z ∈ [0,255] and also random, and p ∈ [0,1] represents a point in a grayscale image, the result is called “salt the probability of noise in the image. and pepper” noise. In color images, this property of “salt and pepper” noise is typical of noise models where 2. Spatial Median Filter for Smoothing Im- only one scalar value of a point is effected. In this noise ages model, the Component Median Filter is more accurate than the Simple Median Filter. The disadvantage of this When transferring an image, sometimes transmis- filter is that it will create a new signal point that did not sion problems cause a signal to spike, resulting in one exist in the original signal, which may be undesirable in of the three point scalars transmitting a incorrect value. some applications. This type of transmission error is called “salt and pep- per” noise due to the bright and dark spots that appear on the image as a result of the noise. The ratio of incor- MEDIAN(x1r,...,xNr) rectly transmitted points to the total number of points CMF(x1,...,xN)= MEDIAN(x1g,...,xNg) (3) is referred to as the noise composition of the image. MEDIAN(x1b,...,xNb) The goal of a noise removal filter is to take a corrupted The Vector Median Filter was developed by Astola, image as input and produce an estimation of the origi- Haavisto, and Neuvo in 1990[2]. In the Vector Median nal with no foreknowledge of the characteristics of the Filter (4), a filter mask is placed over a single point. noise nor the noise composition of the image. The sum of the vector magnitude differences using the In images containing noise, there are two chal- L2 norm from each point to each other point within the lenges. The first challenge is determining noisy points. mask is computed. The point with the minimum sum The second challenge is to determine how to adjust of vector differences is used to represent the point in these points. In the Vector Median Filter (VMF), a point in the signal is compared with the points surrounding it The spatial depth between a point and set of points as defined by a filter mask. Each point in the mask filter is defined by, is treated as a vector representing a point in a three- dimensional space. Among these points, the summed vector distance from each point to every other point 1 N X − x S (X,x ,...,x )= 1 − ∑ i (6) within the filter is computed. The point in the signal depth 1 N N − 1 i=1 kX − xik with the smallest vector distance amongst those points in the filter is the minimum vector median. The point in The Spatial Median Filter is an unbiased smoothing space that has the smallest distance to every other point algorithm and will replace every point that is not the is considered to be the best representative among the maximum spatial depth among its set of mask neigh- set. In the basic implementation of the Vector Median bors.