(IJEECS) INTERNATIONAL JOURNAL OF ELECTRICAL, ELECTRONICS AND COMPUTER SYSTEMS. VOLUME: 2 ISSUE: 1, MAY 2011
Comparing Enhanced Fuzzy Logic Image Filtration with Mean and Median Filtered Images Ramesh Tiwari1, Renu Dhir2 Department of Computer Science & Engineering Dr. B R Ambedkar National Institute of Technology Jalandhar, India 1
[email protected] 2
[email protected]
Abstract— This paper makes contrast between mean, median and fuzzy filters and further analyze fuzzy filter for multiple iterations at constant amplification factor of 10. The paper makes use of java programs to generate a simulation environment for comparison and also depicts implementation of some important functions in paper. The marked difference between filters is noted and analyzed for a single PGM image which contains impulse noise used in a block of 9*9 for input. Keywords— Image processing, noise reduction, impulse noise, Fuzzy filter, mean filter, median filter.
I. INTRODUCTION A PGM image represents a grayscale graphic image. There are many pseudo-PGM formats in use where everything is as specified herein except for the meaning of individual pixel values. For most purposes, a PGM image can just be thought of an array of arbitrary integers, and all the programs in the world that think they're processing a grayscale image can easily be tricked into processing something else [1], this extra ordinary characteristics makes PGM better than other formats for analyzing Image Filtration when it comes to divide images into blocs of m*n for input. Noise can be systematically introduced into images during acquisition and/or transmission of images [2, 3]. The impulse noise (sometimes called salt-and-pepper noise or spike noise) has the tendency of either relatively high or relatively low, thus it could severely degrade the image quality and some loss of information details [4]. Various filtration techniques have been proposed for removing such noise in the past and is well known that linear filters could produce serious image blurring. A major class of linear filters minimizes the mean squared error (MSE) criterion and it provides optimum performance among all classes of filters if the noise is additive and Gaussian [5]. Non linear filters are widely exploited and improved, the best known & most widely used non linear digital filter based on order statistics are median filters known to remove impulse noise without damaging edges [6]. During the past years the variety of filter classes are developed such as (1) Classical filters; (2) Fuzzy Classical Filters i.e. fuzzy logic based filters that are modification or extension of classical filters; (3) Fuzzy Filters [7]. In this paper we exploit the use of Fuzzy Filters and resemble their usage with increase in number of iterations. II. SYSTEM DESCRIPTION
A. Mean Filter Mean filtering is a simple, intuitive and easy to implement method of smoothing images, i.e. reducing the amount of intensity variation between one pixel and the next. It is often used to reduce noise in images [8]. 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. Like other convolutions it is based around a kernel, which represents the shape and size of the neighborhood to be sampled when calculating the mean. Often a 3*3 square kernel is used, as shown in Fig. 1, although larger kernels can be used for more severe smoothing. A small kernel can be applied more than once in order to produce a similar but not identical effect as a single pass with a large kernel. Computing the straight forward convolution of an image with this kernel carries out the mean filtering process. 7 + 5 + 8 + 9 + 7 + 5 + 6 + 1 + 6 = 54 54 / 9 = 6 Center value, previously is 7, is replaced by the mean of all nine values 6. Unfiltered Values
Mean Filtered
7
5
8
*
*
*
9
7
5
*
6
*
6
1
6
*
*
*
Fig. 1 Calculating the mean value of pixel neighborhood.
The code to implement mean filter in java language is as, //smoothing algorithm (mean) for(int t=1;t<=tIterations;t++) { if(PrintStatus==true) { System.out.print("\rIteration"+t+"..."); } for(int r=0;r
©IJEECS
(IJEECS) INTERNATIONAL JOURNAL OF ELECTRICAL, ELECTRONICS AND COMPUTER SYSTEMS. VOLUME: 2 ISSUE: 1, MAY 2011
for(int c=0;c
C. Fuzzy Filter 1) Fuzzy Derivative Estimation: For filtering we want a good indication of the edges, while to find these edges we need filtering. In our approach, we start by looking for the edges. We try to provide a robust estimate by applying fuzzy rules. Consider the 3*3 neighborhood of a pixel (x, y) as display in Fig. 3. A simple derivative at the central pixel position (x, y) in the direction D (D ∈ dir = {NW, W, SW, S, SE, E, NE, N}) is defined as the difference between the pixel at (x, y) and its neighbor in the direction D. This derivative value is denoted by ∇D(x, y). For example
146 145 154 157 144 156 167 147 159 152 156 150 144 145 148 142 148 158 156 153 149 144 158 152 192 155 143 156 154 159 145 149 157 151 165 164 151 156 155 140 150 154
∇N(x, y) = I(x, y - 1) - I(x, y)
145 158 190 156 154 157 154
∇NW(x, y) = I(x - 1, y - 1) - I(x, y)
Fig.2 Calculating the median value of pixel neighborhood.
The code to implement median filter in java language is as, //smoothing algorithm (median)
for(int t=1;t<=tIterations;t++) { if(PrintStatus==true) { System.out.print("\rIteration"+t+"..."); } for(int r=0;r
neighbor[j]) { int temp=neighbor[i]; neighbor[i]=neighbor[j]; neighbor[j]=temp; } } } int outval=neighbor[4]; imgout.setPixel(r,c,outval); } }
Next, the principal of the fuzzy derivative is based on the following observation. Consider an edge passing through the neighborhood of a pixel (x, y) in the SW – NE direction. The derivative value ∇NW(x, y) will be large, but also derivative
©IJEECS
(IJEECS) INTERNATIONAL JOURNAL OF ELECTRICAL, ELECTRONICS AND COMPUTER SYSTEMS. VOLUME: 2 ISSUE: 1, MAY 2011
values of neighboring pixels perpendicular to the edge’s direction can expected to be large. In Table 1, we give an overview of the pixels we use to calculate the fuzzy derivative for each direction. Each direction corresponds to a fixed position and the sets specify which pixels are considered with respect to the central pixel (x, y). NW
N
NE
W
(x, y)
E
SW
S
SE
Fig 3. Neighborhood of a central pixel (x, y).
To compute the value that express the degree to which the fuzzy derivative in a certain direction is small, we will make use of the fuzzy set small. The membership function mK(u) for the property small is the following:
where K is an adaptive parameter [10]. TABLE I PIXEL INVOLVED TO CALCULATE THE FUZZY DERIVATIVES IN EACH DIRECTION Direction
Position
Set w.r.t. (x, y)
NW
(x - 1, y - 1)
{(-1,1),(0,0),(1,-1)}
W
(x - 1, y)
{(0,1),(0,0),(0,-1)}
SW
(x - 1, y + 1)
{(1,1),(0,0),(-1,-1)}
S
(x , y + 1)
{(1,0),(0,0),(-1,0)}
SE
(x + 1, y + 1)
{(1,-1),(0,0),(-1,1)}
E
(x + 1, y)
{(0,-1),(0,0),(0,1)}
NE
(x + 1, y - 1)
{(-1,-1),(0,0),(1,1)}
N
(x , y - 1)
{(-1,0),(0,0),(1,0)}
2) Adaptive Threshold Selection: We start by dividing the image in small m*n non-overlapping blocks. For each block B, we compute a rough measure for the homogeneity of this block by considering the maximum and minimum pixel value [11].
Where L represents the number of gray levels.
The code to implement fuzzy filter in java language is as //smoothing algorithm (Fuzzy) int K=-1,prevK=0,L=imgin.getMaxGray(); int neighbor[]=new int[8]; int simpderiv[][]=new int[3][8]; double fofxsmall[][]=new double[3][8]; double fuzzyderiv[]=new double[8]; double fofxpositive[]=new double[8]; double fofxnegative[]=new double[8]; double positivetruthness[]=new double[8]; double negativetruthness[]=new double[8]; double delta,fK; //calc simple derivative of (r,c) for(int t=0;t<8;t++) simpderiv[0][t]=neighbor[t]-inval; //calc simple derivative of perpendicular point-1 simpderiv[1][0]=imgin.getPixel(r-1 +1,c-1 -1)imgin.getPixel(r+1,c-1); simpderiv[1][1]=imgin.getPixel(r +1,c-1 )imgin.getPixel(r+1,c ); simpderiv[1][2]=imgin.getPixel(r+1 +1,c-1 +1)imgin.getPixel(r+1,c+1); simpderiv[1][3]=imgin.getPixel(r+1 ,c +1)imgin.getPixel(r ,c+1); simpderiv[1][4]=imgin.getPixel(r+1 -1,c+1 +1)imgin.getPixel(r-1,c+1); simpderiv[1][5]=imgin.getPixel(r -1,c+1 )imgin.getPixel(r-1,c ); simpderiv[1][6]=imgin.getPixel(r-1 -1,c+1 -1)imgin.getPixel(r-1,c-1); simpderiv[1][7]=imgin.getPixel(r-1 ,c -1)imgin.getPixel(r ,c-1); //calc membership value for 'small' fuzzy set for(int t=0;t<8;t++) { fofxsmall[0][t]=SmallFuzzySet.fofx(simpderiv[0][t],K); fofxsmall[1][t]=SmallFuzzySet.fofx(simpderiv[1][t],K); fofxsmall[2][t]=SmallFuzzySet.fofx(simpderiv[2][t],K); } //calc fuzzy derivative by applying fuzzy rule for 'small' fuzzy set for(int t=0;t<8;t++) { fuzzyderiv[t]=SmallFuzzySet.ApplyRule(fofxsmall[0][t],fofx small[1][t],fofxsmall[2][t]); } //fuzzy smoothing //calc membership values for 'positive' and 'negative' fuzzy sets for(int t=0;t<8;t++) { fofxpositive[t]=PositiveFuzzySet.fofx(simpderiv[0][t],L); fofxnegative[t]=NegativeFuzzySet.fofx(simpderiv[0][t],L); } //calc truthness of 'positive' and 'negative' fuzzy sets by applying fuzzy rules for(int t=0;t<8;t++) { positivetruthness[t]=PositiveFuzzySet.ApplyRule(fuzzyderiv[ t],fofxpositive[t]); negativetruthness[t]=NegativeFuzzySet.ApplyRule(fuzzyderi v[t],fofxnegative[t]); }
©IJEECS
(IJEECS) INTERNATIONAL JOURNAL OF ELECTRICAL, ELECTRONICS AND COMPUTER SYSTEMS. VOLUME: 2 ISSUE: 1, MAY 2011
//calc correction term (defuzzification) delta=0.0; for(int t=0;t<8;t++) { delta=delta+(positivetruthness[t]-negativetruthness[t]); } delta=((double)L/8.0)*delta; int outval=inval+(int)delta; imgout.setPixel(r,c,outval); } The java interface developed is shown in Fig. 4 as, Fig. 6 Mean Filtered Image after 15 iterations
B. Median Filtered Image The Fig. 7 shows median filtered image after 15 iterations. The image is clear but blurred.
Fig. 4 Developed java interface.
III. RESULTS AND DISCUSSIONS The image processing is done on system with Intel(R) Pentium Processor (R) D CPU 2.80 GHz, 1.25 GB Ram, Windows 7 (32 bit) operating system and jdk1.6.0_06. The Fig. 5 shows the input image taken for image processing.
Fig. 7 Median Filtered Image after 15 iterations
C. Fuzzy Filtered Image Fig. 8 shows fuzzy filtered image after one iteration.
Fig. 5 Original.
A. Mean Filtered Image Fig. 6 shows mean filtered image after 15 iterations. The image is not clear due to overlap of differences to remove noise. The increase in number of iterations doesn’t make image clear but further remove the difference between neighboring pixels.
Fig. 8 Fuzzy Filtered Image after 1 iteration
Fig. 9 shows fuzzy filtered image after two iterations and shows that noise is more removed but image got blurred.
©IJEECS
(IJEECS) INTERNATIONAL JOURNAL OF ELECTRICAL, ELECTRONICS AND COMPUTER SYSTEMS. VOLUME: 2 ISSUE: 1, MAY 2011
Fig. 9 Fuzzy Filtered Image after 2 iterations
Fig. 12 Fuzzy Filtered Image after 8 iterations
Fig. 10 shows fuzzy filtered image after three iterations and shows that noise is more removed but image got blurred and light. The difference between pixel values is decreasing by taking derivative on neighboring values.
Fig.13 shows fuzzy filtered image after fifteen iterations and shows that now there is no significant change in image.
Fig. 13 Fuzzy Filtered Image after 15 iterations Fig. 10 Fuzzy Filtered Image after 3 iterations
Fig. 11 shows fuzzy filtered image after four iterations and shows that noise is more removed but image much light and blurred.
IV. CONCLUSIONS The paper analyzes the mean, median and fuzzy filters in different scenarios and conditions. The results of paper depict that mean and median filters remove noise at significant level by removing the difference between neighboring pixels in large number of iterations, but the fuzzy filter removes noise smartly considering the edge differences in small number of iterations. The large number of iterations in fuzzy filters makes no much difference.
REFERENCES [1]
By Jef Poskanzer on his official site
[2]
Zhou, Yan; Tang, Quan-hua; Jin, Wei-dong; Adaptive fuzzy median filter for images corrupted by impulse noise in Congress on image and signal processing IEEE Conference, 2008, Volume 5 Page(s): 265 269 Schulte, S.; De Witte, V.; Nachtegael, M.; Van der Weken, D.; Kerre, E.E.; Fuzzy two-step filter for impulse noise reduction from color images in IEEE Transactions on Image Processing, 2006, Volume: 15 , Issue: 11 Page(s): 3567 – 3578. Pei-Eng Ng; Kai-Kuang Ma;. A switching median filter with boundary discriminative noise detection for extremely corrupted images in IEEE Transactions on Image Processing, 2006, Volume: 15 , Issue: 6 Page(s): 1506 – 1516. S. Balasubramanian, S. Kalishwaran, R. Muthuraj, D. Ebenezer, V. Jayaraj; An efficient non-linear cascade filtering algorithm for
http://netpbm.sourceforge.net/doc/pgm.html
[3] Fig. 11 Fuzzy Filtered Image after 4 iterations [4]
Fig. 12 shows fuzzy filtered image after eight iterations and shows that noise is almost removed but image got much lighter.
[5]
©IJEECS
(IJEECS) INTERNATIONAL JOURNAL OF ELECTRICAL, ELECTRONICS AND COMPUTER SYSTEMS. VOLUME: 2 ISSUE: 1, MAY 2011
[6] [7]
[8]
[9]
[10]
[11] [12]
[13]
[14]
[15]
removal of high density salt and pepper noise in image and video sequence in international conference on control, automation, communication and energy conservation -2009, 4th-6th June 2009, Page(s): 1-6. J. Astola and P. Kuosmanen, Fundamentals of Non-Linear Digital Filtering, BocRaton, CRC, 1997. Nachtegael, M.; Schulte, S.; Van der Weken, D.; De Witte, V.; Kerre, E.E.; Fuzzy filters for noise reduction: the case of gaussian noise in The 14th IEEE International Conference on Fuzzy Systems, FUZZ '05,2005, Page(s): 201 – 206. Oten, R., de Figueiredo, R.J.P., Adaptive alpha-trimmed mean filters under deviations from assumed noise model in IEEE Transactions on Image Processing, Volume: 13 Issue: 5, May 2004, Page(s): 627 – 639. S. Zhang, M. A. Karim. A new impulse detector for switching median filters in IEEE Signal Process. Lett., , November 2002, Page(s) : 360363 Van De Ville, D.; Nachtegael, M.; Van der Weken, D.; Kerre, E.E.; Philips, W.; Lemahieu, I.; Noise reduction by fuzzy image in IEEE Transactions on Fuzzy Systems, 2003, Volume: 11 , Issue: 4, Page(s): 429– 436. H.Haussecker and H.Tizhoosh, Handbook of Computer Vision and Applications,1999, Page(s): 708– 753. Taguchi, A.; Data-dependent α-trimmed mean filters for image restoration in IEEE International Symposium on Circuits and Systems Volume: 3, 1994. Page(s): 289 - 292 . Hao Xu; Jizheng Xu; Feng Wu; A post-compensation scheme for Nonlocal Means filter based image restoration in 15th IEEE International Conference on Image Processing, 2008, Page(s): 545 548 Z. Wang, D. Zhang.; Progressive switching median filter for the removal of impulse noise from highly corrupted images in IEEE Trans. Circuits Syst. II, Analog Digit Signal Process January 1999, Page(s) 78-80. Z. Deng, Z Yin, and Y Xiong. High probability impulse noiseremoving algorithm based on mathematical morphology in IEEE Signal Process Lett., January 2007 Page(s): 31-34.
[16]
[17]
[18]
Young Sik Choi, Krishnapuram, R., A robust approach to image enhancement based on fuzzy logic in IEEE Transactions on Image Processing, Volume: 6 Issue: 6, Jun 1997, Page(s): 808 - 825, Yuewei Lin; Bin Fang; Yuanyan Tang; Image Restoration Using Fuzzy Impulse Noise Detection and Adaptive Median Filter in Chinese Conference on Pattern Recognition,2010 , Page(s): 1 - 4 . Haixiang Xu; Xiaorui Yue; An Adaptive Fuzzy Switching Filter for Images Corrupted by Impulse Noise in Sixth International Conference on Fuzzy Systems and Knowledge Discovery Volume: 3, 2009, Page(s): 383 – 387.
Ramesh Tiwari is an M.Tech. student in Computer Science & Engineering department of Dr. B R Ambedkar National Institute of Technology, Jalandhar, India. He has completed his B.Tech. degree in 2008 from Govind Ballabh Pant University of Agriculture and Technology, Pantnagar, India. His research area is image processing, biometric authentication. Renu Dhir has done her PhD in Computer Science And Engineering from Punjabi University in 2007 and M.Tech. in Computer Science & Engineering from TIET Patiala in 1997.Her area of research is mainly image processing and character recognition. She has published more than 35 papers in various international journals and conferences. Now she is working as a Associate Professor in Computer Science & Engineering department of Dr. B R Ambedkar National Institute of Technology, Jalandhar, India.
©IJEECS