Automatic Gradient Threshold Determination For Edge Detection
Automatic Gradient Threshold Determination For Edge Detection
Automatic Gradient Threshold Determination For Edge Detection
5, MAY 1996
I. INTRODUCTION
This paper describes a model-based method for accurately and
automatically determining a threshold that separates edge pixels from
nonedge pixels for intensity images. Since the general definition of
edges as sharp intensity changes over a small area of an image
does not lend itself to a specific mathematical formula, many edge-
detection algorithms have been used [I]. This paper focuses on the
enhancemendthresholding method of edge detection, since it is the
most common in practice [2], [3]. Convolving an operator with the
image yields a gradient value that is proportional to the degree of
contrast under the operator. The determination of a threshold, which
decides between edge and nonedge pixels in the image, is very
difficult since it may depend upon the application, the source of the
image, and the subjective perception of the viewer. 0.012-1
The threshold decision for a gradient histogram is similar to the
automatic segmentation problem where grey scale or color can be
used to classify pixels. Such methods generally place the threshold
at the minimum value between two peaks of the histogram (Fig.
1), relying on the modality, shape, or moments of the classes in
the histogram [4], [SI. However, this is not effective for gradient
histograms, as they typically do not have two distinct peaks (Fig. 2).
Past approaches in edge evaluation suggest selecting a threshold that
optimizes various edge attributes such as continuity, edge location,
and classification error [l], [6], [7], but these are not well suited for a
wide range of images. Techniques such as the p-tile [SI, which assume
a fixed percentage of edge pixels a priori, produce only a rough
estimate, since the percentage strongly depends upon the image and
noise present.
"0 100 200 300 400 500 600 700 800
Gradient Squared
11. THEFIVE-PARAMETER
EDGEMODEL
Our approach employs a statistical classification based upon a Fig. 2. Typical histogram for edge thresholding with the estimated densities
five-parameter model that fits the sum of edge and nonedge density of the nonedge and edge pixels.
functions to the original histogram. Assuming a normal distribution
of intensity contrasts for edges and nonedges in the intensity image, to the initial histogram is the sum of a gamma density representing
the edge operators produce a gradient squared value that could be the edge pixels and a gamma density representing the nonedge pixels
modeled as a noncentral chi-squared distribution. However, due to the and weighted by the edge to nonedge pixel ratio PO, which can be
computation involved with this distribution, we modeled the gradient formally written as f ( x I n o , / & ) p o + f ( z I a l , P ~ ) ( l - p o )(Fig. 2).
values with a gamma distribution. The gamma distribution fits this By accurately estimating the five parameters of this model, we can
assumed model of gradient values well (x' : p < . O l ) , thus validating statistically determine a threshold to distinguish between edges and
the use of this approach. The overall five-parameter model tbat is fit nonedges using a ML (maximum likelihood) or MAP (maximum a
posteriori) criterion 161.
Manuscript received August 31, 1994; revised August 28, 1995. This work
was supported by the NSF under Grant no. IRI-9011421. The associate editor
coordinating the review of this manuscript and approving it for publication 111. DESCRIPTION
OF THE PARAMETER CALCULATIONS
was Prof. William E. Higgins.
The authors are with the School of Electrical Engineering, Purdue Univer- Using our model, there are several different methods of estimating
sity, West Lafayette, IN 47907 USA (e-mail: [email protected]). the five parameters. Global descent methods that try to estimate all
Publisher Item Identifier S 1057-7149(96)03169-7. five parameters simultaneously were found to be too computationally
Fig. 3. Battery of 16 images of varying scenes. Moving left to right starting Fig. 4. Thresholded images using our model
at the top, the images are: Umas House scene; X-ray skull image; Bethl;
Conlact: Crowd; Dilts; Synthetic Dragon Cartoon; Flir Images of a Truck:
Gih; Girl2; Jo; John: Satellite Image of Earth; Madonna quantized to a few Since it is difficult to accurately estimate the parameters for two
grey levels; Text Scan; and Im16. densities simultaneously from their sum, we divide all the points in
tlhe histogram into two nonoverlapping groups. Again using the EM
expensive. Instead, we divided the parameter estimation problem algorithm formulation, we compute a ratio function of the densities
into two algorithm steps, which is similar to the EM (expectation- weighted by po at each point of the histogram, defined as
maximization) algorithm (81, [91 and significantly reduces the search P O x densityO(i)
ratio(i) =
space. po x densityO(i) +
(1 - P O ) x densityl(i)
The first step, which we will refer to as “alpha-beta estimation,” where density0 and density1 are the reconstructions of the gamma
attempts to find the CY and B parameters of both the edge and
densities given the estimates of the Q and )?! parameters from the
nonedge density functions. The second step, “percentage estimation,” most recent estimation. From this ratio function we form two new
computes the p o ratio of edge and nonedge pixels in the image. These
density estimates
two steps are performed alternately until the parameters converge or
no progress is made. densityd(i) = histogram(i) x ratio(;)
1) Initial p,” = 88%
2) Initial alpha-beta estimation (p;) returns a,“,(?; a t . ,!!I:
densityl‘(i) = histogram(2) x (I - ratio(i))
3) Overall estimation loop {
percentage estimation (a,“:&, CY:, a:) updates TI;+’ firom which new 0 and 13 parameters can be more easily estimated.
alpha-beta estimation ( a ; /$, a ; ,
~ a,“,pi+’) We compared five different methods for estimating the 01 and 4
returns ck:+J , p + 1 n.h+l, fiF+l
parameters of each density: the method of moments [lo], maximum
,io > 1
I: = k + 1 ] likelihood (ML) [lo], and a two-parameter Powell descent algorithm
where the I; denotes the iteration number. using the dl-d3 distance measures 1111. As will be discussed later,
Before defining the algorithms, we had to define a “best fit” of the maximum likelihood proved the most effective. The maximum
the model to the data. We used three distance measures that provide likelihood estimates are the parameter values for which the density
a measure of how well the model histogram vector U^ fits the actual functions (density0’ and d e n s i t y 1’) written
data histogram vector y, as follows:
d l : the absolute distance error given by E, I y? - 2, I
d2: the squared error given by C,(:y& -. x ~ ) ~
d3: the area between the curves using a trapezoidal approxima-
achieve a maximum value. The ML estimates can be calculated by
tion.
taking the log of the density function and setting its partial derivatives
While the measures are strongly correlated, they represent different
with respect to Q and ,3 equal to 0, as follows:
accuracies and computation speeds, and vary with the amount of
noise present.
B. Percentage Estimation
The percentage of nonedge pixels po determines the relative
weights of the two densities that sum to the gradient histogram. Four
different algorithms were compared for the percentage estimation of
nonedges. Three of the algorithms use the golden section descent
algorithm, a 1 -D minimization method based on the bracketing of the
minimum value, with the distance measures d l through d3 [ I l l . The Fig. 5. Images thresholded at 27, 39, 57, and 128 gradient units for subjective
fourth algorithm employs the EM algorithm on a Bernoulli estimate decisions. The computed threshold is the second image.
of the ratio. The latter algorithm, which proved to be the best, can
be described for a histogram of length n as shown at the bottom of
the page.
C. Threshold Determination
Given two overlapping densities, there are several methods of
determining a threshold. We considered the MAP, ML, and fixed
percentage po decision thresholds, which are the most common in Fig. 6. Synthetic images with added white Gaussian zero-mean noise of
practice. Of these three methods, the MAP threshold, which decides variances 1.0, 128.0, 1024.0, and 4096.0.
that an edge is present when d e n s z t y l x (1- P O ) > denszty0 x PO,
proved the most accurate.
IV. EXPERIMENTS
Two different techniques are used to analyze the effectiveness
of our model. In the first experiment, 16 diverse images are pro-
cessed with the different algorithms and the computed thresholds are
compared with the subjective edge threshold decisions made by five Fig. 7. Thresholded synthetic images with added white Gaussian zero-mean
researchers. The second experiment evaluates the robustness of the noise of variances 1.0. 128.0, 1024.0, and 4096.0.
model to different noise levels applied to a synthetic image.
A. Data Preparation
To evaluate the parameters, the images are converted into a
histogram prepared by smoothing with a 3 x 3 Gaussian filter [12],
applying the Sobel operator [13], and forming a normalized histogram
of the gradient units. Although our model can utilize any differential
or gradient-based operator with similar results, only the 3 x 3 Sobel
operator is employed since it is effective in the presence of noise and
is widely used 161.
1 p: E, densityO(j)
pi+’ = histogram(i)
-
n pk E,densityO(j) + (1 - pi) E,densityl(j) ’
IEEE TRANSACTIONS ON IMAGE PROCESSING, VOL. 5, NO. 5 , MAY 1996 787