Sei sulla pagina 1di 7

IMAGE PROCESSING, ANALYSIS,

RECOGNITION, AND UNDERSTANDING

An Integrated Edge Detection Method


Using Mathematical Morphology¶
C.-P. Huang and R.-Z. Wang
Department of Computer and Communication Engineering,
Ming Chuan University, 5 Der-Ming Rd. Kwei-shan, Tau-yuan 333, Taiwan
e-mail: hcptw@mcu.edu.tw; rzwang@mcu.edu.tw

Abstract—This paper presents an edge detection method based on mathematical morphology. The proposed
scheme consists of four steps: preprocessing, edge extraction, edge decision, and postprocessing. In the prepro-
cessing step, a morphological central transformation is applied to remove noise. In the edge extraction and deci-
sion steps, a morphological edge extractor is designed to estimate the edge information of an image, and an
edge decision criterion is followed to determine whether a pixel is an edge or not. In the postprocessing step,
the morphological hit-or-miss transformation is utilized to improve the correctness of the detected edges. It is
proved theoretically for the correctness and effectiveness for detecting ideal edges. Experimental results show
that the proposed method works well on both artificial and real images.
DOI: 10.1134/S1054661806030102

Keywords: edge detection, morphological transformation, mathematical morphology, morphological filters.

1. INTRODUCTION Mathematical morphology is an approach based on


set theory for extracting geometrical features out of sig-
Edge detection is one of the key technologies in the nals. The field was pioneered by Serra [4, 5], Sternberg
field of signal, image, and video processing. Several [12], and Maragos [9, 10]. Morphology has been shown
techniques based on linear filtering [6, 15] have been to be an effective method [2, 3, 10] to extract geometri-
proposed to detect edges. Spatial edge operators [16] cal features. Morphological edge detection has been
are conventional edge detection methods. Statistical generally performed by using the difference of the two
approaches such as the hypothesis test method [1] have processed images, for instance, between eroded and
also been proposed. Multiscale edge detection proce- dilated images or between the original and eroded
dures, such as the Canny estimation approach [7] or
Mallat wavelet approach [13], have gained popularity image [2, 14]. These results indicate that morphological
in recent years. The traditional edge detection approach operators have potential in edge detection. The results
uses local operators as well as a threshold scheme. This also show that their efforts emphasize the operator for
is done by using local operators to enhance the edge extraction.
strengths of edges and to smooth small variations at the The simplest morphological edge detectors are dila-
same time, and a threshold is applied to the processed tion and erosion residues [5]. In Serra’s book [4], he
image to determine whether the edge pixel is present or proposes the gradient method as an edge detector. A
not. Sobel edge operator [11] is one of the most popular gradient is defined by averaging the difference between
edge detection operators. This operator is a weighted- dilation and erosion of the signals and corresponds to
average operator that gives greater weight to points jumps in the image. This method is very simple and
lying close to the point of interest. These techniques effective when noise is absent. In Marago’s paper [8],
are shown to be effective in a clean image, but they he proposes the erosion residue method. He defined the
work poorly in the presence of noise [7]. There are structure element nB = B ⊕ B ⊕ …B, where B is a unit
some limitations of using linear-based instead of non- size structure element, n is an element’s size, and ⊕ is
linear-based edge detection operators. A linear filter the morphological dilation operator. The residue f –
may either blur edges or be sensitive to noise, while a ( fΘnB) will enhance the edge of a gray-scale image f,
nonlinear filter retains the sharpness of the edges and is where Θ is the morphological erosion operator. The
insensitive to noise. Statistical and multiscale size n of nB will control the thickness of the edge mark-
approaches are based on convolution calculations and ers. The results of this method will be position-biased
consider multiple sizes of the windowed signal that can to the border of the brighter side. Haralick et al. [2] pro-
be computationally expensive. pose the blur-minimum morphological edge method.
¶ The
This method has been shown to be effective in edge
text was submitted by the authors in English. extraction, but the edges are fuzzier.
In this paper, we propose an integrated mathemati-
Received August 5, 2005 cal morphology procedure to detect edges in images.

ISSN 1054-6618, Pattern Recognition and Image Analysis, 2006, Vol. 16, No. 3, pp. 406–412. © Pleiades Publishing, Inc., 2006.
AN INTEGRATED EDGE DETECTION METHOD USING MATHEMATICAL MORPHOLOGY 407

Morphological operators are nonlinear; they are not [3]. These properties show the validity of the CT for the
only very effective for detecting edges but also well signal smoothing.
suited for efficient implementation using parallel or To compare with the linear smoothing (LS) operator
sequential computing [5]. The proposed method is shown in Eq. (4) used in many edge detection algo-
shown to be theoretically effective for ideal edges. rithms [2, 16],
Experimental results are provided to show the validity
( N – 1 )/2
and performance of our method in practice for artificial

1
and real images. LS ( f ( n ) ) = ---- f ( n – j ), (4)
N
j = – ( N – 1 )/2

2. THE PROPOSED METHOD where N (odd, positive integer) is the number of pixels
of the mask and the median smoothing (MD) operator
The proposed edge detection method consists of the is constructed by replacing the value of each point with
following four steps: (1) preprocessing, (2) edge extrac- the median value in the masked neighborhood of that
tion, (3) edge decision, and (4) postprocessing. The point. The CT method is a better choice for noise
purpose of the preprocessing step is to remove noise removal in edge detection applications due to the fol-
from an image in order to enhance the validity of the lowing observations: (1) Using LS, sharp edges are
subsequent edge detection process. A morphological widened. However, using the CT and MD, sharp edges
edge extractor is proposed to evaluate the edge infor- are preserved. (2) The CT method smoothes out more
mation of an image, and the morphological decision than LS or MD. (3) In the noisy case, the CT and MD
step is applied to decide whether or not edges are remove all the noise, while the LS cannot. These obser-
present. In the postprocessing step, a morphological vations indicate that the morphological filter is a better
hit-or-miss transformation is designed to remove extra- choice for signal smoothing than the linear or median
neous noisy edges. Details of each step are presented in smoothing.
the following subsections.
2.2. Edge Extraction
2.1. Preprocessing
In this section, an effective edge extraction scheme
A good edge detection algorithm should not only be based on the morphological transformation is proposed
capable of detecting the edge information but also be and its validity is investigated. The edge extraction
insensitive to noise. A morphological transformation is operator is defined as follows:
proposed here to remove noise while keeping the edge
information. In order to deal with both positive and f ed
(5)
negative noise, we combine the positive and negative = Max { LS ( f ( n ) ) – f ( n ) , Min { e r ( n ), d r ( n ) } },
morphological smoothing filters to form the morpho-
logical central transformation (CT). The central trans- where fed is the extracted edge information, f is an input
formation is derived from the combination of morpho- signal such as an image, and LS(.) is the linear operator
logical opening-closing and morphological closing- defined in Eq. (4). The size of the linear smoothing
opening filters to obtain the central area of the signal, mask is the same as the size of the structuring function
that is, used in the erosion and dilation residues. The erosion
residue er is defined as
CT ( f ( n ) )
(1) e r = f – ( fΘk ), (6)
= Min { oc ( f ( n ) ), Max { co ( f ( n ) ), f ( n ) } },
where co( f (n)) is the morphological opening operation where k is a structuring function with a flat top and zero
followed by the morphological closing operation height, f is the input signal, and Θ is the morphological
applied to signal f (n) and the oc( f (n)) is the morpholog- erosion operator. The dilation residue dr is defined as
ical closing operation followed by the morphological dr = ( f ⊕ k ) – f , (7)
opening operation applied to signal f (n). The central
transformation has the following important properties:. where f and k are the same as in the erosion residue and
Property 1. The CT( f (n)) is bounded to co( f (n)) ⊕ is the morphological dilation operator. We list some
and oc( f (n)), that is, properties of the proposed edge extraction operator to
support the validity of the operator.
co ( f ( n ) ) ≤ CT ( f ( n ) ) ≤ oc ( f ( n ) ). (2) Property 3. If input signal f (n) is constant over the
Property 2. The CT filter is an idempotent filter, that size of the mask (or support K of the structuring func-
is, tion) and the structuring function has a flat top with
zero height, then the extracted edge information
CT ( CT ( f ( n ) ) ) = CT ( f ( n ) ). (3) fed(n) = 0.
These properties can be proved using the antiextensive, Proof: By definition, fed = Max{|LS( f (n)) – f (n)|,
extensive, and idempotent properties of co and oc filters Min{er(n), dr(n)}}. If f (n) is constant over the mask

PATTERN RECOGNITION AND IMAGE ANALYSIS Vol. 16 No. 3 2006


408 HUANG, WANG

area, then LS(f(n)) = 0, and |LS(f(n)) – f(n)| = 0. If f(n) By definition,


is constant over the support K of the structuring func- ( N k – 1 )/2
tion, then mini ∈ K f(n + i) = f(n) and maxi ∈ K f(n – i) =
f(n) hold, and thus er = f – (fΘk) = f(n) – mini ∈ K f(n + LS ( f ( n ) ) = 1/N k ∑ f ( n – n i ), (12)
i) = 0. Similarly, it can be derived that dr = (f ⊕ k) – f = 0. n i = – ( N k – 1 )/2

Thus, we have fed = Max{|LS(f(n)) – f(n)|, LS ( u ( n ) )


Min{er(n), dr(n)}} = 0.
⎧ 0 if n ≤ n 0 – n j , n j ≥ ( N k + 1 )/2,
This property shows that our edge extractor has the ⎪
property that the edge detected is 0 if there is no edge. ⎪ C if n ≥ n 0 + n j , n j ≥ ( N k + 1 )/2,

Property 4. If the input signal f(n) is not constant ⎪ ( N k + 2n j + 1 )C/ ( 2N k ) if n ≥ n 0 + n j , (13)
over the size of the mask (or support K of the structur- = ⎨
ing function) and the structuring function has a flat top ⎪ 0 ≤ n j < ( N k + 1 )/2,
with zero height, then, for at least one point n' ∈ K, we ⎪
have fed(n') > 0. ⎪ ( N k – 2n j + 1 )C/ ( 2N k ) if n ≤ n 0 – n j ,
⎪ 1 ≤ n < ( N + 1 )/2.
Proof: By definition, fed = Max[|LS(f(n)) – f(n)|, ⎩ j k

Min[er(n), dr(n)]]. If f(n) is not constant over the mask


Let LSr(f(n)) = |LS(u(n)) – u(n)|. Then,
area, then we can find at least two points n1, n2 ∈ K,
f(n1) ≠ f(n2) in the mask area such that LS(f(n1)) – f(n1) ( N k – 1 ) > 0, (14)
LS r ( u ( n 0 ) ) = LS r ( u ( n 0 – 1 ) ) = -------------------
-
≠ 0 or LS(f(n2)) – f(n2) ≠ 0. Let us assume the point n' 2N k
∈ K to be n1 or n2. Then, |LS(f(n')) – f(n')| > 0.
and
We have fed(n') = Max[|LS(f(n')) – f(n')|, Min[er(n'),
dr(n')]] > 0. f ed ( n 0 ) = f ed ( n 0 – 1 ) > 0. (15)
This property shows our edge extractor has the We have
property that, if there is an edge (not flat a surface), then
the edge detected is greater than 0. ⎧ LS r ( u ( n 0 ) ) > LS r ( u ( n 0 + n j ) ), n j > 0,
⎨ (16)
Property 5. If f(n) is a step edge u(n) defined as ⎩ LS r ( u ( n 0 – 1 ) ) > LS r ( u ( n 0 – n j ) ), n j > 1.
⎧ C if n ≥ n 0 , This implies
u(n) = ⎨ (8)
⎩ 0 otherwise, ⎧ f ed ( n 0 ) > f ed ( n 0 + n j ), n j > 0,
⎨ (17)
where C is a positive constant value and the size of the ⎩ f ed ( n 0 – 1 ) > f ed ( n 0 – n j ), n j > 1.
mask is odd (≥3), then fed(n0 – 1) = fed(n0) > 0 and those
two points have the maximum value. Thus, fed(n0) = fed(n0 – 1) > 0, and these two points have
the maximum value.
Proof: By definition, we have
This property shows that our edge extractor extracts
⎧ f ed(n) = Max [ LS( f (n)) – f (n) , Min [ e r(n), d r(n) ] ],
two pixels with the maximum value in the masked area
⎪ e (n) = ( f (n) – ( f (n)Θk ) ) = f (n) – min f (n + i), for the step edge and that these two edge pixels are at a
⎨ r i∈K
(9) higher and lower gray-scales of that edge. This property
⎪ confirms that our edge extractor is an unbiased two-
⎩ d r ( n ) = ( f (n) ⊕ k ) – f (n) = max f (n – i) – f (n),
i∈K pixel edge detector for an ideal step edge.
Property 6. If f(n) is a ramp edge r(n) defined as
where k is a structuring function with a flat top with
zero height and K is the support of the structuring func-
⎧ C if n ≥ n i
tion. Let Nk be the size of the mask or structuring func- ⎪
tion. If f(n) = u(n), then we have r ( n ) = ⎨ C ( n – n 0 )/ ( n i – n 0 ) if n 0 < n < n i , (18)

⎧ C if n 0 ≤ n ≤ n 0 + [ ( N k – 3 )/2 ], ⎩ 0 otherwise,
er ( n ) = ⎨ (10)
⎩ 0 otherwise. where C is a positive constant value and the size of the
mask is odd (≥3), then the edge detected at the middle
point, nm, is greater than zero, i.e., fed(nm) > 0, where
⎧ C if n 0 – [ ( N k – 3 )/2 ] ≤ n ≤ n 0 – 1, m = ⎣(i + 1)/2⎦ and ⎣x⎦ denotes the largest integer part
dr(n) = ⎨ (11)
⎩ 0 otherwise. of x.
Proof: By definition, fed(n) = Max{|LS(f(n)) – f(n)|,
From Eqs. (10) and (11), we get Min[er(n), dr(n)] = 0. Min{er(n), dr(n)}}.

PATTERN RECOGNITION AND IMAGE ANALYSIS Vol. 16 No. 3 2006


AN INTEGRATED EDGE DETECTION METHOD USING MATHEMATICAL MORPHOLOGY 409

(a) (b) (c)

Fig. 1. Artificial test images: (a) the clean image, (b) the noisy version with SNR 10dB, (c) the noisy version with SNR 7dB.

Fig. 2. Edge detection results of Fig. 1 using the proposed method.

Fig. 3. Edge detection results of Fig. 1 using the blur-minimum method.

Let f(n) = r(n). Then, LSr(r(n)) = |LS(r(n)) – r(n)| ≥ 2.3. Edge Decision
0, ∀n. If LSr(r(nm)) > 0, then fed(nm) > 0 holds. If
LSr(r(nm)) = 0, then we need to show Min[er(nm), In addition to the edge information, the image con-
dr(nm)]] > 0 first, then we can get fed(nm) > 0. tains many spurious pixels, illustrating the problem
associated with thresholding the edge information. The
By definition, r(n) = C if n ≥ ni, C(n – n0)/(ni – n0) if simplest thresholding technique would be to select a
n0 < n < ni, 0 otherwise. single value Th and assign all pixels with an edge
We have r(nm) = C(nm – n0)/(N – n0) > 0, er(nm) = strength above the selected value Th to the set of edge
r(nm) – Minj ∈ Kr(nm + j) > 0, and dr(nm) = Maxj ∈ Kr(nm – pixel. But in real image it seems hard to select a single
j) – r(nm) > 0, where K is the support of the structuring threshold value that will extract the edge without spuri-
function. We get Min[er(nm), dr(nm)]] > 0. ous noise.
This property confirms that our edge extractor In order to solve this problem, we apply a morpho-
detects the middle point of the ramp edge. logical operator Rm to the extracted edge first and then

PATTERN RECOGNITION AND IMAGE ANALYSIS Vol. 16 No. 3 2006


410 HUANG, WANG

Fig. 4. Real test images: Lena, House.

Fig. 5. Edge detection results of Fig. 4 using the proposed method.

Fig. 6. Edge detection results of Fig. 4 using the blur-minimum method.

thresholding to get a binary signal. The morphological The property can be shown easily by using the anti-
operator Rm is defined as extensive property of the oc filter. The advantage of this
R m ( n ) = f ed ( n ) – Min [ oc ( f ed ( n ) ), f ed ( n ) ], (19) operator is not only that it can be used to select the
peaks of interest but also that it is above most of the tex-
where fed denotes the extracted edge information image, ture. Thus, this operator can be used for prethreshold-
oc is the opening–closing operation, and Min[x] ing purposes. The width of the structuring function
denotes the minimum of x. used in this stage should not be more than that used in
Property 7. Rm(n) is a nonnegative value for all n. the edge extraction. Then, to determine the edge pixel

PATTERN RECOGNITION AND IMAGE ANALYSIS Vol. 16 No. 3 2006


AN INTEGRATED EDGE DETECTION METHOD USING MATHEMATICAL MORPHOLOGY 411

in the image, just set a single threshold value Th is nec- 6, respectively. Figure 6 indicates that some thin edges
essary. The thresholding is are lost and the detected edges appear fuzzy when using
the blur-minimum based method. Figure 5 shows that
⎧ C if R m > Th, the proposed method successfully detects the edges of
F = ⎨ (20) the test images. The results indicate that the proposed
⎩ 0 otherwise, algorithm is effective in the edge detection of complex
where F is a binary signal or image, C is a fixed con- images. A visual evaluation gives the impression that
stant (C > 0), for the binary image case C = 1, Rm is the the proposed algorithm has a better performance in the
test images.
morphological operation signal, and Th is set to a small
constant.
4. CONCLUSIONS
2.4. Postprocessing In this paper, the problem of edge detection using a
Although the edge can theoretically be correctly morphological approach has been studied. Existing
detected, in practice the resulting edge image will have methods for edge detection emphasize the edge extrac-
some broken and isolated edge pixels. If we assumed tion only. In this paper, we use morphological
edges are connected and not isolated, then some kind of approaches to solve the edge detection problem with a
noise removal and edge growing is required to improve more complete and robust solution. We show theoreti-
the quality. This procedure can be efficiently performed cally the correctness and effectiveness for the proposed
using morphological operators. Since the image in this method in manipulating ideal edges. Experimental
step is already a binary image, the morphological oper- results are also provided to show the validity and high
ator is also binary. The hit-or-miss transformation [9] is performance of our method in practice for artificial and
proposed to remove the spurious noise and to grow bro- real images.
ken edges by designing proper structuring element
pairs.
REFERENCES
The hit-or-miss transformation is defined as
1. A. Kundu and S. K. Mitra, “A New Algorithm for Image
F ⊗ S ( n ) = ( FΘA ) ∩ ( F ΘB ),
c
(21) Edge Extraction, a Statistical Classifier Approach,”
IEEE Trans. on Pattern Analysis and Machine Intelli-
where F is a binary image, S is a structuring element gence 9, 569–577 (1987).
pair S = (A, B) (one to probe the inside and one to probe
2. J. Lee, R. Haralick, and L. Shapiro, “Morphological
the outside of F), Fc is the complement of F, and ∩ is a Edge Detection,” IEEE J. of Robotics and Automation 3,
logical AND operator. It is assumed that A and B are 142–155 (1987).
disjoint, or otherwise it is impossible for both fits to
3. J. R. Hidalgo and P. Salembier, “Robust Segmentation
occur simultaneously. Since the hit-or-miss transforma- and Representation of Foreground Key Regions in Video
tion is a pattern-matching process, so it can be used to Sequences,” Proc. IEEE ICASSP 3, 1565–1568 (2001).
locate the desired pattern for removal or recovery.
4. J. Serra, Image Analysis and Mathematical Morphology
(Academic Press Inc., 1982).
3. EXPERIMENTAL RESULTS 5. J. Serra, “Introduction to Mathematical Morphology,”
In this section, two experiments are conducted to Computer Vision, Graphics, and Image Processing 35,
test the validity of the proposed method. A structuring 283–305 (1986).
function of dimensions 3 × 3 with a flat top and zero 6. K. Cinkler, “Very Low Bit-Rate Wavelet Video Coding,”
height is used in the experiments. In the first test, an IEEE J. on Selected Areas in Communications 16, 4–11
artificial checkerboard image and two of its noisy ver- (1998).
sions shown in Fig. 1 are selected to test the algorithm. 7. J. Canny, “A Computational Approach to Edge Detec-
Figures 1b and 1c show added Gaussian noise to Fig. 1a tion,” IEEE Trans. on Pattern Analysis and Machine
with a signal-to-noise ratio (SNR) of 10.0 and 7.0 dB, Intelligence 8, 6979–6986 (1986).
respectively. The edge detection results of the proposed 8. P. Maragos, “Morphological Filter-Part I,” IEEE Trans.
algorithm and the blur-minimum method [2] are shown on Acoustics, Speech, and Signal Processing 35, 1153–
in Figs. 2 and 3, respectively. These results indicate that 1169 (1987).
the visual quality of these two methods in the “clean” 9. P. Maragos, “Morphological Filter-Part II,” IEEE Trans.
artificial images is almost the same. However, the edge on Acoustics, Speech, and Signal Processing 35, 1170–
detection results using the proposed method are more 1184 (1987).
insensitive to noise. 10. P. Salembier and J. Serra, “Morphological Multiscale
In the second test, we apply the algorithm to popular Image Segmentation,” SPIE-VCIP 1818, 620–631
real test images of Lena and House, shown in Fig. 4. (1992).
The edge detection results using the proposed method 11. R. C. Gozalez and E. W. Richard, Digital Image Process-
and the blur-minimum method are shown in Figs. 5 and ing (Prentice-Hall Inc., 2002).

PATTERN RECOGNITION AND IMAGE ANALYSIS Vol. 16 No. 3 2006


412 HUANG, WANG

12. S. R. Sternberg, “Grayscale Morphology,” Computer Trans. on Pattern Analysis, and Machine Intelligence 9,
Vision, Graphics, and Image Processing 35, 333–355 532–550 (1987).
(1986).
15. T. Meier and K. N. Ngan, “Video Segmentation for Con-
13. S. Mallat and S. Zhong, “Characterization of Signals
tent-Based Coding,” IEEE Trans. on Circuit and Systems
from Multiscale Edges,” IEEE Trans. on Pattern Analy-
for Video Technology 9, 1190–1203 (1999).
sis, and Machine Intelligence 14, 701–732 (1992).
14. S. Sternberg, R. Haralick, and X. Zhuuang, “Image 16. Y. Yakimovsky, “Boundary and Detection in Real World
Analysis Using Mathematical Morphology,” IEEE Image,” J. of ACM 23, 599–618 (1976).

Chin-Pan Huang was born in Ran-Zan Wang was born in 1972


1959 in Taiwan, Republic of China. in Fukien, Republic of China. He
He received the B.S. and M.S. degrees received his B.S. degree in computer
in electrical engineering from Chung engineering and science in 1994 and
Cheng Institute of Technology, Tai- M.S. degree in electrical engineering
wan, in 1981 and in 1985, respec- and computer science in 1996, both
tively. In 1996, he received the Ph.D. from Yuan-Ze University. In 2001, he
degree in electrical engineering from received his Ph.D. degree in computer
the University of Pittsburgh in the and information science from
United States. From 1996 to 2002, he National Chiao Tung University. In
was an associate scientist of the Elec- 2001–2002, he was an assistant pro-
tronic System Division in Chung Shan fessor at the Department of Computer
Institute of Science and Technology. He then joined the Engineering at the Van Nung Institute of Technology. He
Department of Computer and Communication Engineering at joined the Department of Computer and Communication
Ming Chuan University in August 2002 and is currently an Engineering at Ming Chuan University in August 2002 and is
assistant professor there. His recent research interests include currently an assistant professor there. His recent research
data compression, computer vision, digital image processing, interests include data hiding and digital watermarking, image
and pattern recognition. processing, and pattern recognition. Dr. Wang is a member of
the Phi Tau Phi Scholastic Honor Society.

PATTERN RECOGNITION AND IMAGE ANALYSIS Vol. 16 No. 3 2006

Potrebbero piacerti anche