Academia.eduAcademia.edu
Pattern Recognition, Vol. 28, No. 1, pp. 41 51, 1995 Elsevier Science Ltd Copyright © 1995 Pattern Recognition Society Printed in Great Britain. All rights reserved 0031-3203/95 $9.50+.00 Pergamon 0031-3203(94) E0043-K IMAGE THRESHOLDING BY MINIMIZING THE MEASURES OF FUZZINESS L I A N G - K A I H U A N G and M A O - J I U N J. W A N G t Department of Industrial Engineering, National Tsing Hua University, Hsinchu, Taiwan 300, R.O.C. (Received 13 August 1993; in revised form 22 February 1994; receivedfor publication 20 April 1994) Abstract--This paper introduces a new image thresholding method based on minimizing the measures of fuzziness of an input image. The membership function in the thresholding method is used to denote the characteristic relationship between a pixel and its belonging region (the object or the background). In addition, based on the measure of fuzziness, a fuzzy range is defined to find the adequate threshold value within this range. The principle of the method is easy to understand and it can be directly extended to multilevel thresholding. The effectivenessof the new method is illustrated by using the test images of having various types of histograms. The experimental results indicate that the proposed method has demonstrated good performance in bilevel and trilevel thresholding. Image thresholding Measure of fuzziness Fuzzy membership function I. I N T R O D U C T I O N Image thresholding which extracts the object from the background in an input image is one of the most common applications in image analysis. For example, in automatic recognition of machine printed or handwritten texts, in shape recognition of objects, and in image enhancement, thresholding is a necessary step for image preprocessing. Among the image thresholding methods, bilevel thresholding separates the pixels of an image into two regions (i.e. the object and the background); one region contains pixels with gray values smaller than the threshold value and the other contains pixels with gray values larger than the threshold value. Further, if the pixels of an image are divided into more than two regions, this is called multilevel thresholding. In general, the threshold is located at the obvious and deep valley of the histogram. However, when the valley is not so obvious, it is very difficult to determine the threshold. During the past decade, many research studies have been devoted to the problem of selecting the appropriate threshold value. The survey of these papers can be seen in the literature31-3) Fuzzy set theory has been applied to image thresholding to partition the image space into meaningful regions by minimizing the measure of fuzziness of the image. The measurement can be expressed by terms such as entropy, {4) index of fuzziness,~5) and index of nonfuzziness36) The "entropy" involves using Shannon's function to measure the fuzziness of an image so that the threshold can be determined by minimizing the entropy measure. It is very different from the classical entropy measure which measures t Author to whom correspondence should be addressed. 41 probabilistic information. The index of fuzziness represents the average amount of fuzziness in an image by measuring the distance between the gray-level image and its near crisp (binary) version. The index of nonfuzziness indicates the average amount of nonfuzziness (crispness) in an image by taking the absolute difference between the crisp version and its complement. In addition, Pal and Rosenfeld ~7) developed an algorithm based on minimizing the compactness of fuzziness to obtain the fuzzy and nonfuzzy versions of an ill-defined image such that the appropriate nonfuzzy threshold can be chosen. They used some fuzzy geometric properties, i.e. the area and the perimeter of an fuzzy image, to obtain the measure of compactness. The effectiveness of the method has been illustrated by using two input images of bimodal and unimodal histograms. Another measurement, which is called the index of area converge (IOAC), ts) has been applied to select the threshold by finding the local minima of the IOAC. Since both the measures of compactness and the IOAC involve the spatial information of an image, they need a long time to compute the perimeter of the fuzzy plane. In this paper, based on the concept of fuzzy set, an effective thresholding method is proposed. Given a certain threshold value, the membership function of a pixel is defined by the absolute difference between the gray level and the average gray level of its belonging region (i.e. the object or the background). The larger the absolute difference is, the smaller the membership value becomes. It is expected that the membership value of each pixel in the input image is as large as possible. In addition, two measures of fuzziness are proposed to indicate the fuzziness of an image. The optimal threshold can then be effectively determined by minimizing the measure of fuzziness of an image. The performance of the proposed approach is compared 42 L.-K. HUANG and M.-J. J. WANG with three commonly used thresholding methods. The method will be stated in detail in the following sections. 2. T H E F U Z Z Y S E T A N D T H E P R O P O S E D M E T H O D Hence, it is expected that the membership value of any pixel should be no less than 1/2. The membership function in (4) really reflects the relationship of a pixel with its belonging region. 2.1. The fuzzy set and membership function 2.2. Measures of fuzziness Let X denote an image set of size M × N with L levels, and x,"n is the gray level of a (m, n) pixel in X. Let lax(X,"n) denote the membership value which represents the degree of possessing a certain property by the (m, n) pixel in X; that is, a fuzzy subset of the image set X is a mapping la from X into the interval [0, 1]. In the notation of fuzzy set, the image set X can be written as The measure of fuzziness usually indicates the degree of fuzziness of a fuzzy set. It is a function, (1) X = {(x,".,lax(X,,.))}, where 0 _< lax(X.,.) _< 1, m -- 0, 1. . . . , M - 1 and n = 0, 1,..., N - 1. Here, the membership function lax(X,..) can be viewed as a characteristic function that represents the fuzziness of a (m, n) pixel in X. For the purpose of image thresholding, each pixel in the image should possess a close relationship with its belonging region: the object or the background. Hence, the membership value of a pixel in X can be defined by using the relationship between the pixel and its belonging region. Let h(0) denote the number of occurrences at the gray level 0 in an input image. Given a certain threshold value t, the average gray levels of the background/t o and the object lal can be, respectively, obtained as follows: f:A~, which gives the fuzzy set A a value to represent the degree of fuzziness of A. Several approaches of measueing the fuzziness have been proposed. Here, we introduce two commonly used methods. One is the entropy measure by using the Shannon's function ~9)and another is the Yager's measure of fuzzinesstl°) by using the distance between a fuzzy set and its complement. They are described in the following. 2.2.1. Entropy. The entropy which is used as a measure of fuzziness is in analogy with the entropy in information theory, but with a slight difference in definition. Based on the Shannon function, De Luca and Termini t4) defined the entropy of a fuzzy set A as: E(,t) = ~ n In 2 S(#A(X~)), i . . . 1,2, .. ,., with the Shannon's function S(laA(xi)) = - laa(xi)In [la~(x~)] - [1 - laA(Xi)]In [1 -- la,dxi)]. /to = ~ oh(o) g h(g) (2) g=O and la,= y~ gh(~) g=t+l h(g). g (3) 1 The average gray levels, lao and lal, can be considered as the target values of the background and the object for the given threshold value t. The relationship between a pixel in X and its belonging region should intuitively depend on the difference of its gray level and the target value of its belonging region. Thus, let the relationship possess the property that the smaller the absolute difference between the gray level of a pixel and its corresponding target value is, the larger membership value the pixel has. Hence, the membership function which evaluates the above relationship for a (m, n) pixel can be defined as: lax(Xm) = 1 if x,", < t (4) 1 + Ix,". - ' l a o ] / C - 1 1 + Ix.,. - if x m > t, lad/C where C is a constant value such that 1/2 < lax(Xm~) < 1. For a given threshold t, any pixel in the input image should belong to either the object or the background. (5) (6) Extending to the two-dimensional image plane, the entropy of an image set X is expressed as E(X) 1 X~ MN In 2 .~ s(#x(x,,n) ) with m = 0 , 1 , . . . , M - 1 and n = 0 , 1 , . . . , N - (7) 1. Using the histogram information, Equation (7) can be further revised as 1 E(X) - M N In 2 ~ S(lax(g))h(v) g = O, 1..... L - I. (8) Note that the Shannon's function in (6) is monotonically increasing in the interval [0, 0.5] and decreasing in the interval [0.5, 1]. When lax(X,~,)= 0.5 for all m and n, the entropy E will have the maximum measure of fuzziness. Thus, the entropy measure E should possess the following properties: (1) 0 < E(X) < 1. (2) E(X) has the minimum value 0, iflax(Xm) = 0 or 1 for all (m, n). (3) E(X) has the maximum value 1, if lax(xm) = 0.5 for all (m, n). (4) E(X) < E(X'), if X is crisper (sharper) than X'. (5) E(X) = E(X), where )7 is the complement of X. Image thresholding 2.2.2. Yager's measure. One major distinction between the fuzzy set and the traditional crisp set is that the fuzzy set does not always satisfy the law of the excluded middle. Yager ~ o) argued that the measure of fuzziness should be dependent on the relationship between the fuzzy set A and its complement ,4. Thus, he suggested that the measure of fuzziness should be defined as the measure of lack of distinction between A and its complement ,4. The distance between a fuzzy image set X and its complement _~ is defined as: 43 W(L-1) for an input image. Given the threshold value t = gmi., let S(t - 1) = 0 and w ( t - 1)=0. Step 1. Compute Sit) = S(t - 1) + h(t), (16) S(t) = S ( L - 1) - S(t), (17) W(t) = W(t - 1) + t x h(t), (18) ff'(t) = W ( L - 1 ) - W(t). (19) The average gray levels of the background and the object are respectively obtained by p = 1,2,3 ..... (9) where #x(Xm,)= 1 - l i x ( X , . ), Thus, the measure of fuzziness of X can be denoted as: ~/p(X) = 1 Dp(X,)?) [XI1W 1 O~(X,~) Dp(X,x)=L~lltx(g)--l,~(g)lP]l/Ph(g), (11) For p = 1, D 1 is called the Hamming metric, and for p = 2, D2 is called the Euclidean metric. Note that the measure qp(X) also satisfies the five properties stated in the previous entropy measure E(X). For a given image set X, it is expected that the measure of fuzziness should be as small as possible. Hence, our main purpose is to select an appropriate threshold value such that the measure of fuzziness of X is minimal. The computation method of the proposed approach will be presented in the following. 2.3. The computation method Given an M x N image with L levels, let gmax and 9mi, represent the maximum and minimum gray levels, respectively, and let C in (4) be equal to ( g m . - groin)' For convenience,some variables are denoted as follows: t S(t)= ~ h(g), (12) g=0 L fit)= 1 h(g) and S ( L - 1 ) = 0 , ~ g-t+ (13) l W(t) = ~ gh(g), (14) g-O L-I ~V(t) = ~ gh(g), and I~'(L- 1) = 0, tq = int [ffV(t)/S(t)], (21) where int [x] takes the integer value near the real x. To simplify the computation, we can use the histogram information to compute the Dp(X, X) by g = 0 , 1 ..... L - 1 . (20) and (10) (MN)I/P" /l 0 = int [W(t)/S(t)] (15) g=t+l Step 2. Compute the measure of fuzziness of the input image by using Equations (4), and (8) or (11). Step 3. Set t = t + 1 and go to Step 1 until t = gmax-- 1. Step 4. Find the minimum measure to determine the optimal threshold value. The two average gray levels (the two target values) in (20) and (21) are taken as integer values so that the membership value and the measure of fuzziness of each gray level can be evaluated in advance and are stored in a table. When the given threshold value t is iteratively changed from gmi, to gmax, the use of the data in the table can significantly reduce the computation time in Step 2. Hence, it is necessary to construct the table in Step 0. Sometimes, the threshold value located by minimizing the measure of fuzziness is not necessarily the deepest valley between two peaks. To make sure that the threshold should locate at the real valley, a fuzzy range is defined such that the measures within the range are equal to or less than a tolerance 6, 6 = minv + (maxv - minv) x ~%, (22) where minv = minimum measure of fuzziness; maxv = maximum measure of fuzziness; ~ is a specified value (0 < ~ < 100). By using the fuzzy range, we can further determine an improved threshold t*, which is the best location of deep valley in the gray-level histogram. In other words, the threshold t* can be obtained according to the following equation: Minimize h(g - 1) + h(g) + h(g + 1) # where 0 < t < L - 1. Note that S(L-- 1) and W ( L - 1) are constant values for an input image. The algorithm of the proposed method is described in the following. Algorithm. Step 0. Set the parameter p in (9), if using the Yager's measure. Then, calculate the S ( L - 1 ) and ge the fuzzy range. (23) Theoretically, the threshold t* should have a better chance of being located at the real valley than the threshold obtained by minimizing the measure of fuzziness, and it should have a better threshold result in practice. 44 L.-K. HUANG and M.-J. J. WANG 2.4. E x t e n s i o n to multilevel thresholdiny The proposed thresholding method can be directly extended to multilevel thresholding using the same concept presented in Sections 2.1 and 2.2. For example, if an image needs to be classified into three meaningful regions, two threshold values are required. Assume that the two threshold values, t 1 and t2, 0 ~ t I ~ t 2 L - I, are used to separate the input image into three classes. Then, by the same concept as (4), the membership function of each pixel can be defined as 1 #'x(Xmn) = 1 + IXm~ -- # o l / C ' 1 if Xm, < t~ (24) if t~ < xm, < t2, 1 + ]Xmn -- ~ I I / C ' 1 if Xmn > t 2, 1 + Ixmn -- Iz2l/C where g0, #1, and /~2 are targets (the average gray levels) of the three regions separated by t I and tz, and C', like C in (4), is also a constant to control the range of #~(x,,) in 10.5, 1]. We hope to obtain the optimal thresholds t* and t* such that the measure of fuzziness of an image set X is the minimum. Hence, the criterion function can be written as a function of the two variables, tl, and t2. The two optimal threshold values t* and t$ can be determined by minimizing the measure of fuzziness E ( X ) in (7) or r/p(X)in (10). 3. E X P E R I M E N T A L RESULTS AND EVALUATION In order to evaluate the effectiveness of the proposed method, several images shown in Fig. 1 were tested. These images grabbed from a CCD camera are 256 x 256 in size, with gray levels L = 256. All the objects in these images are meaningful. And, their corresponding gray-level histograms are shown in Fig. 2. In addition to the proposed method, three other methods, which are the Otsu's method, ~11} the moment-preserving method,O 2} and the minimum error method, "3} were used for comparison. The reason for choosing the three methods is that they are global thresholding approaches. The threshold values determined by the above methods are presented in Table !. The indices E and r/in Table 1 represent the entropic measure of fuzziness and the Yarger's (p = I) measure of fuzziness, respectively. The indices E* and r/*, respectively, represent the entropic measure and the Yager's (p = 1) measure of fuzziness of the improved approach (~ = 5). The thresholding results of the testing images obtained by the evaluating methods are shown in Figs 3 6. For the dragon image in Fig. l(a), all the proposed methods have generated acceptable thresholding results except the minimum error method, as shown in Fig. 3. Figure 4 illustrates the thresholded images of the gear image in Fig. l(b). As can be seen, Otsu's method, the moment-preserving method, and the proposed method using Yager's measure (r/) do not generate good binary results, and some noise pixels are still present. Similarly in Fig. 5, the best outcome is from E* and the output images of the other methods involve some noise pixels. This is because the two populations in the gray-level histogram have a large overlap. As for the coin image in Fig. 1(d), the corresponding histogram has four peaks due to poor illumination, but it only needs to be separated into two regions (classes). By examining the thresholded images in Fig. 6, the proposed method and the Otsu method can provide reasonable thresholding results for the coin image, but the moment-preserving method and the minimum error Fig. 1. The four test images: (a) "dragon" image; (b)"gear" image; (c)"dragon text" image; (d) "coin" image. Image thresholding O (a) ¢.. 45 (b) to ,..... | gra~! l o u o l (c) grao level gra~ level ¢,! (d) to ~, tO g..~, ¢o gra~ level Fig. 2. The gray-level histograms for images of Fig. 1:(a) "dragon" image; (b) "gear" image; (c) "dragon text" image; (d) "coin" image. Table 1. The thresholding results of applying the proposed method to the four testing images Method E E* q r/* Otsu Moment-preserving Minimum error Max. uniformity Max. shape Fig. l(a) Fig. l(b) Fig. l(c) Fig. l(d) 67 68 55 68 71 77 86 72 72 60 56 70 56 67 81 50 68 32 158 152 156 156 157 160 159 156 152 138 141 147 141 155 173 125 156 148 method cannot. The experimental results indicate that the proposed method based on the measures of fuzziness seems to have satisfactory thresholding performance. One important concern in image thresholding is the effectiveness in segmentation. According to the thresholding results, the proposed method has demonstrated satisfactory results. However, it is somewhat difficult to compare quantitatively the performance of global thresholding results. Two common performance evaluation criteria, the uniformity and the shape measure of the objects,~14} are employed to evaluate the thresholding methods. ~z'3)The uniformity indicates the degree of spread of the segmented regions from the mean. The uniformity of a region (the object or the background) is inversely proportional to the variance of the values evaluated at those pixels belonging to that region. The shape measure sums a generalized gradient value of every pixel (m, n)t2) by checking the relationship between the determined threshold value and the gray values of its neighboring pixels. The more adequate the determined threshold, the larger the shape measure. Further, by using the two performance measures, Table 2 shows the results of evaluation using the testing images shown in Fig. 1. In Table 2, the two performance measures have been normalized within the range [0,1] according to their corresponding maximum measures, which can be evaluated by the best threshold values in Table 1. For the shape evaluation results in Table 2(a-d), the proposed method has significantly better shape performance measures. It has the best shape measures of all the methods, particularly for the improved approach by using the fuzzy range. Further, the Otsu method has the best uniformity performance. This is because Otsu's 46 L.-K. H U A N G and M.-J. J. WANG Fig. 3. The binary images of Fig. l(a) tested by methods considered: (a) E; (b) E*; (c) ~/; (d) ~/*; (e) Otsu method; (f) moment-preserving method; (g) minimum error method. Image thresholding (b i 4~ !J i i (c Fig. 4. The binary images of Fig. lib) tested by methods considered: (a) E; (b) E ; (c) r/; (d) r/ ; (e) Otsu method; (f) moment-preserving method; (g) minimum error method. 47 L.-K. HUANG and M.-J. J. WANG _____,-__“___“-_ll -..“_-.~_I,“” “_.._” _.,._. __ .~----_-_l___l_l_,- -1--““- __1_1_ -_______’ ,.___ ~ 11”._._..__- Fig. 5. The binary images of Fig. l(c) tested by the methods considered: (a) E; (b) E*; (c) q; (d) q*; (e) Otsu method; (f) moment-preserving method; (g) minimum error method. Image thresholding (a) (b) (c) j:~(d) ii e) ~ ,., (g) Fig. 6. The binary images of Fig.l(d) tested by the methods considered: (a) E; (b) E*; (c) r/; (d) ~/*;(e) Otsu method; (f) moment-preserving method; (g) minimum error method. 49 50 L.-K. HUANG and M.-J. J. WANG (b) (a) ii gra~ (C, level J Fig. 7. The "cell" image for tri-level thresholding: (a) the "cell" image; (b) the gray-level histogram; (c) the thresholded image at level 139 and 190. Table 2. The performance measures for the image in Fig. 1. Method Threshold Uniformity Shape a:Fig, l(a) E E* q q* Otsu Moment preserving Minimum error 67 68 55 68 71 77 86 0.9973 0.9987 0.9648 0.9987 0.9999 0.9733 0.9542 0.9890 0.9880 0.8926 0.9880 0.9601 0,8798 0.6671 b:Fig, l(b) E E* q q* Otsu Moment preserving Minimum error 60 56 70 56 67 81 50 0.9971 0.9943 0.9994 0.9943 0.9999 0.9656 0.9876 0.9314 0.9239 0.8413 0.9239 0.8854 0.6733 0.8435 c: Fig. l(c) E E* r/ q* Otsu Moment preserving Minimum error 158 152 156 156 157 160 159 0.9982 0.9857 1.0000 1.0000 0.9999 0.9892 0.9943 0.9023 1.0000 0.9618 0.9618 0.9316 0.7982 0.8577 d:Fig, l(d) E E* r/ r/* Otsu Moment preserving Minimum error 138 141 147 141 155 173 125 0.9956 0.9970 0.9988 0.9970 0.9998 0.9633 0.9850. 0.9188 0.9570 0.9981 0.9570 0.9860 0.7222 0.6866 method is an uniformity-oriented algorithm. Overall, the proposed method has demonstrated outstanding results in both performance measures. Furthermore, the proposed method was applied to trilevel thresholding using the cell image shown in Fig. 7(a). The corresponding gray-level histogram shown in Fig. 7(b) has three rough peaks. By applying the proposed method to the cell image, the two threshold values determined by m i n i m i z i n g the two measures of fuzziness are at levels 139 and 190. The thresholding result is shown in Fig. 7(c). By comparing the original image with the thresholded image, it seems that the proposed method has again demonstrated excellent performance. 4. CONCLUSION Based on the concept of fuzzy sets and the definition of membership function, a new thresholding method is proposed. It utilizes the measures of fuzziness of an input image to identify the appropriate threshold value. The two fuzziness measures (i.e. one using Shannon's function and one using Yager's measure) have maximum fuzziness when lax(X,,,)= 0.5 and minimum fuzziness when lax(X,,,)= 1. Since C in equation (4) is taken as (gmax -- 9mi,) in our algorithm, the membership values of all pixels are in the interval [0.5, 1]. It is expected that the membership values of each pixel can be as close to 1 as possible, so that the fuzziness of each pixel is as minimal as possible. In conclusion, the proposed method which is based on minimizing the measure of fuzziness of an image has demonstrated very satisfactory performance in Image thresholding bilevel and trilevel thresholding. The use of the fuzzy range can help to locate effectively the deep valley of the histogram. Furthermore, a simple algorithm that can improve the computation time is also suggested. 4. 5. 5. SUMMARY Based on the concept of fuzzy sets and the definition of membership function, a new image thresholding method is proposed. It utilizes the measure of fuzziness to evaluate the fuzziness of an image and to determine an adequate threshold value. Two c o m m o n performance evaluation criteria, the uniformity and the shape measure, were employed to evaluate some thresholding methods. The experimental results indicate that the proposed method can effectively find an appropriate threshold value. 6. 7. 8. 9. 10. 11. REFERENCES 12. 1. J. S. Weszka, A survey of threshold selection techniques, Comput. Vision Graphics Image Process. 7, 259-265 (1978). 2. P. K. Sahoo, S. Soltani and A. K. C. Wong, A survey of threshold techniques, Comput. Vision Graphics Image Process. 41, 233-260 (1988). 3. S. U. Lee and S. Y. Chung, A comparative performance study of several global thresholding techniques for seg- 13. 14. 51 mentation, Comput. Vision Graphics Image Process. 52, 171-190 (1990). A Deluca and S. Termini, A definition ofa non-probabilistic entropy in the setting of fuzzy set theory, Int. Control 20, 301-312 (1972). A. Kaufmann, Introduction to the Theory of Fuzzy Subsets--Fundamental Theoretical Elements, Vol. 1. Academic Press, New York (1975). S. K. Pal, A measure of edge ambiguity using fuzzy sets, Pattern Recognition Lett. 4, 51-56 (1986). S.K. Pal and A. Rosenfeld, Image enhancement and thresholding by optimization of fuzzy compactness, Pattern Recognition Lett. 7, 77-86 (1988). S. K. Pal and A. Ghosh, Index of area converge of fuzzy image subsets and object extraction, Pattern Recognition Lett. 11, 831-841 (1990). L. A. Zadeh, Fuzzy Sets and their Applications to Cognitive and Decision Processes, pp. 1-39. Academic Press, London (1975). R. R. Yager, On the measure of fuzziness and negation. Part I: Membership in the unit interval, Int. J. yen. Syst. 5, 221-229 (1979). N. Otsu, A threshold selection method from gray-level histogram, IEEE Trans. Syst. Man Cybern. 8, 62-66 (1978). W. Tsai, Moment-preserving thresholding: a new approach, Comput. Vision Graphics Image Process. 29, 377-393 (1985). J. Kittler and J. IUingworth, Minimum error thresholding, Pattern Recognition 19, 41-47 (1986). M. D. Levine and A. M. Nazif, Dynamic measurement of computer generated image segmentations, IEEE Trans. Pattern Anal. Mach. lntell. 7, 155 164 (1985). About the A u t h o r - - LIANG-KAI HUANG received a B.S. degree (1989) and M.S. degree (1991) in Industrial Engineering from National Tsing Hua University, Taiwan, Republic of China. He is currently working on his Ph.D. degree. His research interests include machine vision, automated inspection, and pattern recognition. About the Author--MAO-JIUN J. WANG is a Professor of Industrial Engineering at National Tsing Hua University, Taiwan, Republic of China. He received his Ph.D. in Industrial Engineering from the State University of New York at Buffalo in 1986. His research interests include computer vision systems, fuzzy set theory, and automatic inspection.