+ All Categories
Home > Documents > Gradient based adaptive thresholding

Gradient based adaptive thresholding

Date post: 12-Dec-2016
Category:
Upload: hamzah
View: 253 times
Download: 15 times
Share this document with a friend
11
Gradient based adaptive thresholding Haniza Yazid a,, Hamzah Arof b a School of Mechatronic Engineering, University Malaysia Perlis, 02600 Ulu Pauh, Arau, Perlis, Malaysia b Electrical Engineering Department, Faculty of Engineering, University of Malaya, 50603 Kuala Lumpur, Malaysia article info Article history: Received 23 May 2012 Accepted 30 May 2013 Available online 12 June 2013 Keywords: Image segmentation Adaptive thresholding Gradient based thresholding Diabetic retinopathy Handwritten document images Medical image analysis Exudate detection Binarization abstract For images with poor and non-uniform illumination, adaptive thresholding is required to separate the objects of interest from the background. In this paper a new approach to create an adaptive threshold sur- face is proposed to segment an image. The technique is inspired by the Yanowitz’s method and is improved upon by the introduction of a simpler and more accurate threshold surface. The method is tested on several images of different patterns with varying illumination and the results are compared to the ones produced by a number of adaptive thresholding algorithms. In order to demonstrate the effec- tiveness, the proposed method had been implemented in medical and document images. The proposed method compares favorably against those using watershed and morphology in medical image and favor- ably against variable threshold and adaptive Otsu’s N-thresholding for document image. Ó 2013 Elsevier Inc. All rights reserved. 1. Introduction Thresholding is a simple yet powerful technique to separate the object of interest from the background. Thresholding has found various applications such as in non-destructive testing (NDT) [1– 3], document image analysis [3–7], medical image analysis [8–9], quality inspection of materials and various image segmentation applications. In an image, if the objects are clearly lighter (or dar- ker) than the background it is natural to separate them by setting a threshold. Once the threshold value is chosen, a label is assigned to all pixels in the image that are higher than the threshold and an- other label is assigned to the remaining pixels. The result is a bin- ary image where one label represents the objects while the other represents the background. However, under poor illumination or non-uniform background, achieving a proper separation of objects and background using a fixed threshold is rather unlikely. Thus an adaptive thresholding method is required such that the threshold will vary throughout the image to suit the varying lighting condi- tion and changing background. This can be achieved by formulat- ing a threshold surface so that each pixel has its own threshold value. In the work of Chow and Kaneko [10], the image is divided into non-overlapping squares and a sub-histogram of grey levels in each square is calculated. Then the sub-histograms which are determined to be bimodal are used to obtain local thresholds for the squares. These local thresholds can be interpolated to produce a threshold surface for the entire image. Niblack [11] proposed a threshold based on the mean and standard deviation of a local neighborhood while Eikvil et al. [12] utilized Otsu method to seg- ment pixels in the local neighborhood into two classes. If the means of the two classes are further apart than a predefined limit, they are segmented otherwise they are combined. Yanowitz and Bruckstein [13] constructed the threshold surface by keeping the pixel values of the original image at high gradient pixels and smoothing the surface by forcing the low gradient pixels to satisfy the Laplace equation using successive over-relaxation method. On the other hand, Chan et al. [14] translated two (2) of the steps in the Yanowitz’s algorithm using variational theory. However, no performance comparison was made between the proposed method and the original Yanowitz’s method. Blayvas et al. [15] introduced a new thresholding method using multiresolution representation. The surface was constructed as a sum of function that is based on scaling and shifting of the original function. Meanwhile, Chen et al. [16] proposed another approach for thresholding which is similar to region growing based on edge and intensity information. Initially, the seeds are placed near the image edges and then an edge connection method is performed to close the image edges. Afterward, the closed image edges are parti- tioned using a high threshold which is obtained by a primary bina- rization result by filling the partitioned high threshold binary image with the seeds. Finally, the second binarization result is obtained by remedying the primary result with the low threshold binary image. Chen et al. [16] made a performance comparison between the 1047-3203/$ - see front matter Ó 2013 Elsevier Inc. All rights reserved. http://dx.doi.org/10.1016/j.jvcir.2013.06.001 Corresponding author. E-mail address: [email protected] (H. Yazid). J. Vis. Commun. Image R. 24 (2013) 926–936 Contents lists available at SciVerse ScienceDirect J. Vis. Commun. Image R. journal homepage: www.elsevier.com/locate/jvci
Transcript
Page 1: Gradient based adaptive thresholding

J. Vis. Commun. Image R. 24 (2013) 926–936

Contents lists available at SciVerse ScienceDirect

J. Vis. Commun. Image R.

journal homepage: www.elsevier .com/ locate / jvc i

Gradient based adaptive thresholding

1047-3203/$ - see front matter � 2013 Elsevier Inc. All rights reserved.http://dx.doi.org/10.1016/j.jvcir.2013.06.001

⇑ Corresponding author.E-mail address: [email protected] (H. Yazid).

Haniza Yazid a,⇑, Hamzah Arof b

a School of Mechatronic Engineering, University Malaysia Perlis, 02600 Ulu Pauh, Arau, Perlis, Malaysiab Electrical Engineering Department, Faculty of Engineering, University of Malaya, 50603 Kuala Lumpur, Malaysia

a r t i c l e i n f o

Article history:Received 23 May 2012Accepted 30 May 2013Available online 12 June 2013

Keywords:Image segmentationAdaptive thresholdingGradient based thresholdingDiabetic retinopathyHandwritten document imagesMedical image analysisExudate detectionBinarization

a b s t r a c t

For images with poor and non-uniform illumination, adaptive thresholding is required to separate theobjects of interest from the background. In this paper a new approach to create an adaptive threshold sur-face is proposed to segment an image. The technique is inspired by the Yanowitz’s method and isimproved upon by the introduction of a simpler and more accurate threshold surface. The method istested on several images of different patterns with varying illumination and the results are comparedto the ones produced by a number of adaptive thresholding algorithms. In order to demonstrate the effec-tiveness, the proposed method had been implemented in medical and document images. The proposedmethod compares favorably against those using watershed and morphology in medical image and favor-ably against variable threshold and adaptive Otsu’s N-thresholding for document image.

� 2013 Elsevier Inc. All rights reserved.

1. Introduction

Thresholding is a simple yet powerful technique to separate theobject of interest from the background. Thresholding has foundvarious applications such as in non-destructive testing (NDT) [1–3], document image analysis [3–7], medical image analysis [8–9],quality inspection of materials and various image segmentationapplications. In an image, if the objects are clearly lighter (or dar-ker) than the background it is natural to separate them by setting athreshold. Once the threshold value is chosen, a label is assigned toall pixels in the image that are higher than the threshold and an-other label is assigned to the remaining pixels. The result is a bin-ary image where one label represents the objects while the otherrepresents the background. However, under poor illumination ornon-uniform background, achieving a proper separation of objectsand background using a fixed threshold is rather unlikely. Thus anadaptive thresholding method is required such that the thresholdwill vary throughout the image to suit the varying lighting condi-tion and changing background. This can be achieved by formulat-ing a threshold surface so that each pixel has its own thresholdvalue.

In the work of Chow and Kaneko [10], the image is divided intonon-overlapping squares and a sub-histogram of grey levels ineach square is calculated. Then the sub-histograms which aredetermined to be bimodal are used to obtain local thresholds for

the squares. These local thresholds can be interpolated to producea threshold surface for the entire image. Niblack [11] proposed athreshold based on the mean and standard deviation of a localneighborhood while Eikvil et al. [12] utilized Otsu method to seg-ment pixels in the local neighborhood into two classes. If themeans of the two classes are further apart than a predefined limit,they are segmented otherwise they are combined. Yanowitz andBruckstein [13] constructed the threshold surface by keeping thepixel values of the original image at high gradient pixels andsmoothing the surface by forcing the low gradient pixels to satisfythe Laplace equation using successive over-relaxation method. Onthe other hand, Chan et al. [14] translated two (2) of the steps inthe Yanowitz’s algorithm using variational theory. However, noperformance comparison was made between the proposed methodand the original Yanowitz’s method.

Blayvas et al. [15] introduced a new thresholding method usingmultiresolution representation. The surface was constructed as asum of function that is based on scaling and shifting of the originalfunction. Meanwhile, Chen et al. [16] proposed another approachfor thresholding which is similar to region growing based on edgeand intensity information. Initially, the seeds are placed near theimage edges and then an edge connection method is performed toclose the image edges. Afterward, the closed image edges are parti-tioned using a high threshold which is obtained by a primary bina-rization result by filling the partitioned high threshold binary imagewith the seeds. Finally, the second binarization result is obtained byremedying the primary result with the low threshold binary image.Chen et al. [16] made a performance comparison between the

Page 2: Gradient based adaptive thresholding

H. Yazid, H. Arof / J. Vis. Commun. Image R. 24 (2013) 926–936 927

proposed method with those of the Yanowitz’s and Blayvas’smethods. Although the proposed method showed superiorresults it is dependent on several thresholds which are selectedmanually.

In this paper, a novel approach inspired by the work of Yano-witz and Bruckstein [13] is proposed to construct a thresholdingsurface. First, the input image undergoes edge detection to identifythe boundary points of objects in the image and Otsu thresholdingis used to separate the weak boundary points from the strong ones.Next, the thresholding surface is constructed as explained in Sec-tion 3. Then the thresholding surface is superimposed on the origi-nal image and its position is automatically adjusted to segment theobjects from the background. Finally, the performance of the pro-posed method is compared to those of several methods on thesame set of test images. The rest of this paper is organized as fol-lows. Section 2 provides a short review of a few thresholding meth-ods that are selected for comparison purpose namely the onesdeveloped by Niblack [11], Yanowitz and Bruckstein [13], Chanet al. [14], Blayvas et al. [15] and Chen et al. [16]. This is followedby Section 3 that describes the formulation of the proposed adap-tive thresholding method. Section 4 describes the implementationof the proposed algorithm on a set of simulated images. In addi-tion, Section 4 also presents the performance comparison of thenew approach against those of the selected methods in segmentinga set of test images meanwhile Section 5 presents the applicationof the proposed method in several areas. Finally, a conclusion isdrawn in Section 6.

2. Review of several selected methods

2.1. Niblack’s method

In Niblack’s method, the image is divided into non-overlappingsquares where each square has its own local threshold value whichdepends on the mean and standard deviation of pixel intensities inthe square. The threshold is calculated based on the following.

Tði; jÞ ¼ mði; jÞ þ k � sði; jÞ ð1Þ

where m(i,j) and s(i,j) are the mean and standard deviation values,respectively. The window size recommended by Trier and Tact[17] is 15 by 15 and k = �0.2. The window size needs to be large en-ough to reveal the local illumination level and include the objectand background. A major drawback of this method is its depen-dence on scale. The method will not work properly if the object sizeis varied and furthermore if the image suffers from non-uniformillumination its effectiveness will decrease. Since a threshold isevaluated and assigned for each square, there will always be somepixels classified as the background and the others as object withineach. As a result, there will be misclassification for squares contain-ing only the object or the background if the square is not large en-ough to contain both. Additionally, it can be argued that thesuggested value of k is obtained heuristically by assuming thatthe background is brighter than the object.

2.2. Yanowitz and Bruckstein’s (YB) method

The YB method of adaptive thresholding is implemented in 7steps. Essentially, the input image is first smoothened using anaveraging filter followed by the derivation of the gradient magni-tude of the smoothen image. Then, thinning and thresholding areapplied to the gradient magnitude to locate the object boundarypoints called the support points. A threshold surface T(x,y) is thenconstructed where its values at the support points are equal tothose of the smoothen image I(x,y). The values of other points onthe threshold surface are obtained from solving the Laplace equa-

tion via successive overrelaxation. Afterward, the image is seg-mented by the threshold surface according to the followingequation.

Rði; jÞ ¼1; if Iðx; yÞ > Tðx; yÞ0; if Iðx; yÞ 6 Tðx; yÞ

�ð2Þ

where R(i,j) is the segmented image. Finally, ghost objects andstains are removed by a validation process which requires the aver-age gradient of edge pixels around every object to be computed andcompared to a selected threshold. It is assumed that the averagegradients of edge pixels around real objects are high while thoseof ghost objects are low. Other details of YB method can be foundin [13]. As opposed to Niblack’s method, this approach is scale inde-pendent. However, it is high in computational complexity [15].

2.3. Chan’s method

Chan et al. [14] proposed an adaptive thresholding methodusing variational theory. The method can be regarded as a varia-tional translation of YB algorithm. However, the threshold surfaceis obtained by deforming the original image using Poisson equationrather than the Laplace equation. The solution of the Poisson equa-tion is achieved through the use of the SOR method and it can bewritten as

Tnþ1i;j ¼ Tn

i;j þx=4ei;j ð3Þ

where ei,j = Ti,j � 1 + Ti,j + 1 + Ti � 1,j + Ti + 1,j � 4 Ti,j – a (dF/dT) and x isthe overrelaxation parameter. The value of x was restricted be-tween 1 and 2 while the value of alpha was fixed at 18. The methodwas tested on a number of test images and the results were satisfac-tory. However, no performance comparison was made to othermethods including that of the YB.

2.4. Blayvas’s method

Blayvas et al. [15] proposed a method called the multiresolutionapproximation (MA) method which constructs a surface as a sumof functions formed by scaling and shifting of a single source func-tion. The threshold surface is given by the following equation;

Tði; jÞ ¼Xlog2ðNÞ

l¼0

X2l�1

j;k¼0

aljkGljkði; jÞ ð4Þ

where l = 0. . .log2 (N) is a scale factor and j,k 2 {0,. . .2l � 1} are thespatial shifts factor. Details on how to obtain the scaling and shiftfactor are available in [15]. The performance of the proposed meth-od in binarizing several test images was compared to those of theYB and a few other methods, where improvement was observed.

2.5. Chen’s method

In the work of Chen et al. [16], a double thresholding method isintroduced which combines the edge and intensity information. Insummary, the process starts with the input image undergoing theCanny edge detection and then pixels which have low intensityand are close to the boundaries and not isolated are selected asseeds. Starting from the seeds, region filling is performed on thepartitioned high-thresholded binary image. Then for each region,an evaluation is made whether the filled region is an object bymeasuring the proportion of the seeds to the boundary pixels ofthe region. After the final segmentation result is obtained, a postprocessing step is taken where small regions which are consideredas non-objects are removed as noise. Details of the steps taken inthe method can be found in [16] and it should be pointed out thatin order to implement this method successfully the values of a

Page 3: Gradient based adaptive thresholding

928 H. Yazid, H. Arof / J. Vis. Commun. Image R. 24 (2013) 926–936

number of thresholds used have to be chosen carefully. The perfor-mance of the method is compared to those of MA and YB methodswhen tested on a number of test images. The proposed methodoutperforms the other two but the YB and MA methods use no postprocessing step in obtaining their results.

Fig. 2. Prewitt operator.

3. Gradient based adaptive thresholding

The flow of the proposed thresholding process is illustrated inFig. 1. First, edge detection is performed on the image to identifythe boundaries of the objects [18]. One of the basic edge detectionoperations involves convolving the input image with matricescalled operators or detectors. The convolution provides a measureof gradient or slope within the size of the detectors. The standardPrewitt operators are selected for this task due to their simplicityand ease of implementation. At every pixel, the four operatorsare convolved with the image to capture the directions of the edgein horizontal, vertical, diagonal and anti-diagonal orientations asshown in Fig. 2. The absolute values of the convolutions in the fourdirections are compared and the highest value among them is keptto represent the edge information at the pixel. The collection ofthese gradient values form an image called the edge image denotedas E(i,j).

It is expected that the gradients (or edge values) of pixels at theboundary of objects to be higher than the gradients of pixels thatmake up the background and the interior of the objects. Therefore,if we want to distinguish the pixels at the object boundaries fromthe others we need to find a suitable threshold that would separatethe weak edges from the strong edges in E(i,j). The threshold wouldsplit values in E(i,j) into two groups, the weak edge and the strongedge groups. All pixels in E(i,j) belonging to the weak edge groupare then assigned to zero and the remaining pixels with strongedges are considered as the pixels on the boundaries of the objectsin the image. To avoid manually selecting a threshold value whichmight be affected by uneven illumination and contrast, we employOtsu [19] method which selects a threshold value automatically.Further details on this method can be found in [19]. However, if

Input image

Otsu thresholding

Edge detection

Thresholding surface Construction

Binarization

Output image

Fig. 1. The flow of the proposed thresholding process.

the edges of the object are too weak, then the gradient thresholdwill be less effective.

3.1. Thresholding surface construction

Suppose we draw a line on an image traversing the backgroundand two objects where the objects are assumed to have higherintensity than the background. The cross section of the image alongthis hypothetical line is shown in Fig. 3(a). The sections that repre-sent the background are labeled as 1, 5, and 9 and those that formthe interior of the objects are labeled as 3 and 7. Meanwhile sec-tions 2, 4, 6 and 8 are the boundaries that link the objects andthe background. Fig. 3(b) shows the cross section of the threshold-ing surface we intend to construct along the same hypotheticalline. When the two surfaces overlap in the segmentation processtheir cross sections intersect and the result is as depicted inFig. 3(c) where the objects are identified as the portions of the ori-ginal image where the intensity is higher than that of the thres-holding surface as indicated by the dotted line. Conversely, if theobjects have lower intensity than the background, we can identifythe objects simply as the portions of the original image where theintensity is lower than that of the thresholding surface.

If we regard the cross section of the original image in Fig. 3(a) asbeing composed of 9 separate portions, we can construct the crosssection of the thresholding surface of Fig. 3(b) by implementing thefollowing steps. First we invert the gradient of the four boundarysections to produce their inverted counterparts as shown inFig. 4(a). We can think of the inverted boundary parts as the out-puts of reflecting sections 2, 4, 6 and 8 about a vertical axis. Then,all of the non-boundary sections from Fig. 3(a) are recombinedwith the inverted boundary parts of Fig. 4(a) to produce the crosssection of the thresholding surface by connecting the endpoint ofone section to the start point of the next section consecutively as

(a)

(b)

(c)

8

9

76432

1

5

Fig. 3. (a) Cross section of a line on the original image, (b) cross section of the sameline on the thresholding surface and (c) the overlapping of the two surfaces alongthe line in the binarization/thresholding.

Page 4: Gradient based adaptive thresholding

(a)

4’ 8 8’6 6’2 2’ 4

(b) +

+

+

+ +

+

+

+

Fig. 4. (a) The four boundary section and their inverted counter parts and (b)combining the non-boundary sections with the inverted boundary section to formthe thresholding surface of Fig. 3(b).

(a) (b)

(c) (d)

(e) (f)

H. Yazid, H. Arof / J. Vis. Commun. Image R. 24 (2013) 926–936 929

illustrated in Fig. 4(b). Inverting boundary pixels of objects in animage to produce a thresholding surface is based on the same ideaand it is elaborated in the following paragraphs.

The thresholding surface T(i,j) is derived from the intensitiesand gradients of the original image I(i,j) and those of the negativeimage N(i,j) where N(i,j) is obtained by subtracting I(i,j) from themaximum intensity level L (L = 255). The interpolation of pixel val-ues needed for T(i,j) is performed in 8 passes and the difference be-tween one pass to another is in the path taken to process the pixelsas shown in Fig. 5. Firstly, for each pass a primary surface Pm(i,j)(m = 1, 2, 3. . .8) is initialized to the original image I(i,j). Then theintensity of pixels on the primary surface Pm(i,j) is reconstructeddepending on whether the pixels are boundary pixels or non-boundary pixels. Boundary pixels are those with strong edge(E(i,j) > 0) and their gradients are made equal to those of the neg-ative image N(i,j) thus inverting the original pixels’ gradients andemulating the process in Fig. 5. Non-border pixels are those withweak edge (E(i,j) = 0) and their gradients are set equal to those ofthe original image I(i,j). The thresholding surface T(i,j) is obtainedby averaging the eight primary surfaces.

For each pixel(i,j), four gradients are calculated in horizontal,vertical, diagonal and anti-diagonal directions between the pixe-l(i,j) and its four nearest neighbors that have been traversed. Thereconstruction of the primary surface P1(i,j) for the first or LRTB pass(Left Right Top Bottom) is summarized as follows. The formation ofthe other seven primary surfaces can be generalized from P1(i,j).

1. Obtain the negative image N(i,j) by negating I(I,j) using Eq. (5).The gradients of each pixel in the negative image N(i,j) shouldbe the opposite of those in the original image I(i,j).

Nði; jÞ ¼ 255� Iði; jÞ ð5Þ

2. Initialize the primary surface P1(i,j) to the original image I(i,j)

P1ði; jÞ ¼ Iði; jÞ

3. For every pixel(i,j), adjust the intensity of P1(i,j) according to thefollowing cases(i) Case 1: If the pixel(i,j) is a border pixel (E(i,j) > 0) we equate

the gradients of P1(i,j) to those of the negative image N(i,j).

(g) (h)

Fig. 5. Processing directions (a) first pass in left–right-top–bottom(LRTB) direction,(b) second pass in top–bottom-left–right (TBLR) direction, (c) third pass in right–left-bottom–top (RLBT) direction and (d) fourth pass in bottom–top-right–left(BTRL) direction, (e) fifth pass in right–left-top–bottom (RLTB) direction, (f) six passin top–bottom-right–left (TBRL) direction, (g) seven pass in left–right-bottom–top(LRBT) direction, (h) eight pass in bottom–top-left–right (BTLR) direction.

First, we need to find the gradients of the pixel(i,j) in fourdirections relative to four of its nearest neighbors thathave been traversed. In LRTB pass, the neighboring pixelsare (N(i,j � 1), N(i � 1,j), N(i � 1,j � 1), N(i � 1,j + 1)) andthe gradients in horizontal, vertical, diagonal and anti-diagonal directions are

D1 ¼ Nði; jÞ � Nði; j� 1Þ D2 ¼ Nði; jÞ � Nði� 1; jÞD3 ¼ Nði; jÞ � Nði� 1; j� 1Þ D4 ¼ Nði; jÞ � Nði� 1; jþ 1Þ

ð6Þ

Then use each gradient to estimate the value of P1(i,j) using its cor-responding neighbors as follows

e1ði; jÞ ¼ P1ði; j� 1Þ þ D1 e2ði; jÞ ¼ P1ði� 1; jÞ þ D2

e3ði; jÞ ¼ P1ði� 1; j� 1Þ þ D3 e4ði; jÞ ¼ P1ði� 1; jþ 1Þ þ D4

Page 5: Gradient based adaptive thresholding

930 H. Yazid, H. Arof / J. Vis. Commun. Image R. 24 (2013) 926–936

The four estimates are then averaged to give us the final value ofP1(i,j) for the pixel

P1ði; jÞ ¼ ðe1ði; jÞ þ e2ði; jÞ þ e3ði; jÞ þ e4ði; jÞÞ=4:0 ð7Þ

(ii) Case 2: If the pixel(i,j) is a non-border pixel (E(i,j) = 0) thegradients of P1(i,j) are set to be the equal to those of the ori-ginal image I(i,j).

In this case, the neighboring pixels are I(i,j � 1), I(i � 1,j),I(i � 1,j � 1), I(i � 1,j + 1) and the gradients in horizontal,vertical, diagonal and anti-diagonal directions are

D1 ¼ Iði; jÞ � Iði; j� 1Þ D2 ¼ Iði; jÞ � Iði� 1; jÞ

D3 ¼ Iði; jÞ � Iði� 1; j� 1Þ D4 ¼ Iði; jÞ � Iði� 1; jþ 1Þð8Þ

The estimates for P1(i,j) using its corresponding neighbors are asfollows

e1ði; jÞ ¼ P1ði; j� 1Þ þ D1 e2ði; jÞ ¼ P1ði� 1; jÞ þ D2

e3ði; jÞ ¼ P1ði� 1; j� 1Þ þ D3 e4ði; jÞ ¼ P1ði� 1; jþ 1Þ þ D4

They are then averaged to give us the final value of P1(i,j) for thepass

(a)

P1ði; jÞ ¼ ðe1ði; jÞ þ e2ði; jÞ þ e3ði; jÞ þ e4ði; jÞÞ=4:0 ð9Þ

For the other passes, steps (1) and (2) are the same as those inthe first pass and for step (3) the neighbors used to evaluate thegradients in horizontal, vertical, diagonal and anti-diagonal direc-tions are given below. Other pixels on the primary surface usedin calculating the four estimates are in the same relative locationsas those selected neighbors.

(a) For TBLR pass, N(i,j � 1), N(i � 1,j), N(i � 1,j � 1),N(i + 1,j � 1) and I(i,j � 1), I(i � 1,j), I(i � 1,j � 1),I(i + 1,j � 1)) are the respective neighbors used for borderand non-border pixels in reconstructing P2(i,j).

(b) For RLBT pass, N(i,j + 1), N(i + 1,j), N(i + 1,j � 1), N(i + 1,j + 1)and I(i,j + 1), I(i + 1,j), I(i + 1,j � 1), I(i + 1,j + 1)) are therespective neighbors used for border and non-border pixelsin reconstructing P3(i,j).

(c) For BTRL pass, N(i,j + 1), N(i + 1,j), N(i � 1,j + 1), N(i + 1,j + 1)and I(i,j + 1), I(i + 1,j), I(i � 1,j + 1), I(i + 1,j + 1) are the respec-tive neighbors used for border and non-border pixels inreconstructing P4(i,j).

(d) For RLTB pass, N(i,j + 1), N(i � 1,j), N(i � 1,j + 1), N(i � 1,j � 1)and I(i,j + 1), I(i � 1,j), I(i � 1,j + 1), I(i � 1,j � 1)) are therespective neighbors used for border and non-border pixelsin reconstructing P5(i,j).

(e) For TBRL pass, N(i,j + 1), N(i � 1,j), N(i � 1,j + 1), N(i + 1,j + 1)and I(i,j + 1), I(i � 1,j), I(i � 1,j + 1), I(i + 1,j + 1)) are therespective neighbors used for border and non-border pixelsin reconstructing P6(i,j).

(f) For LRBT pass, N(i,j � 1), N(i + 1,j), N(i + 1,j + 1), N(i + 1,j � 1)and I(i,j � 1), I(i + 1,j), I(i + 1,j + 1), I(i + 1,j � 1) are therespective neighbors used for border and non-border pixelsin reconstructing P7(i,j).

(g) For BTLR pass, N(i,j � 1), N(i + 1,j), N(i � 1,j � 1), N(i + 1,j � 1)and I(i,j � 1), I(i + 1,j), I(i � 1,j � 1), I(i + 1,j � 1) are therespective neighbors used for border and non-border pixelsin reconstructing P8(i,j).

4. The final thresholding surface T(i,j) is the average of the eightprimary surfaces

(b)

Fig. 6. (a) A cross section of I(i,j) and (b) the cross section of T(i,j) along the same

Tði; jÞ ¼

P8m¼1Pmði; jÞ

8ð10Þ

3.2. Binarization

In surface thresholding, the main task is to adjust the position ofthe inverse surface so that only the areas containing defects willoverlap with the original image I(i,j). Fig. 6(a) shows the intensitiesof pixels along a line drawn on I(i,j) while Fig. 6(b) shows the samepixels along a similar line drawn on T(i,j). The positions of the edgepixels are marked with ‘‘x’’. The idea is to adjust the position of thethresholding surface T(i,j) and to intersect the two surfaces as inFig. 7 such that the edge pixels coincide. This is done by adding/subtracting a constant to the intensities of T(i,j) in order to movethe thresholding surface up or down. Since the edge pixels havedifferent intensites, the strategy is to minimize the absolute differ-ence between the edge pixels on the input image I(i,j) and the ad-justed thresholding surface T(i,j) + k, where k is the added constant.The value of k that achieves this minimum sum of absolute differ-ence is denoted as ko.

Once the right position for the thresholding surface (or constantko) is found, we can extract the objects as the area where I(i,j) isgreater than T(i,j) + ko. In Fig. 7 the objects are designated by thearea where the bold line is higher than the thin line. The wholeprocess of the surface thresholding can be summarized as follows;

Step 1: Construct the inverse image T(i,j) as directed in previoussectionStep 2: Find the value of a constant k that varies from �255 to255 to minimize the sum of the absolute difference of|I(i,j) � T(i,j) + k| for the edge pixels.

line.

k0 ¼argmink

Xborderpixelsði;jÞ

jIði; jÞ � Tði; jÞ þ kj; k 2 f�255;�254; . . . 0 . . . ;254;255g

24

35

ð11Þ

Step 3: Segment I(i,j) into object and background.

resultði; jÞ ¼0; ðobjectÞ if Iði; jÞ > Tði; jÞ þ k0

255; ðbackgroundÞ if Iði; jÞ < Tði; jÞ þ k0

ð12Þ

4. Experimental results

In order to demonstrate the effectiveness of the proposed meth-od, two simulated images are created with uneven background.Fig. 8(a) shows the simulated images containing several objectsand Fig. 8(b) shows the thresholding surface obtained by the pro-posed algorithm. The resulting images obtained after binarizationusing the thresholding surface are given by Fig. 8(c) whileFig. 8(d) shows the results of applying Otsu thresholding on thesame images.

Page 6: Gradient based adaptive thresholding

Fig. 7. Binarization of image surface (bold line) and thresholding surface (thin line).

(a)

(b)

(c)

(d)

Fig. 8. (a) Objects added to the uneven background intensity, 8(b) the thresholdingsurface based on the proposed method, 8(c) the detected objects after surfacethresholding, 8(d) results of Otsu thresholding.

H. Yazid, H. Arof / J. Vis. Commun. Image R. 24 (2013) 926–936 931

Fig. 9(a) illustrated the 3D background of the images in Fig. 8(a)and 9(b) shows the 3D surfaces of the two simulated test images.As shown in Fig. 9(c), the histograms of image are not bimodal.Clearly, it is difficult to find a threshold that can separate the ob-jects from the background. Therefore, the use of an adaptive thres-holding is necessary to solve the problem. Using surfacethresholding, each pixel in the image will have its own thresholdvalue to segment the object from the background. The thresholdsurface of our method is illustrated in Fig. 9(d). Then, adjustingthreshold surface up and down by adding or subtracting a constantto it, is necessary to minimize the absolute difference between theedge pixels on the input image I(i,j) and the adjusted inverse sur-face T(i,j) to obtain the right segmentation.

Six methods had been experimented with namely the the Ni-black’s method, YB method, Chan’s method, MA method, Chen’smethod and the proposed gradient based threshold method. Theprograms were written in C programming language and ran onPentium Core 2 Duo 1.83 Hz processor. Similar test images fromBlayvas et al. [15] were adopted and experimented on. Fig. 10shows the proposed gradient threshold for several test imagesmeanwhile Fig. 11 shows the segmentation results of the six adap-tive thresholding approaches. The misclassification error (ME) usedby Segzin and Sankur [3] was adopted to measure the performanceof the methods and the results are listed in Table 1. The ME mea-surement is given as follows;

ME ¼ 1� jBo \ BT j þ jFo \ FT jjBoj þ jFoj

Bo indicates the background of the original image and Fo indi-cates the foreground of the original image. BT and FT denote thebackground and foreground of the test image. The ME measuresthe percentage of the background which is misclassified as theforeground and conversely, the foreground which is being misclas-sified as the background.

For squares and star images, our method performed better com-pared to the other methods. However, for the text image, the accu-racy of our method is slightly lower than the Niblack’s method.Lastly, the result of the segmentation of the rectangle image gener-ated by our method is comparable to those of Chen’s and MA meth-ods. The rectangle image was created by addition of 1% salt andpepper noise [15]. Based on the result for rectangle, it shows thatthe proposed method is effective to segment the noises image. Itshould be mentioned that the proposed method does not use a pre-processing filter to remove noise from the test image or a post pro-cessing step to improve its results.

5. Applications

5.1. Medical images

The proposed method had been experimented in medicalimages to segment the exudates for diabetic retinopathy detection.Patients with diabetes need annual screening to circumvent visionloss which may lead to blindness. Diabetic Retinopathy (DR) is adiabetic complication that causes changes in the retina. Non-Prolif-erative Diabetic Retinopathy (NPDR) is a common, usually mildform of retinopathy that generally does not interfere with vision.However, the diabetic retinopathy can progress from non-prolifer-ative to proliferative retinopathy (PDR) if left untreated. In order toprevent patients from partial vision loss or even blindness, earlydetection of the disease is crucial. However, screening each patientmanually is time consuming and it relies on the availability ofexperts.

Medical imaging can alleviate the burden on ophthalmologistsby assisting them in detecting lesions that appear in the retinal

Page 7: Gradient based adaptive thresholding

Fig. 9. (a) The 3D plot of the simulated 8(a), 9(b) the 3D plot of 8(b), 9(c) the histogram of 8(a), 9(d) the inverse surface.

Fig. 10. Gradient based threshold surface.

932 H. Yazid, H. Arof / J. Vis. Commun. Image R. 24 (2013) 926–936

Page 8: Gradient based adaptive thresholding

Fig. 11. Segmentation results of the six tested approaches where the first row contains the original image, the second, third, fourth, fifth and sixth rows present the result ofthe Niblack’s,YB, Chan’s, MA method, Chen’s and the proposed methods, respectively.

H. Yazid, H. Arof / J. Vis. Commun. Image R. 24 (2013) 926–936 933

images. With the advent of medical image analysis, many research-ers advocate the use of medical imaging in the detection process.The automated screening tool can highlight any forms of lesionscaused by diabetic retinopathy instantly and thus reduce the pro-cessing time considerably. The images deemed suspect to showingsigns of severe diabetic retinopathy will be further examined bythe ophthalmologist. NPDR is an early stage of DR. There are sev-

eral lesions that may be present in NPDR namely microaneurysms,hemorrhages, exudates and cotton wool spots. The main objectiveof our work is to segment the exudates.

A custom database that is provided by National University Hos-pital of Malaysia and Standard Diabetic Retinopathy Database –Calibration Level 1 (DIARETDB1) are used to assess the proposedapproach. The performance of the proposed method is compared

Page 9: Gradient based adaptive thresholding

Table 1Comparison performance of the Yanowitz, Blayvas, Niblack, Chan, Chen and theproposed method.

Test image ‘Squares’ ‘Text’ ‘Rectangles’ ‘Stars’Error Error Error Error

Yanowitz 0.006300 0.212000 0.191000 0.312000Blayvas 0.007200 0.312000 0.078000 0.096000Niblack 0.128000 0.000000 0.152000 0.174500Chan 0.057322 0.296856 0.173400 0.172878Chen 0.003600 0.022800 0.063900 0.000300Inverse 0.000211 0.000200 0.079156 0.000100

Table 3Performance of the segmentation process for DIABETDB1 database.

Method TPF (%) TNF (%) PV (%)

Proposed method 98.2 97.4 61.3Reza [20] 51.0 96.5 40.0Welfer [21] 70.48 98.84 21.32

Table 4Performance of the segmentation process for NUHM database.

Method TPF (%) TNF (%) PV (%)

Proposed method 90.4 99.2 80.1Reza [20] 37.8 98.8 30.2Welfer [21] 65.4 96.0 12.0

934 H. Yazid, H. Arof / J. Vis. Commun. Image R. 24 (2013) 926–936

with those of a watershed based method by [20] and a morpholog-ical reconstruction approach by [21]. The results are illustrated inTable 2.

The results for segmentation of images of DIABETDB1 and theNUHM databases are shown in Tables 3 and 4, respectively.

In summary, the proposed method achieves higher percentagesin sensitivity (TPF), specificity (TNF) and predictivity (PV) than thewatershed based method [20] and the morphological reconstruc-tion approach [21].

The watershed segmentation approach [20] obtains lowerdetection rate since the proposed method utilizes an average filter-ing which tends to blur the image and make the detection of thesmall exudates difficult. Additionally, this method uses a fixedthreshold which may not be appropriate in segmenting exudatesfrom different datasets. Meanwhile, the morphological reconstruc-tion method shows consistent results for both datasets. However,the accuracy of this method suffers if the images contain non-uni-form illumination.

Table 2Comparison between human grader, proposed method, watershed segmentation [20] and

Original image Expert Grader Inverse surface

thresholding

5.2. Handwritten document images

The proposed method had been experimented to segment thehandwritten for document image analysis. The images are ob-tained from Handwritten Document Image Binarization Contest(H-DIBCO 2012) [22]. 14 images are experimented using the pro-posed method and the results are compared with several methodsin [23] in term of F-Measure (FM) and Peak Signal to Noise Ratio(PSNR). Table 5 shows the resulting images for two methods in[23] which obtained the highest score and two methods whichobtained the lowest score. Based on Table 5, it is shown that, the

morphological reconstruction [21].

Watershed

segmentation [24]

Morphological

reconstruction [16]

Page 10: Gradient based adaptive thresholding

Table 5Evaluation result for several methods submitted to H-DIBCO 2012.

Method FM (%) PSNR Sample output images

6 89.74 21.80

11 92.85 20.57

Proposed method 82.70 16.30

17 81.00 15.36

16 75.23 15.94

H. Yazid, H. Arof / J. Vis. Commun. Image R. 24 (2013) 926–936 935

proposed method produces a lower result when compared to themethod by [24] and [25]. However, the proposed method producesa better result in term of FM and PSNR compared to the method by

[26] and [27]. The proposed method was applied directly to thedocument images without utilizing any preprocessing filter to re-move the noise or a post processing to improve its results.

Page 11: Gradient based adaptive thresholding

936 H. Yazid, H. Arof / J. Vis. Commun. Image R. 24 (2013) 926–936

6. Conclusion

In this work, a new adaptive thresholding method is proposed.The method utilizes the intensities and gradients of the originalimage and its negative counterpart to construct the thresholdingsurface. The performance of new approach is compared to thoseof five other thresholding methods. The segmentation results indi-cate a relatively comparable or better performance than thoseshown by other methods although no preprocessing or post pro-cessing steps are taken to remove unwanted noise or to clean upghost artifacts. The novelty of our approach lies in the use of a gra-dient based thresholding surface that is effective and easy to con-struct. In medical image analysis, the proposed method obtained98.2% in sensitivity, 97.4% in specificity and 61.3% in predictivityfor DIARETDB1 database and 90.4% in sensitivity, 99.2% in specific-ity and 80.1% in predictivity for the NUHM database. The proposedmethod compares favorably against those using watershed andmorphological reconstruction. Meanwhile for document image,the proposed method obtained 82.7 in F-measure and 16.3 in peaksignal to noise ratio. The proposed method compares favorablyagainst variable threshold and adaptive Otsu’s N-thresholding.

Acknowledgment

This work was supported by Ministry of Higher EducationMalaysia under Research Acculturation Grant Scheme (9018-00010).

References

[1] Y. Wang, Sun Y. LvPeng, H. Wang, Detection of line weld defects based onmultiple threshholds and support vector machine, NDT&E Int. 21 (2008) 517–524.

[2] Alaknanda, R.S. Anand, Pradeep Kumar, Flaw detection in radiographicweldment images using morphological watershed segmentation technique,NDT&E Int. 42 (2009) 2–8.

[3] M. Sezgin, B. Sankur, Survey over image thresholding techniques andquantitave performance evaluation, J. Electron. Imaging 13 (1) (2004) 146–165.

[4] J. Sauvola, M. Pietikäinen, Adaptive document image binarization, PatternRecogn. 33 (2) (2000) 225–236.

[5] B. Gatos, I. Pratikakis, et al., Adaptive degraded document image binarization,Pattern Recogn. 39 (3) (2006) 317–327.

[6] I.-K. Kim, D.-W. Jung, et al., Document image binarization based ontopographic analysis using a water flow model, Pattern Recogn. 35 (1)(2002) 265–277.

[7] P. Stathis, E. Kavallieratou, et al., An evaluation technique for binarizationalgorithms, J. Universal Comput. Sci. 14 (18) (2008) 3011–3030.

[8] G. Kom, A. Tiedeu, et al., Automated detection of masses in mammograms bylocal adaptive thresholding, Comput. Biol. Med. 37 (1) (2007) 37–48.

[9] D.Y. Kim, J.W. Park, Connectivity-based local adaptive thresholding for carotidartery segmentation using MRA images, Image Vis. Comput. 23 (14) (2005)1277–1287.

[10] C.K. Chow, T. Kaneko, Automatic boundary detection of the leftventricle fromcineangiograms, Comput. Biomed. 5 (1972) 388–410.

[11] W. Niblack, An Introduction to Digital Image Processing, Prentice-Hall,Englewood Cliffs, N.J., 1986. pp. 115–116.

[12] L. Eikvil, T. Taxt, K. Moen, A fast adaptive method for binarization of documentimages, in: Proceedings of the First International Conference on DocumentAnalysis and Recognition, Saint-Malo, France, 1991, pp. 435–443.

[13] S.D. Yanowitz, A.M. Bruckstein, A new method for image segmentation, in: 9thInternational Conference on Pattern Recognition, 1988.

[14] F.H.Y. Chan, F.K. Lam, et al., Adaptive thresholding by variational method, IEEETrans. Image Process. 7 (3) (1998) 468–473.

[15] I. Blayvas, A. Bruckstein, et al., Efficient computation of adaptive thresholdsurfaces for image binarization, Pattern Recogn. 39 (1) (2006) 89–101.

[16] Q. Chen, Q.-s. Sun, et al., A double-threshold image binarization method basedon edge detector, Pattern Recogn. 41 (4) (2008) 1254–1267.

[17] D. Trier, T. Taxt, Evaluation of binarization methods for document images, IEEETrans. Pattern Anal. Mach. Intell. 17 (1995) 312–315.

[18] R.C. Gonzalez, R.E. Woods, Digital Image Processing, Prentice Hall, UpperSaddle River, NJ, 2002.

[19] Otsu, A threshold selection method from gray-level histogram, IEEE Trans.Systems Man Cybern. 9 (1) (1979) 62–66.

[20] A.W. Reza, C. Eswaran, Subhas Hati, Automatic tracing of optic disc andexudates from color fundus images using fixed and variable threshold, J. Med.System 33 (2009) 73–80.

[21] D. Welfer, J. Scharcanski, et al., A coarse to fine strategy for automaticallydetecting the exudates in color eye fundus images, Comput. Med. ImagingGraph. 34 (3) (2010) 228–235.

[22] I. Pratikakis, B. Gatos, K. Ntirogiannis, Citing Websites. H-DIBCO 2012Handwritten Document Image Binarization Contest. Retrieved Dec 12, 2012,from http://utopia.duth.gr/~ipratika/HDIBCO2012/.

[23] I. Pratikakis, B. Gatos, K. Ntirogiannis, ICFHR 2012 Competition onHandwritten Document Image Binarization (H-DIBCO2012), in: 13thInternational Conference on Frontiers in Handwriting Recognition(ICFHR’12), September 18–20, 2012, Bari, Italy, pp. 813–818.

[24] Nicholas R. Howe, Smith College, Department of Computer Science,Northampton (MA), USA.

[25] Thibault Lelore, Frédéric Bouchara, LSIS, UMR CNRS 6168, South University ofToulon-Var, La Garde, France.

[26] Mohamed Benjlaiel, Adel M. Alimi, REGIM – ENIS, University of Sfax, Tunisia.[27] Nizar Zaghden, Badreddine Khelifi, Mohamed Adel Alimi, REGIM (ENIS-sfax-

TUNISIA).


Recommended