Sei sulla pagina 1di 5

2012 13th ACIS International Conference on Software Engineering, Artificial Intelligence, Networking and Parallel/Distributed

Computing

An Improved Image Segmentation Algorithm Based on the Otsu Method

Mengxing Huang, Wenjiao Yu, Donghai Zhu


College of Information Science & Technology
Hainan University
Haikou, P. R. China
huangmx09@gmail.com

Abstract—By analyzing the basic principle of Otsu method and W1 = {0,1,2, ⋅⋅⋅䯸 T } and
such that
its application in image segmentation, and according to the
distribution characteristics of the target and background, an W2 = {T + 1䯸 T + 2䯸⋅⋅⋅,L-1} , where L is the total
improved threshold image segmentation algorithm based on
number of the gray levels of the image. Let the number of
the Otsu method is developed. By narrowing the selection L-1
range of threshold and searching the minimum variance ratio,
the improved algorithm selects the optimal threshold. Through pixels at i gray level be ni , and N = ¦ n i be the total
the compared with the Otsu method and other methods, the i =0
results show that the new improved algorithm has these number of pixels in a given image. The probability of
advantages such as high segmentation precision and fast occurrence of gray level i is defined as
computation speed. ni L-1
pi = 䯸 p i ≥ 0䯸¦ p i = 1 . W1 and W2 are normally
Keywords- Otsu method; image segmentation; optimal N i =0
threshold; selection range; minimum variance ratio corresponding to the object of interested and the background,
the probabilities of the two classes are
I. INTRODUCTION T

Image segmentation is one of the basic problems of the Pw1 = ¦ pi and Pw 2 = ¦ pi = 1-Pw1 .
i =0
image processing and machine vision, its key point is: the
image is divided into a number of sets that do not mutual The means of the classes W1 and W2 can be computed
overlapping zones; these zones either have meaning to as:
currently mission or help to explain correspondence between T
i * pi
them and the actual object or some parts of object. Image
segmentation have a wide range of applications in practice,
μ w1 = ¦ (1)
i = 0 Pw1
such as: industry automation, product online detection,
L −1
manufacturing and process control, remote sensing image i * pi
processing, biomedical image analysis, etc [1][2]. μ w1 = ¦ (2)
Threshold is a commonly used method that improves the i =T +1 Pw 2
image segmentation effect obviously, meanwhile it is So we can get the equivalent formula:
simpler and easier to implement. However, it fails when the σ 2 (T ) = Pw1Pw 2 ( μ w1 − μ w 2 ) 2 (3)
difference of the two within-class variances is large and the
*
result of Otsu method may be present twin peaks or more The optimal threshold T can be obtained by
peaks [3]. By studying the principle of the Otsu method and maximizing the between-class variance.
its application in image segmentation, an improved threshold T * = Arg max σ 2 (T ) (4)
image segmentation algorithm based on the Otsu method is 0<T< L-1
developed. By narrowing the selection range of threshold The Otsu method is simple and has a stable affection, so
and searching the minimum variance ratio, the improved it has been widely applied in image segmentation in practice
algorithm selects the optimal threshold. The results of the .It play an important role in the automatic selection of
simulation by different images were analyzed, studied, threshold. However, we found that the Otsu method is very
compared. The results show that the improved Otsu sensitive about noise and the size of target. It is only
algorithm has these advantages such as high segmentation effective to the image with single peak variance after the
precision and fast computation speed. experiments to many kinds of images. When the difference
of the two intra-class variances is large, the threshold of the
II. OTSU METHOD Otsu method tends to be closer to the class with larger intra-
Otsu proposed a dynamic threshold selection method in class class variance, which means that more pixels of this
1979. This method suggests maximizing the weighted sum of class will be classified into the another class [5], so the
between-class variances of foreground and background segmentation result needs to be improved.
pixels to establish an optimum threshold [4]. We can
partition the image into two classes W1 and W2 at gray T

978-0-7695-4761-9/12 $26.00 © 2012 IEEE 135


DOI 10.1109/SNPD.2012.26
III. THE PROPOSED OTSU METHOD L -1
i * pi
In order to overcome the above problems, this paper T2 = 㺌P (7)
presents an improved Otsu method, the main steps of i =T0 +1 w2
improved Otsu method: Where the Pw 2 is defined in (2).

D. Define the scope of threshold


It is very importance to choose a reasonable threshold
range for the optimization algorithm. First, we can exclude a
large part of the gray values and less time is consumed
greatly by narrowing the selection range of threshold.
Second, by removing the gray value which is too low or too
high, which reduced the noise in the image, so that reduced
the false selection rate of the optimal threshold. How to
determine the threshold for the range of options, in a number
of papers have been discussed.
Generally speaking, since the initial threshold value T0
is the mean of whole image, and the most dark areas of
image are belong to background, a small part of the lighter
areas are the target, the final threshold must be greater than
the first threshold value T0 . Therefore, we can set the mean
of class W1 as the lower threshold, which would eliminate a
large part of low gray area, meanwhile without losing the
potential optimal threshold.
 For the choice of the range of threshold, we consider the
Figure 1. The main steps of improved Otsu method following reasons: When using the initial threshold T0 to
segment the original image, due to the exclusion of a large
A. Initial threshold segmentation part of low gray background pixels which belong to W1 ,
We can partition the image into two classes W1 and then the proportion of target areas will increases in W2 , the
W2 with the image mean grey value T0 such that mean value T2 increased, which is higher than the target
W1 = {0,1,2,⋅ ⋅ ⋅䯸 T } area, so we set T2 as high threshold. Finally, the scope of
and W2 = {T + 1䯸 T + 2䯸⋅ ⋅⋅, L - 1} , where L is the total threshold value is defined, so that we can search for optimal
number of the gray levels of the image. threshold in [T1 , T2 ] .
L -1
T0 = 㺌i * p i (5) E. Calculate inter-class variance and intra-class variance
i =0 The variance of W1 and W2 are defined as follow:
L-1
pi =
ni
䯸 p i ≥0䯸㺌p i = 1 (i - μ w1 ) 2 * p i
T
Where
N σ 2
w1 =㺌 (8)
i =0 i =0 Pw1
L 1
B. Calculate lower threshold (i - w 2 ) 2 * p i
 2
w2 = 㺌 (9)
The means of W1 can be computed as: Pw2
i =T +1
T0
i*p Where T 㺃㪲T0 , T1 ] .
T1 = 㺌 i (6)
i =0 Pw1
The intra-class can be computed as˖
2
Where the Pw1 is defined in (1).  W =  2 w1 +  2 w2 . The inter-class can be computed as:
 2 i = Pw1 Pw 2 ( w1 - w 2 ) 2
C. Calculate high threshold
Calculate the mean value of the class W2 to get the high F. Calculate the minimum variance ratio
threshold T2 ˖ The minimum variance ratio is defined as:

136
σ 2W
λ= (10)
σ 2i
The inter-class variance σ 2i indicates the different of
class W1 and W2 . There are more differences between class
W1 and W2 , the larger the σ 2 i will be. The intra-class
2
variance  W means the discrete degree of the class W and 1
W2 .The more concentrated the gray in the class W1 and W2 ,
the littler the σ W will be. Both of the inter-class variance
2

and the intra-class variance are considered when we choose 


the λ , so if we want to get the best segmentation, this
(a)

method should make sure that λ as littler as it can.


G. Image segmentation
To divide the 256 grey values into two categories by
optimal threshold value. Making all of the grey value of
pixels less than T to be 0 and making the gray value of pixels
equal or greater than T to 255.
IV. THE RESULTS OF THE SIMULATION EXPERIMENT AND
ANALYSIS

In order to evaluate the performance of the proposed 


method, our algorithm has been tested using images Swan (b)
(481*321) and image Orange (256*256) in Fig.2, and Fig.3 Figure 2. Original images: (a) Swan, (b) Orange
shows the histogram of the images. We can find that the
difference of the two intra-class variances is large from the
histogram of the images, so these images are very suitable to
test our algorithm . The basic information of the images
showed in table I.

TABLE I. THE BASIC INFORMATION OF THE IMAGES

 Swan Orange
Pixel number 154401 160000
Maximum gray value 255 255
Minimum gray value 12 20
Average gray values 89.6796 189.7138
Lower threshold 175 186
High threshold 194 220
(a)

137
(a)

(b)
Figure 3. The histogram of the image: (a) Swan, (b) Orange

A. The effect of image segmentation


The Otsu method is used to segment the image in Fig. 4;
however, it gives an incorrect threshold value that fails to
isolate the contaminant. However, our method and Zhong's
method [6] which is also an image segmentation based on
the improved Otsu algorithm successfully isolated the
contaminant in the image. We can see from Fig. 5 and Fig. 6 (b)
that the proposed method produces images that are Figure 5. Segmentation results by method[6]: (a) Swan, (b) Orange
successfully distinguished from the backgrounds.

(a)

(a)

(b)
(b)
Figure 4. Segmentation results by Otsu method: (a) Swan, (b) Orange Figure 6. Segmentation results by proposed method: (a) Swan, (b) Orange

138
B. Results analysis is more close to the real threshold, so it is a more practical
Compared the proposed method with Otsu method and and effective image threshold segmentation method
the method [6] by repeat the test 100 times. The test results
ACKNOWLEDGMENT
showed in table II.
This work is supported by the National Natural Science
TABLE II. OPTIMAL THRESHOLD AND COMPUTING TIME Foundation of China under Grant No. 71161007, the Social
Science Fund Project of Ministry of Education under Grant
Swan Orange No. 10YJCZH049, the Key Science and Technology
Otsu method
Optimal threshold 139 177 Program of Haikou under Grant No. 2010-0067 and the
Average time /ms 12.78636 12.84267 Scientific Research Initiation Fund Project of Hainan
Method in Optimal threshold 173 185 University under Grant No. kyqd1042.
[6] Average time /ms 20.35641 19.29573
Proposed Optimal threshold 175 186 REFERENCES
method Average time /ms 13.25282 13.24611
[1] He Jun, Ge Hong, Wang Yu-feng,” Survey on the methods of image
Following conclusions from table II can be gained. The segmentation research,” Computer engineering &science, vol.31,
no.12, 2009.
threshold of Otsu method getting optimal threshold is
[2] M. Sezgin and B. Sankur. “Survey over image thresholding
smaller than that the method [6] and the proposed method techniques and quantitative performance evaluation”, Journal of
get. From the histogram of the image Swan and Orange, we Electronic Imaging, pp.146-156, 2003.
can find that the size of background and target is very [3] P. K. Sahoo, S.Soltani, A.K. Wong, and Y. C. Chan, “A survey of
different. The variance of background is big and the variance thresholding techniques”, Computer Vision Graphics, and Image
of target is small. According to the principle that when the Processing, vol.41, pp. 233-260, 1998
difference of the two variances is large, the threshold of the [4] N. Otsu, “A threshold selection method from gray-level histogram”,
Otsu method tends to be closer to the class with larger IEEE Transactions on Systems Man Cybernet, SMC-8 pp. 62-66,
variance, which means that threshold will be small than the 1978.
real threshold. This means that the thresholds of the method [5] Xu Xiang-yang, Song En-min, JIN Liang-hai, “Characteristic
in [6] and the proposed method is more close to the real Analysis of Threshold Based on Otsu Criterion”, Acta Electronica
Sinica, vol.33, no.14, pp. 188-189, 2007.
threshold than the threshold of the Otsu method. Meanwhile,
the time of Otsu method and the proposed method consume [6] Qu Zhong, “Research On Image Segmentation Based on the
Improved Otsu Algorithm “, Computer Science, vol.36, no.5, pp. 276-
is less than that the method [6] need. The reason is that the 278, 2009.
complexity of the proposed method and the method [6] are
[7] Jiang Qin-yu, Li Ping, Sun Lan,”Application of Otsu method in
increased, but the time of the proposed method is reduced by motion detection system”, Journal o f Computer Applications, vol.31,
narrowing the range of threshold selection. no.1, pp. 260-262,2011.
[8] Hu Chang-hua, Nie Zhi-fei, Zhou Zhi-jie, ”Maximum Classes Square
V. CONCLUSIONS Error Bi-histogram Algorithm”, System Simulation Technology,
By analyzing the basic principle of Otsu method and its vol.6, no.4, pp. 259-262,2010.
application in image segmentation, and according to the [9] Chen S D, Ram Li A R. “Contrast enhancement using recursive
mean-separate histogram equalization for scalable brightness
distribution characteristics of the target and background, an preservation”, IEEE Transactions on Consumer Electronics, vol.49,
improved threshold image segmentation algorithm based on no.4, pp. 1301-1309, 2003.
the Otsu method is developed. By narrowing the selection [10] H. Lee, R. H. Park. “Comments on an optimal threshold scheme for
range of threshold and searching the minimum variance image segmentation”, IEEE Trans. Syst.Man Cybern, SMC-20,
ratio, the improved algorithm selects the optimal threshold. pp.741-742, 1990.
Through the compared with the Otsu method and other [11] J. Z. Liu, W. Q. Li, “The Automatic thresholding of gray-level picture
methods, the results show that the new improved algorithm via two-dimensional Otsu method”, Acta Automatica Si.19, pp.101-
105, 1993.

139

Potrebbero piacerti anche