Matecconf cscns2020 03031
Matecconf cscns2020 03031
Matecconf cscns2020 03031
1051/matecconf/202030 903031
CSCNS2019
1 Introduction
In the 20th century, digital image processing technology began to appear and developed
rapidly. Its application is very extensive, involving military science, agriculture, industry,
medical and health [1] and other fields. The edge of digital image exists everywhere in the
image, which contains a lot of information and plays a very important role in the post-
processing of the image, so the edge detection of the image also develops rapidly. The edge
of the image can be said to be the gray segmentation line between different regions with
different gray values, representing the end of one region and the beginning of another new
region. The edge exists in the part where the gray values of the image changes sharply [2],
and it can be used as the dividing line between the target object and the background in the
image.
The commonly used first-order differential operators are roberts operator, Sobel operator
and Prewitt operator, and the second-order differential operators are Laplacian operator and
LOG operator. These traditional algorithms are simple in operation and fast in running, but
they also have defects such as many detected edge breakpoints, low positioning accuracy and
sensitivity to noise. Therefore, many new algorithms have been proposed in recent years,
such as the edge detection algorithm based on neural network and morphology, etc [3,4].
© The Authors, published by EDP Sciences. This is an open access article distributed under the terms of the Creative
Commons Attribution License 4.0 (http://creativecommons.org/licenses/by/4.0/).
MATEC Web of Conferences 309, 03031 (2020) https://doi.org/10.1051/matecconf/202030 903031
CSCNS2019
These algorithms have good detection effect, but the algorithm is complex and the
implementation speed is slow. For traditional Sobel operator, its calculation is simple,
running quickly, but there are defects. this paper is aiming at the shortcomings of the
traditional Sobel detection operator, proposing an improved algorithm, which extends the
operator template to eight directions, and then refines the obtained edge by morphological
operation. So compared with the traditional Sobel detection operator, it has better
improvements in the thickness of the edge, positioning accuracy and so on.
At the edge of the image, the pixel value changes violently and the gradient amplitude is
large. Therefore, the gradient image of an image can be used to determine whether it has the
edge we want and the location of the edge we want. Let an image be h(x,y), and the
neighborhood of an image is shown in Fig.1. The central pixel is (x,y), and the gradient [5]
at the pixel (x,y) can be obtained as Eq .1. It is a vector with a size and direction. Where, the
magnitude of the gradient amplitude can be obtained from Eq .2 and can be obtained from
Eq .3[6] for simple calculation. The gradient direction can be obtained from Eq .4:
(x-1,y-1) (x,y-1) (x+1,y-1)
(x-1,y) (x,y) (x+1,y) ൩
(x-1,y+1) (x,y+1) (x+1,y+1)
Fig. 1. An image neighborhood.
∂h(x,y) ∂h(x,y)
gradሾh(x,y)ሿ=hሺx,yሻ= ቂ , ቃ (1)
∂x ∂y
The calculation of partial derivative of the gradient above is large. In practical calculation,
the template is used to approximate the gradient by convolution. The traditional Sobel
operator is an edge detection operator based on the first derivative, it has 3u3 edge detection
templates in two directions, which detect the horizontal and vertical edges respectively. The
templates are shown in Fig.2.
-1 0 1 -1 -2 -1
-2 0 2൩ 0 0 0൩
-1 0 1 1 2 1
Fig. 2. Sobel operator template.
When Sobel operator is used to detect the edge of an image, the horizontal and vertical
operator templates in Fig.2 are respectively used to perform convolution operation on each
pixel in the image, as shown in Eq.5 and Eq.6, and then the gradient value at each pixel point
in the image can be obtained from Eq.3.
2
MATEC Web of Conferences 309, 03031 (2020) https://doi.org/10.1051/matecconf/202030 903031
CSCNS2019
hx ሺx,yሻ=hሺx+1,y-1ሻ+2hሺx+1,yሻ+h(x+1,y+1)
-hሺx-1,y-1ሻ-2hሺx-1,yሻ-h(x-1,y+1) (5)
hy ሺx,yሻ=hሺx-1,y+1ሻ+2hሺx,y+1ሻ+hሺx+1,y+1ሻ
-hሺx-1,y-1ሻ-2hሺx,y-1ሻ-h(x+1ˈy-1) (6)
According to the gradient image of an image described in 2.1, the general steps of traditional
Sobel operator to detect image edges can be summarized:
(1) traverse the horizontal and vertical templates in Fig.2 from top to bottom and from
left to right respectively, for each pixel in the image. The desired target pixel is corresponding
to the center pixel of the template, and the convolution values hx, hy are obtained from Eq.5
and Eq.6.
(2) The gradient value |grad[h(x,y)]| at each pixel can be obtained by substituting the
convolution values hx, hy into Eq.3,and then assign this value to the pixel in the center of the
corresponding template in the image as a new pixel value. In this way, a gradient image can
be obtained by calculating the new gray value of each pixel in the image successively.
(3) set a threshold Th, and compare each pixel value in the newly obtained gradient image
with the threshold Th, as shown in Eq.7:
A,ȁ h(x,y)ȁ≥Th
gሺx,yሻ= ൜ ,0<A<255 (7)
0,ȁ h(x,y)ȁ<Th
If the gray value is greater than or equal to the threshold value Th, then this pixel point is
the edge point. If less than the threshold value Th, the pixel point is not an edge point and is
set to 0. In this way, the identified edge points are connected together to be the image edges
detected by the Sobel operator.
3
MATEC Web of Conferences 309, 03031 (2020) https://doi.org/10.1051/matecconf/202030 903031
CSCNS2019
-1 -2 -1 -2 -1 0 -1 0 1 0 1 2
0 0 0 ൩ -1 0 1൩ -2 0 2൩ -1 0 1൩
1 2 1 0 1 2 -1 0 1 -2 -1 0
(a) (b) (c) (d)
1 2 1 2 1 0 1 0 -1 0 -1 -2
0 0 0 ൩ 1 0 -1൩ 2 0 -2൩ 1 0 -1൩
-1 -2 -1 0 -1 -2 1 0 -1 2 1 0
(e) (f) (g) (h)
Fig. 3. Sobel operator eight direction templates :(a)-(h) are respectively 0 °, 45 °, 90 °, 135 °, 180 °,
270 ° and 315 ° direction templates of Sobel operator.
h135° ሺx,yሻ=hሺx,y-1ሻ+2hሺx+1,y-1ሻ+h(x+1,y
-hሺx-1,yሻ-2hሺx-1,y+1ሻ-h(x,y+1) (8)
Like the algorithm in the above formula, after obtaining the gradient value in each
direction of the image, the new gray value and direction of the target pixel can be determined
by judging the maximum value, and then the image edge can be obtained by discriminating
the edge point through the threshold value.
Eq.9 indicates that the set obtained by using Z to corrode X is the set of the origin position
of Z when Z is completely included in X.
4
MATEC Web of Conferences 309, 03031 (2020) https://doi.org/10.1051/matecconf/202030 903031
CSCNS2019
(1) each of the eight direction templates in Fig.3 is used to the operation of convolution
in a pending image pixel by pixel from left to right and from top to bottom;
(2) the maximum value of the result obtained by convolving operation is used to replace
the pixel value of the target pixel point and become a new gray value, and the template
direction corresponding to the maximum value is the edge gradient direction of the target
pixel point, so the gradient image can be obtained;
(3) the gradient image is processed based on the global threshold Th. If the pixel value of
the gradient image is less than the threshold Th, the pixel value is set to 0; if it is greater than
or equal to the threshold Th, the pixel value is set to 255;
(4) the edge of the image obtained by the above three steps is relatively thick. It can be
refined by combining the expansion, corrosion, opening and closing operations in
mathematical morphology operation, and finally the edge of the image can be obtained.
4 Simulation results
It can be seen from the detected edge image that the edge detected by several traditional
operators is not as good as the image edge continuity detected by the algorithm in this paper.
Fig.4 shows several traditional operators of liftingbody image as well as the edge image
detected by the algorithm in this paper. The traditional Sobel operator has some anti-noise
ability, but the detection edge continuity is not good and there are many breakpoints. Prewitt
operator has many false edges, wide detected edges and poor continuity.LOG operator has a
certain anti-noise ability, but the detected edge continuity is not good. The introduction of
gaussian filter will cause undue smoothness to the image and lose some edge points. The
edge extracted by Canny operator is better in continuity and more detailed than the previous
operators, but there is still edge breakpoints. The algorithm in this paper detects the edge of
the image in eight directions and improves the positioning accuracy. Compared with that of
traditional operators, some noise is diluted, and the overall edge contour is clear, continuous
and hierarchical, and the detected edge is exquisite.
5
MATEC Web of Conferences 309, 03031 (2020) https://doi.org/10.1051/matecconf/202030 903031
CSCNS2019
5 Summary
Based on the traditional Sobel operator, this paper proposes an improved Sobel algorithm,
aiming at the disadvantages of low edge positioning accuracy and thick edge. This algorithm
adopts eight-direction template, sets global threshold to detect edge points, which is simple
and convenient, and uses morphological algorithm to refine edge. Experimental results show
that the final image edge positioning accuracy has been improved, and the edge is relatively
complete, clear and fine and smooth. Although the improved Sobel algorithm in this paper
makes up for the shortcomings of the traditional Sobel operator to some extent, the extracted
edge has good continuity, the positioning accuracy has been improved to a certain extent, and
the edge is fine, but there are still some cases of missing edge points, and the global threshold
is used to identify edge points, although simple and general, but not targeted, which need
further exploration.
References
1. Drulyte I, Ruzgas T, Raisutis R, Application of automatic statistical post-processing
method for analysis of ultrasonic and digital dermatoscopy images,J.Libyan Journal of
Medicine.13(1)(2018)1-9.
2. Zhou R G,Liu D Q, Quantum Image Edge Extraction Based on Improved Sobel
Operator,J. International Journal of Theoretical Physics.58(9)(2019)2969-2985.
3. Lu H, Han A L. An Improved Edge Detection Algorithm Based on Morphological
Operators and Gradient, J. Journal of Computational and Theoretical
Nanoscience.12(7)(2015)1121-1125.
4. Wang L Y, Shen Y, Liu H D, Guo Z H. An accurate and efficient multi-category edge
detection method, J. COGNITIVE SYSTEMS RESEARCH.58 (2019)160-172
5. Fan P, Zhou R G, Hu W W, Jing N H.Quantum image edge extraction based on classical
Sobel operator for NEQR, J. QUANTUM INFORMATION
PROCESSING.18(1)(2019)1-23.
6. Wang H M,Pan Y L, Gu J N,Research on the improvement of image edge detection
algorithm based on artificial neural network,J.Journal for Light-and
Electronoptic.126(21)(2015)2974-2978.
7. Liu J D,Fan X N, Ding P H,Zheng Q Y, Multi-instrument image edge detection algorithm
based on improved Sobel operator,J. Science technology and engineering.12
(9)(2012)4691-4696.
8. Suman Rani, A novel mathematical morphology based edge detection method for
medical image,J. CSI Transactions on ICT.4 (2-4)(2016)217-225.