Thresholding Based On Variance and Intensity Contrast
Thresholding Based On Variance and Intensity Contrast
www.elsevier.com/locate/patcog
Thresholding based on variance and intensity contrast
Yu Qiao
a,
, Qingmao Hu
a
, Guoyu Qian
a
, Suhuai Luo
b
, Wieslaw L. Nowinski
a
a
Biomedical Imaging Lab, Agency for Science, Technology and Research, 30 Biopolis Street, #07-01 Matrix, Singapore 138671, Singapore
b
School of Design, Communication and Information Technology, The University of Newcastle, University Drive, Callaghan NSW 2308, Australia
Received 11 October 2005; received in revised form 28 March 2006; accepted 21 April 2006
Abstract
A new thresholding criterion is formulated for segmenting small objects by exploring the knowledge about intensity contrast. It is
the weighted sum of within-class variance and intensity contrast between the object and background. Theoretical bounds of the weight
are given for the uniformly distributed background and object, followed by the procedure to estimate the weight from prior knowledge.
Tests against two real and two synthetic images show that small objects can be extracted successfully irrespective of the complexity of
background and difference in class sizes.
2006 Pattern Recognition Society. Published by Elsevier Ltd. All rights reserved.
Keywords: Thresholding; Histogram; Intensity contrast; Small object segmentation; Prior knowledge
1. Introduction
Thresholding is one of the most important and effective
methods for image segmentation, especially, when the image
consists of an object well separated from the background in
terms of intensity. By choosing a suitable threshold between
the dominant intensities of the background and object, the
original image can be partitioned into regions of the object
and background.
Many thresholding approaches have been proposed and
studied. They can be classied into approaches purely based
on intensity histogram and those based on knowledge. The
former can further be classied as methods based on valley
detection [1,2] and those based on criteria optimization. Var-
ious criteria have been proposed. The minimum error thresh-
olding method (MinError) assumes the normal distribution
for both object and background [3,4]. The optimum thresh-
old is achieved by optimizing a criterion function related to
the Bayes risk. Lee and Yang [5] estimated the parameters
2
W
(T ) =P
b
(T )
2
b
(T ) +P
o
(T )
2
o
(T ), (2)
where P
b
(T ) and P
o
(T ) are probabilities of the background
and object,
2
b
(T ) and
2
o
(T ) are corresponding variances of
the background and object, respectively (see Ref. [10] for
their calculation). In this criterion, the within-class variance
measures the intensity homogeneity within the object and
background while intensity contrast captures the intensity
difference between them. The parameter is a weight that
balances their contributions. When =0, the new criterion
degenerates to the within-class variance. If = 1, thresh-
olding is determined only by the intensity contrast, which
may yield the threshold at the largest intensity of the image.
Therefore, the weight should be in the range of [0, 1).
The optimum threshold T
) =min
T
J(, T ). (3)
Eq. (3) actually tries to decrease the within-class variance
and increase the intensity contrast simultaneously. In this
way, the intensity contrast becomes an explicit factor for
determining the optimum threshold.
2.3. The algorithm
An appropriate selection of the weight is desirable such
that a proper balance between the variance and contrast is
achieved to yield the correct threshold.
Theoretical bounds of are generally difcult to obtain
as both the variance and contrast are hard to be expressed
Y. Qiao et al. / Pattern Recognition 40 (2007) 596608 599
Fig. 5. Example 2: (a) the histogram of the image Fig. 4(a); (b) the value
of criterion with various ; and (c) the optimum threshold of different .
analytically. To simplify, we assume that both the object
and background are uniformly distributed (Fig. 1). More
specically, suppose the background is uniformly distributed
in [0, 2L], while the object is evenly located in [C qL,
C +qL]. The probability of the background and object are
k/(k + 1) and 1/(k + 1), respectively. When k approaches
innity (for small object), we have the following bounds
for
1/2
3
C/L (2 1/2
3)
3(C/L 1)
2
q
2
2
p
min
and
p
max
, respectively, such that P
o
l
P
o
()P
o
h
if
p
min
p
max
.
3. Search the minimum and maximum and denote them
as
c
min
and
c
max
, respectively, such that C
l
|m
o
()
m
b
()| C
h
if
c
min
c
max
.
4. Dene
min
= max(
p
min
,
c
min
) and
max
= min
(
p
max
,
c
max
).
5. Estimate
=(
min
+
max
)/2.
Since obtained with this procedure satises both condi-
tions (Eqs. (5) and (6)), it is a valid choice. Furthermore,
the interval [
min
,
max
] can be a constraint for the online
adjustment of .
The thresholding algorithm consists of two steps as fol-
lows:
(1) Estimate an appropriate weight
such that J(
, T
) dened by
Eq. (1) is minimized.
3. Experimental results
We have applied the proposed thresholding method to
two synthetic and two real images. For all experiments,
the weight
Intensity con-
trast |m
o
m
b
|
Proportion of
object P
o
(%)
Otsu 19 20 60.9
c
min
=0.013 58 70 1.8
c
max
=0.094 76 74.99 1.44
p
min
=0.013 58 70 1.8
p
max
=0.165 83 77 1.3
=0.054 69 73 1.6
Table 3
Example 2: optimum thresholds, the corresponding intensity contrasts and
proportions of object of the Otsu method and the proposed method
Optimum
threshold T
Intensity con-
trast |m
o
m
b
|
Proportion of
object P
o
(%)
Otsu 52 44 47.6
c
min
=0.043 90 160 1.05
c
max
=0.999 219 168 0.026
p
min
=0.043 90 160 1.05
p
max
=0.366 90 160 1.05
Intensity con-
trast |m
o
m
b
|
Proportion of
object P
o
(%)
MinError 32 72 90
Otsu 97 58 40
c
min
=0.084 137 110 5
c
max
=0.999 214 120 0.0005
p
min
=0.0 97 58 40
p
max
=0.49 186 110 5
Intensity con-
trast |m
o
m
b
|
Proportion of
object P
o
(%)
MinError 103 32.56 60
Otsu 137 58.29 23
c
min
=0.051 140 60.22 21
c
max
=0.999 209 88.3 0.08
p
min
=0.306 168 76.5 9.9
p
max
=0.422 173 77.3 9.3
i=1
[P
i
(ln
i
ln P
i
)], (7)
where P
i
is the probability of the ith class and
i
the cor-
responding variance. It is based on the assumption that the
histogram of image is a mixture of multiple normal densi-
ties.
MinError works best when the assumption is satised
and prior knowledge about the number of classes is correct
(Fig. 7(d)). The real object may not be extracted if the as-
sumption about the number of classes is wrong (Figs. 7(b)
and (c)). The segmentation may become worse when the
histogram of the image cannot be well approximated by
a mixture of n-mode normal distribution. When n is too
large, this method is too computationally expensive to be
applicable. In example 4, the intensity histogram can not
be well approximated by a mixture of n-mode normal dis-
tributions (n = 2, 3, 4). Thus, the real object cannot be ex-
actly recognized with the multiple thresholding of MinError
(Figs. 10(b)(d)).
In addition, the absence of an explicit term of intensity
contrast in the criterion (Eq. (7)) may cause MinError to
share a similar tendency to the Otsu method, i.e., the se-
lection of threshold ignores the information about intensity
contrast (Figs. 7 and 10).
Hu et al. [12] explored prior knowledge about the pro-
portion of object for thresholding. Their method may not be
well applicable to segmenting small objects as the tight range
of object proportion may not be available. For example, for
the segmentation of cerebral vessels (example 1), we only
know the loose range of object proportion ([1%, 50%)]. The
threshold based on this range using the Otsu method [12] is
25 (P
o
=44%), which is too small. The proposed criterion,
however, is still applicable (Table 2).
The desired segmentation of all four examples by the pro-
posed method clearly illustrates its advantage in extracting
small objects from complex background (Figs. 2(d), 4(c),
6(b) and 9(d)). The new criterion can segment the small
object because it explicitly tries to balance the within-class
variance and the intensity contrast.
4.2. Weight selection
The parameter uniquely determines the optimum thresh-
old and thus the quality of segmentation results. The op-
timum threshold will be the same as that of Otsu method
when is too small (0.012 for example 1 (Fig. 3(c)),
0.042 for example 2 (Fig. 5(c)), 0.083 for example 3
(Fig. 8(c)), and 0.016 for example 4 (Fig. 11(c))). On the
other hand, a too large value of will result in over-weight
of intensity contrast and thus yields a too high threshold
(Figs. 6(d) and 9(f)).
Figs. 3(b), 5(b), 8(b) and 11(b) show the relationship
between the value of the new criterion (Eq. (1)) and the
threshold for different weights of the four examples. When
is small, the new criterion takes the minimum at the
lower end where within-class variance dominates. So the
yielded threshold is close to that of the Otsu method. As
increases, within-class variance and the intensity con-
trast are balanced to yield the desirable threshold ( in
the ranges of [0.013, 0.094], [0.043, 0.366], [0.084, 0.49]
and [0.306, 0.422] for examples 14, respectively). When
is too large, the intensity contrast overwhelms to
yield a too high threshold. In this situation the selected
604 Y. Qiao et al. / Pattern Recognition 40 (2007) 596608
Fig. 11. Example 4: (a) the histogram of ROI for the inverted image
Fig. 9(c); (b) the value of criterion with various ; and (c) the optimum
threshold of different .
threshold is usually the maximum intensity of the image or
very close to it. For example, Figs. 3(b) and (c) in example
1 indicate that when 0.166 the threshold T = 112 that
maximizes the criterion (Eq. (1)) is the maximum image in-
tensity (Fig. 3(a)). So J(, T ) is only dened with T 112.
Similarly, the optimum threshold is around the maximum
image intensity for example 2 (0.368 (Figs. 5(b) and
(c)), T =219 (Fig. 5(a))), example 3 (0.491 (Figs. 8(b)
and (c)), T = 214 (Fig. 8(a))) and example 4 (0.573
(Figs.11(b) and (c)), T =209 (Fig. 11(a))).
An appropriate threshold can only be obtained with a suit-
able value of that well balances the inuences of within-
class variance and intensity contrast in the criterion (Eq. (1)).
Though theoretically there exists a range of to give the de-
sirable segmentation results (Figs. 2(d), 4(c), 6(b) and 9(d)),
the range is application dependent. We observe that if the ob-
ject is well separated from the background by some valleys
in the histogram there may be jumps of optimum threshold
around some . Fig. 3(c) indicates that the optimum thresh-
old has two big jumps in example 1, one from T
=19 to 58
around =0.013 and the other from T
=90 to
200 when =0.367. The jumps in example 3 (Fig. 8(c)) are
also substantial, the rst from T
= 173 to
187. These jumps mark the sharp transitions of the new cri-
terion from the state of dominated within-class variance to
the state of balanced within-class variance and intensity con-
trast or from the latter to the state of over-weighted intensity
contrast. Hence,these jumps may be useful for searching an
appropriate .
However, jumps that mark the state transition of the new
criterion may not always be obvious. In Fig. 11(c) the jump
at = 0.573 happens at the state of over-weighted inten-
sity contrast. No jumps indicate the state transition from
dominated within-class variance to balanced within-class
variance in this example. In this situation, estimation of
based on prior knowledge about intensity contrast and
the proportion of object should be employed. The appro-
priate value of can be estimated with the knowledge
from the original images (examples 2 and 3) or from the
experience in the special eld (medical knowledge in ex-
amples 1 and 4). Tables 25 list the range of obtained
with the knowledge and the suitable estimate for the four
examples.
4.3. Choice of ROI
An ROI is adopted to simplify analysis for easier approx-
imation of object proportion and intensity contrast and more
efcient exploration of prior knowledge. The basic guide-
line is that the ROI should include the object in the presence
of possible variations in both the size and the position of the
object, and the ROI should be as small as possible. When
the size of ROI varies, both the object proportion and the in-
tensity contrast can change. When ROI increases, the object
Y. Qiao et al. / Pattern Recognition 40 (2007) 596608 605
proportion decreases, while the intensity contrast may
increase or decrease. For example 1, the position and
variation of the three vessels are roughly known from
medical literature, and the drawn ROI is based on the
study of literature. Expanding the ROI will decrease the
object proportion but have little impact on the intensity
contrast. With the modied object proportion, new valid
can be found to yield similar segmentation. For exam-
ple, if the size of ROI increase 10% along both horizon-
tal and vertical directions, the lower bound of object P
o
l
decreases from 1% to 0.83%, which generates the corre-
sponding estimated weight (
k
(k +1)
1
2L
, 0x 2L,
1
(k +1)
1
2qL
, C qLx C +qL,
0 otherwise.
(A.1)
1. When T belongs to (0, 2L), the object function is de-
noted as J
1
(, T ).
P
b
(T ) =
T
0
f (x) dx
=
T
0
k
(k +1)
1
2L
dx =
T
2L(1 +1/k)
T
2L
,
P
o
(T ) =1 P
b
(T )
2L T
2L
,
m
b
(T ) =
1
P
b
(T )
T
0
xf (x) dx
=
1
P
b
(T )
T
0
x
k
(k +1)2L
dx =
T
2
,
m
o
(T ) =
1
P
o
(T )
C+qL
T
xf (x) dx
=
1
P
o
(T )
2L
T
x
k
(k +1)2L
dx
+
C+qL
CqL
x
1
(k +1)2qL
dx
=
1
1 P
b
(T )
k
k +1
4L
2
T
2
4L
+
C
k +1
L +
T
2
,
2
b
(T ) =
1
P
b
(T )
T
0
[x m
b
(T )]
2
f (x) dx =
T
2
12
,
2
o
(T ) =
1
P
o
(T )
C+qL
T
[x m
o
(T )]
2
f (x) dx
=
1
P
o
(T )
2L
T
[x m
o
(T )]
2
k
(k +1)2L
dx
+
C+qL
CqL
[x m
o
(T )]
2
1
(k +1)2qL
dx
(2L T )
2
12
,
2
w
(T ) =P
b
(T )
2
b
(T ) +P
o
(T )
2
o
(T )
(L T )
2
4
+
L
2
12
,
J
1
(, T ) =(1 )
w
(T ) [m
o
(T ) m
b
(T )]
(1 )
(L T )
2
4
+
L
2
12
L
(1 )
L
12
L. (A.2)
606 Y. Qiao et al. / Pattern Recognition 40 (2007) 596608
2. When T belongs to (2L, C qL), the object function
is denoted as J
2
(, T ).
m
b
(T ) =L, P
b
(T ) =
k
(k +1)
1
1
1
k
1,
m
o
(T ) =C, P
o
(T ) =
1
(k +1)
1
1
k
0,
2
b
(T ) =
1
P
b
(T )
2L
0
[x m
b
(T )]
2
f (x) dx =
L
2
3
,
2
o
(T ) =
1
P
o
(T )
C+qL
CqL
[x m
o
(T )]
2
f (x) dx =
q
2
L
2
3
,
2
w
(T ) =P
b
(T )
2
b
(T ) +P
o
(T )
2
o
(T )
1
L
2
3
+
L
2
3k
(q
2
1)
L
2
3
,
J
2
(, T ) =(1 )
w
(T ) [m
o
(T ) m
b
(T )]
1
(1 )
L
3
(C L) +
L(q
2
1)(1 )
2
3k
(1 )
L
3
(C L). (A.3)
3. When T belongs to (C qL, C + qL], the object
function is denoted as J
3
(, T ).
P
b
(T ) =
T
0
f (x) dx =
k
k +1
+
T C +qL
2qL(k +1)
1
1
1
k
(C +qL T )
2qL
1,
P
o
(T ) =1 P
b
(T )
1
1
k
(C +qL T )
2qL
0,
m
b
(T ) =
1
P
b
(T )
T
0
xf (x) dx
=
1
P
b
(T )
2L
0
x
k
2L(k +1)
dx
+
T
CqL
x
1
2qL(k +1)
dx
1
L +
1
k
C +qL T
2q
L +
T
2
(C qL)
2
4qL
L,
m
o
(T ) =
1
P
o
(T )
C+qL
T
xf (x) dx =
C +qL +T
2
,
m
o
(T ) m
b
(T )
1
C +T +(q 2)L
2
1
k
C +qL T
2q
L +
T
2
(C qL)
2
4qL
2
b
(T ) =
1
P
b
(T )
T
0
[x m
b
(T )]
2
f (x) dx
=
1
P
b
(T )
2L
0
[x m
b
(T )]
2
k
2L(k +1)
dx
+
T
CqL
[x m
b
(T )]
2
1
2qL(k +1)
dx
1 +
C +qL T
2qLk
L
2
(1 1/k)
3
+
1
k
(T L)
3
(C qL L)
3
6qL
1
L
2
3
+
1
k
L
2
3
+
L(C +qL T )
6q
+
(T L)
3
(C qL L)
3
6qL
2
o
(T ) =
1
P
o
(T )
C+qL
T
[x m
o
(T )]
2
f (x) dx
=
(C +qL T )
2
12
,
2
w
(T ) =P
b
(T )
2
b
(T ) +P
o
(T )
2
o
(T )
1
1
C +qL T
2kqL
L
2
3
+
1
k
L
2
3
+
L(C +qL T )
6q
+
(T L)
3
(C qL L)
3
6qL
+
(C +qL T )
3
24kqL
1
L
2
3
1 +
1
k
1 +
(T L)
3
(C qL L)
3
2qL
3
+
(C +qL T )
3
8qL
3
,
J
3
(, T ) =(1 )
w
(T ) [m
o
(T ) m
b
(T )]
1
(1 )
L
1 +
1
2k
1
+
(T L)
3
(C qL L)
3
2qL
3
+
(C +qL T )
3
8qL
3
C +qL +T 2L
2
+
k
C +qL T
2q
L +
T
2
(C qL)
2
4qL
.
Y. Qiao et al. / Pattern Recognition 40 (2007) 596608 607
As J
3
(, T ) takes minimum at T =(C +qL), so
J
3
(, T )
(1 )
L
3
(C +qL L) +
1
k
(1 )
L
2
(C +qL L)
3
(C qL L)
3
2qL
3
1
+
k
(C L).
As q is small, we further simplify the above expression as
J
3
(, T )(1 )
L
3
(C +qL L)
+
L(1 )
2
3k
C
L
1
2
1
+
k
(C L). (A.4)
In order to nd the constraints on such that T will be in
the range [2L, C qL), we need the following condition:
J
1
J
2
and J
3
J
2
. (A.5)
When J
1
J
2
, we have (using limits of J
1
and J
2
)
(1 )
L
12
L(1 )
L
3
(C L)
1/(2
3)
C/L 2 +1/(2
3)
. (A.6)
When J
2
J
3
, we have (using rst order Taylor series of J
2
and J
3
)
(1 )
L
3
(C L) +
L(q
2
1)(1 )
2
3k
(1 )
L
3
(C +qL L)
+
L(1 )
2
3k
C
L
1
2
1
+
k
(C L)
qL +
L(q
2
1)(1 )
2
3k
L(1 )
2
3k
C
L
1
2
1
+
k
(C L)
3(C/L 1)
2
q
2
2
3)
C/L 2 +1/(2
3)
3(C/L1)
2
q
2
2
3)
C/L 2 +1/(2
3)
<
3(C/L 1)
2
q
2
2
3)
C/L 2 +1/(2
3)
<
3(C/L 1)
2
2
C
L
1
C
L
1
C
L
2 +
1
2
+1
3
2
C
L
1
. (A.10)
To have a valid lower bound for in [0, 1), C should be
larger than 2L; the larger C/L, the smaller the low bound
of . To have a valid upper bound, qk should be larger than
(C/L1); the smaller (qk C/L+1), the larger the upper
bound of .
For a given C/L, the lower bound of is uniquely deter-
mined by
1/(2
3)
C/L2+1/(2
3)
, qk should be small enough such
that the upper bound be larger than the lower bound, which
means q should be small. When q is not small enough, the
upper bound does not exist, which implies that the found
threshold will be larger than C qL so some object pixels
will be classied as background.
Let us give a specic example to illustrate the above re-
lationships. Suppose k =40, L=40, C/L=2.5. To have a
valid upper bound, we have q <0.125. When q =0.05, the
theoretical bounds of derived from (A.8) is [0.366, 0.796],
while the calculated valid bound is [0.35, 0.76]. The calcu-
lated and real bounds are very close. When q =0.10, the cal-
culated and theoretical bounds of are [0.366, 0.438] and
[0.35, 0.39], respectively. As qk becomes larger, the discrep-
ancy between the real and theoretical bounds will get larger
as we have used rst order Taylor series and limits to derive
the theoretical bounds assuming k approaches innity.
References
[1] J.M.S. Prewitt, M.L. Mendelsohn, The analysis of cell images, Ann.
N. Y. Acad. Sci. 128 (3) (1966) 10351053.
[2] J.S. Weszka, A. Rosenfeld, Histogram modication for threshold
selection, IEEE Trans. Syst. Man Cybern. 9 (1) (1979) 3852.
[3] J. Kittler, J. Illingworth, Minimum error thresholding, Pattern
Recognition 19 (1) (1986) 4147.
608 Y. Qiao et al. / Pattern Recognition 40 (2007) 596608
[4] S. Cho, R. Haralick, S. Yi, Improvement of Kittler and Illingworths
minimum error thresholding, Pattern Recognition 22 (5) (1989)
609617.
[5] J.S. Lee, M.C.K. Yang, Threshold selection using estimates from
truncated normal distribution, IEEE Trans. Syst. Man Cybern. 19
(2) (1989) 422429.
[6] T. Pun, Entropic thresholding: a new approach, CVGIP: Graphical
Models Image Process. 16 (1981) 210239.
[7] C.H. Li, C.K. Lee, Minimum cross entropy thresholding, Pattern
Recognition 26 (4) (1993) 617625.
[8] H.D. Cheng, J.R. Chen, J.G. Li, Threshold selection based on fuzzy
c-partition entropy approach, Pattern Recognition 31 (7) (1998)
857870.
[9] P.K. Saha, J.K. Udupa, Optimum image thresholding via class
uncertainty and region homogeneity, IEEE Trans. Pattern Anal.
Mach. Intell. 23 (7) (2001) 689706.
[10] N. Otsu, A thresholding selection method from gray-level histograms,
IEEE Trans. Syst. Man Cybern. 9 (1) (1979) 6266.
[11] J. Kittler, J. Illingworth, On threshold selection using clustering
criteria, IEEE Trans. Syst. Man Cybern. 15 (5) (1985) 652655.
[12] Q. Hu, Z. Hou, W.L. Nowinski, Supervised range-constrained
thresholding, IEEE Trans. Image Process. 15 (1) (2006) 228240.
[13] C.A. Glasbey, An analysis of histogram-based thresholding
algorithms, CVGIP: Graphical Models Image Process. 55 (6) (1993)
532537.
About the AuthorYU QIAO received his B. Eng. and M. Eng. degrees from Shanghai Jiao Tong University in 1991 and 1997, respectively, and Ph.D.
degree from National University of Singapore in 2004. He is currently a post-doc research fellow with the Biomedical Imaging Laboratory, the Agency
for Science, Technology and Research, Singapore. His research interests include medical image processing, computer vision and pattern recognition.
About the AuthorQINGMAO HU received his Ph.D. from Huazhong University of Science and Technology in 1990. From 1990 to 1996, he was a
lecturer and associate professor with the First Military Medical University China. From 1996 to 2000 he was a post-doc research fellow with University
of Bern Switzerland. From 2000, he is a research scientist and team leader with the Biomedical Imaging Laboratory, the Agency for Science, Technology
and Research, Singapore. His research interests include medical image processing, computer vision and pattern recognition.
About the AuthorGUOYU QIAN received his B.Eng. degree from Shanghai Jiao Tong University in 1986 and M. Eng. Degree from Nanyang
Technological University in 1995. He is currently a senior research associate with the Biomedical Imaging Laboratory, the Agency for Science, Technology
and Research, Singapore.
About the AuthorSUHUAI LUO received his B.E. and M.E. degrees from Nanjing University of Posts and Telecommunications China in 1982 and
1987, respectively, and Ph.D. degree from the University of Sydney, Australia in 1995. From 1995 to 2004, he was a senior research scientist with
the Commonwealth Scientic and Industrial Research Organization Australia and the Bioinformatics Institute Singapore. He is now a lecturer with the
University of Newcastle, Australia. His research interests include biomedical signal processing, image and video processing, and information visualization.
About the AuthorWIESLAW L. NOWINSKI D.Sc., Ph.D. is principal scientist and director of the Biomedical Imaging Lab, Agency for Science,
Technology and Research, Singapore. His research interests include neuroinformatics, brain atlases, computer-aided surgery, virtual reality, modeling,
segmentation, registration, and future directions in computer-aided surgery. He has developed 14 brain atlas products used world-wide in neurosurgery,
brain mapping, neuroradiology, and neuroeducation. He has led 33 patent applications and contributed above 330 articles. He received Magna cum
Laude awards from RSNA, ECR, and ASNR radiological societies.