A Novel Image Median Filtering Algorithm based ... - Semantic Scholar

Report 4 Downloads 174 Views
International Journal of Digital Content Technology and its Applications Volume 4, Number 6, September 2010

A Novel Image Median Filtering Algorithm based on Incomplete Quick Sort Algorithm Dong Fuguo, Fan Hui, Yuan Da School of computer science and technology,Shandong Institute of Business and Technology,Shandong, YanTai, China e-mail: [email protected]; [email protected]; [email protected] doi: 10.4156/jdcta.vol4.issue6.8

Abstract Quick sort algorithm is studied thoroughly, a new incomplete quick sort algorithm is designed, and then a novel image median filtering algorithm based on incomplete quick sort algorithm is proposed to improve the filtering speed. The new algorithm considers in detail the characteristic of image median filtering (In median filtering algorithm, the sorting operation of all pixel values is not necessary, the median value can be given by many other methods), and can give the median value by only sorting part of the pixels value in the neighborhood, thus it can reduce many data move operations, and then greatly improve the speed of image median filtering. Algorithm analysis and a lot of experiment results show that, the new algorithm greatly improves the speed of image median filtering, and can keep the edge, outline, texture and much other information to a great extent.

Keywords: Median Filtering, Incomplete Quick Sort Algorithm, Digital Image Processing 1. Introduction Noise filtering is one of the most important task in digital image preprocessing, its performance and speed directly influences the rest works. Image may be polluted in the process of image collection, transmission, transformation, and storing, which leads to quality degradation. Popular noise filtering methods can be categorized as two classes: linear ones and non-linear ones. Linear filtering methods are usually characterized by low-pass, while the outline, edge and texture of images change very frequently, belonging to the high frequency parts of image signals, thus linear filtering may cause image edges to be blurry and the vision effect will be influenced. As a typical non-linear filtering method, median filtering algorithm can reserve much more edge information, outline information and texture information, as well as wiping off or reducing salt-and-pepper noise and impulse interferences. In recent years median filtering algorithm and its fast algorithm have been widely used in the domain of image smoothing, data analysis and processing, etc. However, median filtering algorithm gives the median value by sorting firstly all the pixel values in neighborhood of the target pixel, which involves a great deal of data comparison and movement operations of data items. The amount of comparison and movement operation is enormous and the speed is very slow. Consequently, median filtering algorithm can not meet the real time demand, especially when the radius of the window becomes larger. To improve its speed, the main fast algorithm for median filtering proposed these years can be divided into five categories: 1) Difference set intersection sorting algorithm, which keeps previous sorting results and insert the difference set of two adjacent neighborhoods in appropriate position to keep the order of the sequence, thus the times of data comparison and movement operation are greatly reduced, the speed of median filtering is improved. In this algorithm, how to solve the difference set is the main problem. 2) Point choice algorithm, which chooses part of the pixels in neighborhood and sorts them, thus computation amount is reduced. But in application, how to choose the points and what points should be chosen are the problems. 3) Sign test method, which chooses a value in the neighborhood according to certain rule, then count the number of pixels bigger than or smaller than the selected value separately. If the two numbers are equal or their difference is so small that it can be ignored, the selected value can be considered to be the median value. 4) Small window neighborhood multi-iteration algorithm, which belongs to the divide-and-conquer method. This algorithm divides the pixel values in neighborhood into several small radius windows, sorts every small neighborhood and gives median values in every window, at last, sorts the window consisting of the median values and gives the last median value. In

79

A Novel Image Median Filtering Algorithm based on Incomplete Quick Sort Algorithm Dong Fuguo, Fan Hui, Yuan Da

application, if the original neighborhood is too large, the above steps may be repeated many times and executed iteratively. 5) Parallel processing algorithms, which sorts the data in every row separately at the same time, then sorts the data in the middle column, thus gives the fast algorithm for median filtering. Except for Difference set intersection sorting algorithm, all other algorithms have certain error, the computed median value may not be the theoretical one so that image may degrade to some extent. This paper thoroughly considers the characters of median filtering algorithm and quick sort algorithm, designs and implements a novel fast median filtering algorithm based on incomplete sorting algorithm, which sorts only part of the pixel values in neighborhood, but can give the theoretical median value. The new algorithm reduces lots of operation for data comparison and movement operation, and greatly improves the speed of median filtering algorithm. A lot of algorithm analysis and experiment results show that the new algorithm is much faster than other existing algorithms [1-11].

2. Median Filtering Algorithm Median filtering is a classical nonlinear signal processing technology based on order-statistics theory. In image median filtering, the value of the target pixel in an image is replaced with the median value of its neighborhood, and then the isolated noise points will be eliminated. Median filtering algorithm can reserve the high frequency part of image to large extent, thus ensures the visual effect of the image. In case of image preprocess, median filtering is the preferred technology to eliminate the salt-and-pepper noise and random additive noise. Definition 1: Median value is the value in the middle position of a sorted sequence. In application, the filter window or neighborhood may be chosen as rectangle, circle, cross or cirque. Suppose that the pixel values in neighborhood are put into a sequence x1 , x 2 , x 3 ,..., x n and it becomes x i1 ≤ x i2 ≤ x i3 ... ≤ x in after sorted in ascending order or x i1 ≥ x i2 ≥ x i3 ... ≥ x in in descending order, then its median value is

x median = Med{x i }

, n is odd ⎧x i(n +1)/2 ⎪ = ⎨1 ⎪⎩ 2 x i ( n / 2) + x i ( n / 2+1) , n is even The radius of filtering window n is often chosen as an odd, and then the median value of the sequence is x median = Med{x i } = x i ( n +1) / 2 .

[

]

As to two-dimensional case, suppose I n, n is a n / 2 radius neighborhood matrix, after sorted it becomes I'n, n and its median value is

I median = Med(In, n ) = I' (n/2, n/2) . To use median filtering algorithm, all pixel value in certain neighborhood need to be sorted in ascending or descending order, and then replaces the center pixel with the median value of the value in neighborhood. As the radius of the filtering window becomes larger, median filtering will becomes more and more slow. So this algorithm is only suitable for small filtering radius case or those cases where the timely request is not the very high[12-17].

3. Median Filtering Algorithm Based On Incomplete Quick Sort Method Quick sort algorithm was proposed by C.A.R.Hoare in 1962 and is the fastest one of known sorting algorithms; it has mean time complex Θ(nlbn) and small constant factor. So it is often the preferred sorting algorithm in application. Quick sort algorithm mainly employs the thought of divide-and-conquer method and recursive algorithm: choose a value in the sequence as the pivot, swap the appropriate value with the pivot, and then divide the sequence into two separate parts through a times of sorting operation, all values in one part are less than those in another part, then the two parts will be processed separately in the same way until the original sequence are sorted in ascending or descending order.

80

International Journal of Digital Content Technology and its Applications Volume 4, Number 6, September 2010

Suppose a sequence A[0]…A[N-1], choose a data in the sequence (often choose the data on the first or the middle position for simplicity) as a divot, then move all the data less than it before or after it and the data larger than it after or before it, thus dividing the original sequence into two parts, and all the values in one part are less than the pivot value while those in the other part are larger than the pivot value. The two parts are processed separately in the same way; the algorithm is executed recursively until the original sequence is wholly orderly. Quick sort algorithm can be described as follows: Function definition: QuickSort(A[], left, right) Step 0 if left>=right return Step 1 set initial variable,left→i,right→j Step 2 choose the pivot data, A[(left + right)/2] →key Step 3 while A[j]>=key j-1→j Step 4 swap A[j] and key Step 5 while A[i]=right return -1 Step 1 set initial variable,left→i,right→j Step 2 choose the pivot data, A[(left + right)/2] →key Step 3 while A[j]>=key j-1→j Step 4 swap A[j] and key Step 5 while A[i](left + right)/2 return IQuickSort(A[],left,i-1) Step 10 else return IQuickSort(A[],j+1,right) Suppose a sequence 3,8,5,2,6,1,9,7,4, its median value can be given as in figure 1 and figure 2 shows. The algorithm runs recursively. In every time of sorting, the middle position is chosen as the

81

A Novel Image Median Filtering Algorithm based on Incomplete Quick Sort Algorithm Dong Fuguo, Fan Hui, Yuan Da

pivot, at the first time 6 is chosen and at the second time 5 is chosen. After the first time quick sorting, the original sequence is divided into two parts by 6. In the second time quick sorting, the value right is set to be the j-1. After two times of quick sorting, the value 5 is exactly on the middle position of the original sequence. So the process ends, the median value is given. 3

8

5

2

6

1

9

7

4

8

5

2

4

1

9

7

6

5

2

4

1

9

7

8

5

2

4

6

9

7

8

j

i 3

i

j

3

6

3

1

3

1

i

i

5

2

4

6

j

9

7

3

j

i

3

i

3

8

ij

Figure 1. sort for the first time of incomplete quick sort algorithm

1

5

2

4

1

4

2

5

1

4

2

5

j

j

i

6

9

7

8

6

9

7

8

6

9

7

8

j

Figure 2. sort for the second time of incomplete quick sort algorithm

4. Experimental Result and Analysis A lot of standard images such as lena, horiz, squares, goldhill, peppers and other standard images are chosen in experiment to compare the performance of the median filtering algorithm based on incomplete quick sort algorithm with that of classical median filtering algorithm, divide-and-conquer method, small filtering window iteration method and sign test method. All these algorithms are implemented optimally using Visual C# 2008 and run on the same platform for fairness of the results. Except for bridge, washsat and several other image whose texture change frequently, the new algorithm proposed in this paper performs very well in general. The new median filtering algorithm based on incomplete quick sort algorithm improves the speed greatly while ensuring the quality of image, especially in large filtering radius case. As parts of the experiments, every algorithm processes separately the lena image with 200 random additive noise points, and the experimental results are shown as Table 1 and Table 2 (the relative error of sign test method is set to be ε=0.005, every algorithm is run 1000 times and then compute the average separately), as well as Figure 3 to Figure 6. As we can see that with the radius becomes larger, the processed image is more blurry, but it is not the fault of incomplete quick sort algorithm, it is because of the characteristic of median filtering algorithm. Table 1. Performance comparison of several algorithms to lena image (radius=1) Similarity of target image Algorithm Name Mean Time (Seconds) with original lena image Classical Algorithm Divide-and-Conquer Method Sign Test Method Small Window Iteration Method Incomplete Quick Sort Algorithm

7.062 6.741 5.110 6.801 4.021

82

96.21% 95.01% 95.50% 94.23% 96.21%

International Journal of Digital Content Technology and its Applications Volume 4, Number 6, September 2010

Table 2. Performance comparison of several algorithms to lena image (radius=3) Similarity of processed image Algorithm Name Mean Time (Seconds) with original lena image Classical Algorithm Divide-and-Conquer Method Sign Test Method Small Window Iteration Method Incomplete Quick Sort Algorithm

35.923 28.021 14.015 31.321 9.787

Figure 3. lena image with 200 random noise

92.23% 89.73% 91.21% 88.09% 92.13%

Figure 4. processed image (radius=1)

5. Conclusion In this paper, quick sort algorithm is thoroughly discussed, median filtering algorithm is also discussed in detail, and then the incomplete quick sort algorithm is designed for median filter algorithm. Lots of experimental results and algorithm analysis all show that the new algorithm has higher efficiency than existing algorithms. Another significance of the new algorithm is that it points out a new research direction of median filtering algorithm and sort algorithm. Selection sort algorithm, bubble sort algorithm and heap sort algorithm can also be redesigned as incomplete sort algorithms to quickly get the median value of randomly given sequences. This may be the highlight of next research.

Figure 5. processed image (radius=3)

Figure 6. processed image (radius=5)

83

A Novel Image Median Filtering Algorithm based on Incomplete Quick Sort Algorithm Dong Fuguo, Fan Hui, Yuan Da

6. Acknowledgment This work is supported by National Natural Science Foundation (60673153), National Natural Science Foundation (60773053), National Natural Science Foundation (60803048), Shandong Province Natural Science Foundation (Y2007A28) and Science and technology projects of Shandong Province Education Department ( J10LG21).

7. References [1] Tukey J. M. Exploratory Data Analysis[M]. Reading , Massachusetts: Addison, Wesley, 1971. 55-105 [2] Castleman Kenneth R. Digital Image Processing[M]. Beijing: Electronics Industry Press, 2002. 204-206 [3] Xin Wang. Adaptive Multistage Median Filter[J]. IEEE Transactions on signal processing, 1992, 40(4):1015-1017 [4] Xiahua Yang and Peng Seng Toh. Adaptive Fuzzy Multilevel Median Filter[J]. IEEE Transactions on image processing,1995,4(5):680-682 [5] H. Hwang and R.A.Haddad. Adaptive Median Filters: New Algorithms and Results[J]. IEEE Transactions on image processing,1995,4(4):244-502 [6] Yüksel M. Emin, Besdok Erkan. A simple neuro-fuzzy impulse detector for efficient blur reduction of impulse noise removal operators for digital images[J]. IEEE Transactions on Fuzzy Systems, 2004,12 (12) : 854-865. [7] Sorin Zoican. Improved median filter for impulse noise removal[J]. TELSIKS Serbia and Motenegra, Ni,2003,10(123):681-684 [8] Nelson H C Yung. Novel filter algorithm for removing impulse noise in digital image[J]. SPIE, 1995,250(1):210-220 [9] Dong Fuguo, Yuan Da, Wang Jinpeng. Study on fast algorithm of median filtering[J]. Computer Engineering and Applications,2007,43(26):48-50[董付国,原达,王金鹏.中值滤波快速算法的进 一步思考[J].计算机工程与应用.2007, 43(26):48-50] [10] Dong Fuguo, Fan Hui, Yuan Da. A Novel Parallel Algorithm of Median Filtering[J]. Computer Science. 2007, 34(12):99-101[董付国,范辉,原达.一种新的图像中值滤波并行算法[J]. 计算机 科学(专刊). 2007, 34(12):99-101] [11] Dong Fuguo, Du Ping. Sign Test Method for Image Median Filtering Fast Computation [J]. Computer Engineering and Applications . 2009, 45(19):163-164[董付国,杜萍.图像中值滤波快 速计算的符号检验法[J].计算机工程与应用.2009, 45(19):163-164] [12] Guo Haixia, Xie Kai. An Improved Method of Adaptive Median Filter [J]. Journal of Image and Graphics. 2007, 12(7): 1185-1188[郭海霞,解凯.一种改进的自适应中值滤波算法[J].中国图象 图形学报.2007, 12(7): 1185-1188] [13] Zhang Heng, Lei Zhihui, Ding Xiaohua. An Improved Method of Median Filter[J]. Journal of Image and Graphics. 2004,9(4):408-411 [张恒,雷志辉,丁晓华.一种改进的中值滤波算法[J]. 中 国图象图形学报.2004,9(4):408-411] [14] Xiao Xin, Li Yan. A Coding and Sorting Order Algorithm for Medium Filter[J]. Journal of Computer Aided Design & Computer Graphics. 2004,16(9):1256-1259[肖昕,李岩.中值滤波编码 算法的设计原理与实现[J].计算机辅助设计与图形学学报.2004,16(9):1256-1259] [15] Zhang Li, Chen Zhiqiang, Gao Wenhuan. Mean-based fast median filter[J]. Journal of Tsinghua University(Science and Technology, 2004,44(9):1157-1159[张丽,陈志强,高文焕等.均值加速的 快速中值滤波算法[J].清华大学学报(自然科学版),2004,44(9):1157-1159] [16] Zhang Xuming, Xu Binshi, Dong Shiyun. Adaptive Median Filtering for Image Processing[J]. Journal of Computer Aided Design & Computer Graphics, 2005,17(12):295-299 [张旭明,徐滨士,董世运.用 于图像处理的自适应中值滤波[J].计算机辅助设计与图形学学报.2005,17(12):295-299] [17] Liu Limei, Sun Yurong, Li Li. Research of median filter technology[J]. Journal of Yunnan Normal University (Natural Sciences Edition), 2004,24(1):23-27[刘丽梅,孙玉荣,李莉.中值滤波技术发 展研究[J].云南师范大学学报,2004,24(1):23-27]

84