Sei sulla pagina 1di 8

Edge and junction detection improvement using the Canny algorithm with a

fourth order accurate derivative filter


Andrea Aprovitola and Luigi Gallo
Institute for High Performance Computing and Networking,
National Research Council of Italy (ICAR-CNR), Naples, Italy
Email: {andrea.aprovitola, luigi.gallo}@na.icar.cnr.it

AbstractThe Canny algorithm has been extensively


adopted to perform edge detection in images. The Derivative
of Gaussian (DoG) proposed by Canny has been shown to
be the optimal edge detector to compute the image gradient
due to its robustness to noise. However, the DoG has some
important drawbacks in relation to images with thin edges
of a few pixels width and junctions. The excessive blurring
provided by the DoG affects the detection of the double
and triple junctions that sometimes appear broken while
the corners appear rounded. Such a loss in detail is due
to the second order approximation of the finite difference
(FD) operator adopted to discretize the DoG detector. In this
work an improvement of the Canny algorithm is proposed
for images having thin edges, computing the edge detector as a convolution of a fourth order accurate FD with
the smoothed Gaussian image. The modified wavenumber
analysis of the FD formulation is adopted to motivate the
improvement in the edge resolution gained by the fourth
order FD discretization. Quantitative comparisons performed
with a second order FD discretization of the edge detector
adopting both synthetic and benchmark images highlight an
improvement in edge localization and in junction detection.
Keywords-edge detection; junction detection; fourth order
derivative filter.

I. I NTRODUCTION
Edge detection is a low-level image processing operation adopted for object recognition. Edges are regions of
pixels where the gradient of the image is discontinuous.
In the absence of depth and illumination discontinuities,
edges evidence the boundaries between different objects.
Thus edges are one of the most important sources of
information in an image [1]. Furthermore, the prior knowledge derived from the edge map is adopted to drive
the convergence of segmentation algorithms applied to
complex images [2].
An edge detection procedure involves three steps: image
smoothing, edge detection and edge localization. Image
smoothing is adopted to regularize the image with respect
to the noise [1]. Edge detection is achieved by evaluating
the magnitude and direction of the image gradient, which
define the edge strength and orientation respectively. The
approximation chosen to evaluate the gradient of the image
defines the accuracy of the detector operator [13]. The
most commonly adopted edge detector relies on the discrete convolution of the image with filter masks obtained
from second order accurate FD approximations of the
exact differential operators [12].
The Prewitt and Sobel edge detectors are both based on
a second order FD discretization of the image gradient

components. The only difference lies in the different


coefficients of the filter masks that tune the response
of the detector to the noise. On the other hand, the
Canny operator defined as the Derivative of Gaussian
filter (DoG) [13] has been proved to be the optimal edge
detector due to its property of providing a low error
rate, good edge localization and single edge response.
Although the Canny algorithm is considered to be the
gold standard for edge detection, it has some important
drawbacks related to the detection of the connectivity at
junctions and the corner resolution [1]. Tests performed on
benchmark images with the Canny algorithm have shown
that the image junctions appear broken and the corners are
excessively rounded [21].
These limitations become important when the edge
detection has to be performed on images affected by noise
with edges of a few pixels width [1]. The DoG detector
sets the edge scale resolution by tuning the width of the
Gaussian filter . Low values of make the DoG detector
sensitive to fine edges but also to noise. In contrast, larger
values of the Gaussian width make the DoG robust to
noise but lead to a coarser edge resolution. In addition to
this limitation, DoG performance is also affected by its
numerical approximation.
Numerical computation of the DoG detector requires the
convolution of a FD operator with the Gaussian filtered
image. In this case, the smoothing provided by the DoG
depends also on the order of the approximation of the FD
operator. The wavenumber analysis of FD methods shows
that the order of accuracy of a FD formula does not give
any indication of the frequency resolution of the discrete
derivative operator [3].
Commonly adopted approximations used for edge detection rely on second order FD operators. However, a
second order FD results in a smoothing of the high wavenumber components of the signal to which it is applied [3].
Such a consideration applies also to images as the smooth
frequency components of an image are due to the smooth
intensity variations. On the other hand, edges correspond
to high frequency components describing the fine details
of an image [6]. Thus a second order FD discretization of
the gradient of the smoothed image results in a smoothing
of the image frequency components associated with thin
edges and sharp corner. This effect adds to the smoothing
deriving from the application of the Gaussian filter in the
DoG operator making the DoG detector less sensitive in
detecting fine image details.

To improve the spectral resolution of the discrete derivative operator, a high order FD formula can be adopted. In
fact, fourth order FD has an improved spectral resolution
compared to second order FD and increases the frequency
resolution of the discrete edge detector [14].
In this work we propose an improvement of the Canny
edge detector based on a fourth order FD approximation
for the derivative of the Gaussian filtered image. The proposed procedure is validated with respect to a benchmark
database where ground truth segmentation is available.
Comparisons between the Canny algorithm obtained with
a second order FD discretization of the DoG and with a
fourth order discretization are performed. The improvement in edge detection accuracy is quantitatively assessed
through the introduction of a similarity index. The tests
relative to junction detection evidence the recovery of the
broken junctions detected by the second order FD discretization of the DoG. Furthermore, the tests performed
on real benchmark images show an improvement in thin
edge localization.
II. R ELATED W ORK
Modifications of the Canny algorithm documented in
literature are mainly focused on improving the edge detector accuracy and on reducing the uncertainty deriving
from manual thresholding. A scale multiplication-based
scheme was developed in [15] to enhance the performance
of the Canny edge detector incorporating the property of
different edge scales. The similarity between the filtered
images at two contiguous edge scales was exploited to
define a multiplication function given by the multiplication
of filtered images at two contiguous scales. The edges
of the image were located by applying the detection
and localization criteria of such a multiplication function.
Implicit finite differencing schemes were adopted in [8] to
replace the DoG and to perform the computation of the image gradient. The implicit FD scheme was integrated into
the Canny algorithm and the results were compared with
a second order FD difference, Sobel and Sharr operators
being used to compute the gradient. Tests performed on
benchmark images showed that an implicit finite difference
reduced the excessive blurring obtained with Sobel and
the second order finite difference computation due to the
improvement in the spectral resolution.
An improved Canny algorithm was proposed in [18]
for images affected by illumination problems. To account
for the uncertainty in the gradient calculation, an algorithm was adopted an algorithm based on the concept
of type-2 fuzzy sets. The algorithm automatically selects
the threshold values needed to provide the thresholded
gradient images. The results showed a good performance
on benchmark images and medical images.
Other proposed improvements of the Canny algorithm
were focused on the thresholding step. The limitations
imposed from the manual threshold step were overcome by
Otsu in [17] by adopting the adaptive thresholding method.
The low threshold value was computed adaptively through
a probability distribution model. A Gaussian probability

GrayScale Image I
DoG Derivatives

G (x, y)
I
x

G (x, y)
I
y

Iy

Ix
Gradient Magnitude

Ix + I y

Iy
Ix

Gradient Direction = arctg

Non Maxima Suppression

Hysteresis Thresholding
Edge Map
Figure 1. Workflow of the Canny algorithm with the DoG edge detector
(Canny DOG )

was chosen to calculate the derivative along the image


direction hence the low threshold value was derived from
histogram analysis. The drawbacks deriving from the
wrong detection of double and triple junctions by the
Canny algorithm were analyzed in [10]. The authors proposed a method to recover broken edges by improving the
non maxima suppression step. Pixels detected as maxima
of the gradient image were denoted as minor edges if
their gradient magnitude is maxima but not in the gradient
direction. Minor edges were further subdivided into false
and true edges. True edges connected with major edges
allowed the recovery of the broken edges.
In this work we have improved the frequency resolution
of the edge detector in the Canny algorithm by adopting a
fourth order FD applied to the Gaussian smoothed image.
Differently from [8] we adopt a fourth order explicit FD
formulation. The explicit FD is less expensive from a
computational point of view compared to the implicit FD
[14]. Besides, fourth order accuracy has a less blurring
effect with respect to the second order FD approximation
used in the numerical discretization of the DoG operator.
Moreover, we will show that fourth order explicit FD
provides sufficient spectral resolution to detect thin edges
and sharp corners.
III. I MPROVED C ANNY EDGE DETECTION
Canny edge detection is summarized in the flow chart
reported in figure 1. The gradient of the image along the

coordinate directions is computed by adopting the DoG


operator i.e.:
G
I
Ix =
x

(1)

G
Iy =
I,
y

(2)

and

being G is the two dimensional Gaussian function of


2
+y 2
width i.e. G(x, y) = exp( x 2
2 ). The bar symbol
indicates the component of the smoothed gradient of the
image. The Gaussian function built in the DoG operator
allows for the removal of noise and selects the edge scale
resolution [20].
Non-maxima suppression is adopted to produce a single
edge response from the edge detection reducing the thick
edges to a single line. Once the gradient magnitude
and direction are known at a pixel (i, j), the gradient
magnitude is scanned in each of the four pixel neighbors
perpendicular to such a direction:

= 0 , (i + 1, j) , (i 1, j)
= 90 (i, j + 1) , (i, j 1)
= 45 (i + 1, j + 1) , (i 1, j 1)
= 135 (i + 1, j 1) , (i 1, j + 1).

When pixel (i, j) has the highest gradient magnitude


among the two neighbor pixels examined it is assumed to
be an edge. The hysteresis thresholding step preserves the
edge connectivity in pixels where the gradient fluctuations
occur due to the unfiltered noise. The adoption of two
threshold values prevents the removal of true edges when
the fluctuations of the gradient magnitude occur below one
threshold value.
To improve the Canny algorithm for images having thin
edges and junctions, we have focused focus on improving
the numerical discretization of the edge detector, recalling
(1) and (2) and considering that the differentiation can be
accomplished by the convolution [16] (1) and (2) rewrite
as:

G
I =
(G I)
x
x

G
I =
(G I).
y
y

(3)

(4)

Equations (3) and (4) show that the DoG operator


applied to an image is equivalent to convolving the image
with the Gaussian filter and then computing its derivative.
It is worth noting that such an equivalence applies also to
the discrete approximation of (3) and (4).
A. Second order discretization of the edge detector
A second order FD approximation is commonly exploited to compute the exact derivative operator in (3) and
(4) [16]. This is equivalent to a discrete convolution of the
smoothed Gaussian image with a filter having the masks:

Figure 2. The normalized modified wavenumber for second and fourth


order explicit FD

HxII

0
= 0.5
0

0 0
0
0 0.5 , HyII = 0
0 0
0

0.5
0
0.5

0
0
0

(5)

being HxII and HyII the horizontal and vertical edge detector of the second order FD filter. Thus, by partitioning the
image domain by means of a uniform grid spacing along
the image coordinate directions we obtain the following
second order approximation for (3) and (4):

(G I) HxII (G I) =
x
1
= (Ii+1,j Ii1,j )
2

(6)

(G I) HyII (G I) =
y
1
= (Ii,j+1 Ii,j1 )
2

(7)

where the symbol is the discrete convolution and I =


G I the smoothed Gaussian image, respectively.
B. Wavenumber accuracy of derivative filters
As previously remarked, the order of accuracy of a
FD approximation affects the frequency resolution of the
discrete derivative operators and so the edge resolution.
In figure 2 is reported the behavior of the modified vs
the exact wavenumber reported normalized with respect
to the Nyquist cut-off frequency kc = /h being h = 1,
the grid spacing for a second and a fourth order FD
approximation of a first derivative in one dimension.
The modified wavenumber is the effective wave number
resolved by the FD operator [14].
Looking at figure 2, it appears that only for low
wavenumber do the second and the fourth order FD
approximations behave as the exact differential operators.
Figure 2 shows that the smooth frequency components
of the image are correctly approximated by (6) and (7).

Thus, in the frequency domain second order FD operators


behave as low-pass filters smoothing the high frequency
components of the image. This results in a loss in resolution of the edge detector relative to the detection of
the sharp intensity variations occurring on edges of a
few pixels width. Such considerations suggest a way of
overcoming the smoothing provided by the DoG operator
by adopting a fourth order approximation for the exact
derivative operator in (3) and (4).

GrayScale Image I
Gaussian Filtering

(G (x, y) I )
x
H xIV I

(G (x, y) I )
y
H IV I
y

C. Fourth Order Derivative Filter


A fourth order FD approximation for the first derivative
requires a discrete convolution of the smoothed images
with the filter masks:

HxIV

0
0

=
1
0
0

0
0
8
0
0

0 0 0
0 0 0

0 8 1

0 0 0
0 0 0

(8)

Gradient Magnitude

Ix + Iy

Iy

Gradient Direction = arctg


Ix

Non Maxima Suppression

Hysteresis Thresholding

and

HyIV

0
0

0
0

0
0
0
0
0

1
8
0
8
1

0 0
0 0

0 0
,
0 0
0 0

Edge Map

(9)

Adopting (8) and (9), (3) and (4) rewrite as:

Figure 3. The modified Canny algorithm adopting a fourth order finite


difference filter mask

IV. R ESULTS
A. Validation of the procedure

i,j =
(G I) (HxIV I)
x
Ii2,j 8Ii1,j + 8Ii+1,j Ii+2,j
=
12

(10)

(G I) (HyIV I)i,j =
y
Ii,j2 8Ii,j1 + 8Ii,j+1 Ii,j+2
=
12

(11)

and

that are the expression of the fourth order accurate FD


central approximation for the first derivative along x and
y evaluated in the pixel i,j.
D. Modified Canny workflow
In figure 3 the workflow of the proposed Canny F DIV
algorithm is reported, in which we first perform the
smoothing of the image and then apply the fourth order
discrete derivative filters along x and y to compute the
gradient magnitude. The remaining steps of the Canny
algorithm are left unchanged. We adopted MATLAB
functions provided in [11] to implement the hysteresis
thresholding and non maxima suppression steps of Canny
procedure.

We tested the accuracy of the Canny F DIV algorithm


with reference to the synthetic image proposed in [21]
and reported in figure 4. Such an image shows edges
with different angles and line junctions. Furthermore, the
differences in the gray level intensity among the features
(triangle, square etc.), allow us to estimate the accuracy
in the edge localizations. Such a point is particularly
important in complex images where a strong blurring
deriving from large width of the Gaussian filter is adopted
to balance the noise and a single response from the edge
detector operator is required.
Figure 5 reports the comparisons between the edge
detection performed with Canny DoG (images a,c,d) and
Canny F DIV (images b,e,f ). The width of the Gaussian
filter was set equal to = 0.5 [21]. The low and
high threshold values used in the hysteresis thresholding
step were manually set equal to thlow = 0.016 and
thhigh = 0.05 respectively for both the algorithms. Such
values allowed us to obtain the best performance from
the edge detection of Canny DoG compared to the manual
edge detection assumed as the ground truth.
In order to compare quantitatively the algorithms we
adopted the Jaccard similarity index. Such index evaluates
the overlap between the detected binary image and the
ground truth image:

J(I gt , I edge ) =

|I gt I edge |
,
|I gt I edge |

(12)

being I gt the ground truth image and I edge the binary


edge map obtained by Canny DoG and Canny F DIV .
Canny
Adopting (12) we had JDoG
= 0.44 and JFCanny
DIV =
0.5. The similar order of magnitude of the Jaccard index
states that both algorithms detect the edge with the same
overall accuracy and that a slight improvement is gained
with Canny F DIV . This improvement in the similarity
index can be explained by comparing the features c,e
and d,f reported in figure 5. The features detected with
Canny F DIV show a single localization of the edge
separating the regions having different gray levels. This
appears inside the triangle and the rectangle feature of
the image considered (see images c,e and d,f ). The same
edge detection accuracy is not obtained when adopting
Canny DoG . In fact, inspecting images d,f, two oblique
adjacent lines of pixels, and not a single line of pixels,
separate the regions having a different gray level intensity.
Moreover, comparing the corners of the features c,e and
d,f we found an improvement in corner resolution with
Canny F DIV while the corners detected with Canny DoG
appeared more smoothed.
The improvements in edge detection obtained with
Canny F DIV are the effect of the higher accuracy of
the numerical discretization. In fact, the lower smoothing
effect induced by the fourth order FD discretization of (3)
and (4) allows us to improve the localization of the thin
edges.
B. Triple Junction detection
Image a reported in figure 5 shows that several triple
junctions appear broken for both the Canny DoG and
Canny F DIV . Such a result is consistent with the results
reported in [21]. Setting the scale of the Gaussian filter to
= 1 in (8) and (9), it appears from figure 6 that most
of the triple junctions are recovered on both sides of the

Figure 5.
Edge detection obtained with Canny DoG (a,c,d) and
Canny F DIV (b,e,f )

feature considered with Canny F DIV (see image l). On


the other hand, it appears that Canny DoG (see image i in
figure 6) does not produce the same accuracy in the triple
junctions that remain broken.
C. Test on the Berkley image dataset

Figure 4.

The synthetic image used for validation

In this section we report the results of the comparison


between Canny F DIV and Canny DoG by adopting the
Berkley segmentation dataset and benchmark [7]. This
being a database organized by algorithms, we refer to the
database images obtained with the Multiscale Gradient

Figure 6.
Comparisons between the edge detection obtained with
Canny DoG (g,i) and Canny F DIV (h,l)

Magnitude. We assumed the machine segmented image


from the database as the ground truth with which to
compare the results of Canny F DIV and Canny DoG .
Two images were selected from the database: m and w,
reported in figure 7 and figure 9, respectively. The first
one has been used to test the Canny F DIV accuracy so
as to detect double and triple junctions, while the second
one to assess the accuracy of Canny F DIV in detecting
disjoint edges. The width of the Gaussian filter was set
equal to = 1 in both cases to achieve a balance between
noise reduction and fine edge detection. The low and
high threshold values used in the hysteresis thresholding
step were set equal to thlow = 0.06 and thhigh = 0.1,
respectively.
In figure 7, we report the comparisons between the
edge maps detected with Canny DoG and Canny F DIV
(images o,p, respectively). In table I, we report the value
of the Jaccard index (12) for the images o,p with respect
to the ground truth image n. Looking at table I, we can
observe an improvement in edge detection obtained with
Canny F DIV of 10% for both the images. In fact, in
images o,p some features appear to be better detected by
Canny F DIV . In figure 8 we report an enhancement of the
side of the building where Canny F DIV (image t) appears
to outperform Canny DoG (image s).
As the same threshold parameters are used for both the
Table I
JACCARD INDEX FOR Canny DoG AND Canny F DIV .
Image
A
B

J(I gt , I Canny )
0.2
0.2

J(I gt , I F DIV )
0.3
0.3

Figure 7.
Edge detection comparisons: n ground truth image, o
Canny DoG , p Canny F DIV

algorithms and in particular the width of the Gaussian filter


, we suppose that this value does not provide the same
edge response due to the different accuracy of the numerical discretization of the edge detector operator. The different results obtained with Canny DoG and Canny F DIV
could be explained by considering the stronger blurring of
the DoG operator. When a second order discretization of
DoG is adopted, slight differences in gray level intensity
in the features of figure 8 begin to vanish due to the
reduced contrast among the objects. Hence, the edges
tend to be segmented as several connected lines. Such an
effect of the numerical discretization of the DoG operator
can be interpreted as if a coarser edge scale greater than
that imposed one imposed by had be selected. On
the other hand, Canny F DIV , due to the fourth order
discretization, has a good spectral accuracy on the high
frequency components of the image that correspond to
the thin edges. Thus, it appears to be sensitive only on
effective variations of the image intensities.
Figure 9 reports the results relative to the edge detection
performed on images having several disjoint edges occurring in a small pixel neighbor. Table I shows the improvement in the edge detection obtained with Canny F DIV .

t
Figure 9.
Edge detection comparisons: x ground truth image, y
Canny DoG , j Canny F DIV

R EFERENCES
[1] F. A. Pellegrino, W. Vanzella, and V. Torre Edge Detection
Revisited, IEEE Transactions on systems, Man And Cybernetics - Part B: Cybernetics. 2004,34(3):1500-1518.
[2] H. Tang. E. X. Wu, Q. Y. Ma, D. Gallagher, G. M. Perera,
T. Zhuang MRI brain image segmentation by multi-resolution
edge detection and region sellction, Computerized Medical
Imaging and Graphics. 2000,24:349-357.
Figure 8.
Edge detection comparisons: r ground truth image, s
Canny DoG , t Canny F DIV

In fact, images y and j show that Canny F DIV provides a


more sensitive resolution. In particular, focusing on the
plumage, it appears that very close plumes in the test
image still appears as different objects in Canny F DIV .
V. C ONCLUSIONS
In this work we have introduced a way to overcome
the limitations of the Canny algorithm for the detection of
images having thin edges and junctions. The recognition
of such features is important in complex images where
a high sensitivity in edge detection is required and a
large width of the Gaussian filter has to be adopted to
balance the effect of the noise. Exploiting the properties
of the convolution, we have proposed an edge detector
based on the fourth order derivative of the Gaussian
smoothed image, also detailing the differences between
the performance of the developed procedure by adopting
the wavenumber analysis of finite difference formulation.
Tests performed on synthetic and real images highlight
the improvement in edge detection of thin features and in
edge localization. The proposed idea is general and could
represent the basis for the development of a novel kernel
suitable for use when high sensitivity in edge detection is
required to overcome the effects of noise and blurring.

[3] S. K. Lele. Compact finite difference schemes with


spectral-like resolution, Journal of Computational Physics.
1992,103:16-42.
[4] M. Swamy, M. S Holi. Knee joint cartilage visualization and
quantification in normal and osteoarthritis, In Proceedings
of IEEE International conference on systems in medicine
and biology ICSMB; 2010, 148-152
[5] G. Piccioli, E. D. Micheli, P. Parodi, M. Campani. Robust
method for road sign detection and recognition, Image and
Vision Computing. 1996,14(3): 209-223
[6] B. Jane. Digital Image Processing 6th ed,
SPRINGER

2005,

[7] D. Martin, C. Fowlkes, D. Tal, J. Malik, A Database of


Human Segmented Natural Images and its Application to
Evaluating Segmentation Algorithms and Measuring Ecological Statistics, Proc. 8th Intl Conf. Computer Vision,
2001,2:416-427.
[8] A. Belyaev. Implicit Image Differentiation and Filtering with
application to image sharpening, SIAM Journal of Imaging
Sciences. 2013,6(1):660-679.
[9] M. Ali, D. Clausi, Using the Canny edge detector for feature
extraction and enhancement of remote sensing images, IEEE
International Geoscience and Remote Sensing SymposiumIGARSS 01. 2001,5:2298-2300.
[10] L. Ding, A. Goshtasby, On the Canny edge detector, Pattern
Recognition. 2001,34:721-725.

[11] P. D. Kovesi, MATLAB and Octave Functions for Computer


Vision and Image Processing, School of Computer Science &
Software Engineering, The University of Western Australia,
Perth; http://www.csse.uwa.edu.au/ pk/research/matlabfns .
[12] R. C. Gonzales. Digital image processing 3rd Edition,
2007, Prentice Hall Edition.
[13] J. Canny A Computational Approach to Edge Detection ,
IEEE Transactions on Pattern Analysis and Machine Intelligence. 1986, 8 (6):.679,698.
[14] J. H. Ferziger, M. Peric Computational Methods for fluid
Dynamics, Springer 2013
[15] P. Bao, D. Zhang, W. Xiaolin , Canny edge detection
enhancement by scale multiplication, IEEE Transaction
on Pattern Analysis and Machine Intelligence.
2005,
27(9):1485,1490.
[16] T. S. Yoo. Insigth into Images: principles and practice for
segmentation, registration and image analysis, T. S. Yoo
(Editor.) 2004
[17] Y. K. Huo, G. Wei, Y. D. Zhang; Le-nan Wu. An adaptive
threshold for the Canny Operator of edge detection, International Conference on Analysis and Signal Processing (IASP),
9-11 April 2010 371,374
[18] R. Biswas, J. Sil. An Improved Canny Edge Detection
Algorithm Based on Type-2 Fuzzy Sets, Procedia Technology,
2012,4:820-824.
[19] J. M. Brady, S. M. Smith. A new approach to low level
image processing, International Journal of Computer Vision,
1997,23:45-78.
[20] A. F Kazerooni, A. Ahmadian, N. D. Serej, Rad H S.,
H Saberi, H Yousefi, P. Famia. Segmentation of brain tumors
in MRI images using multi-scale gradient vector flow, Engineering in Medicine and Biology Society, EMBC. Annual
International Conference of the IEEE Aug. 30 -Sept. 3 ,
2011 7973,7976.
[21] S. M. Smith, J. M. Brady SUSAN-A New approach to low
Level Image Processing , International Journal of Computer
Vision. 1997, 23(1):.45,78

Potrebbero piacerti anche