Grey Relevancy Degree and Improved Eight-Direction Sobel Operator Edge Detection


Edge detection is an important aspect to improve image edge quality in image processing. The purpose of edge detection is to identify the points in digital images with great brightness variation. However, the accuracy of traditional edge detection methods in edge extraction is low. For the actual image, the grey edge is sometimes not very clear, the image also contains noise. The detection result of the traditional Sobel operator is relatively accurate, but the detection result is rough and sensitive to noise. To solve the above problems, this paper proposes an improved eight-direction Sobel operator based on grey relevancy degree, which combines 5 × 5 Sobel operator with a grey relational degree and a new eight-direction grey relevancy method. The results show that this method can detect the useful information of edge more accurately and improve the anti-noise performance. However, the drawback is that the algorithm is not automatic.

Share and Cite:

Yang, Y. and Wei, L. (2021) Grey Relevancy Degree and Improved Eight-Direction Sobel Operator Edge Detection. Journal of Signal and Information Processing, 12, 43-55. doi: 10.4236/jsip.2021.122002.

1. Introduction

Edge is one of the most basic and important features of an image. In a digital image, edge refers to the collection of pixels with a step-change in the greyscale of surrounding pixels, which exists in the target and background, target and target, region and region, elements and elements [1]. So, the essence of image edge detection is to detect the change of position feature in the image. Edge detection has always been a hotspot and focuses in image processing technology, and has become one of the most standard research topics in image processing, image analysis, automatic target recognition, and computer vision [2].

In recent years, a variety of new edge detection theories and methods have emerged in an endless stream, and academic ideas have been very active. Traditional edge detection methods include differential algorithm, Robert operator, Sobel operator, Prewitt operator, Kirsch operator, etc. Prewitt and Sobel’s operators are examples of gradient-based edge detectors [3] [4]. Marr and Hildreth [5] proposed the Laplacian of Gaussian (LoG) operator for edge detection, which uses Gaussian function for image smoothing, then calculates the second derivative, the zero-crossing points are considered to be edge points. Canny presented an optimal edge detector, especially for two-dimensional images. Canny operators can give the edge information of both intensity and direction [6]. There are also new edge detection methods based on fuzzy mathematics, statistical analysis, wavelet transform, mathematical morphology, the genetic algorithm, neural network, etc. Edge is an important feature of the image, which is a greyscale mutation, and these greyscale mutations constitute the edge. The classical operator uses a derivative operator combined with the grey level change to detect the edge. The grey system is a model with incomplete information. Grey relevancy analysis is to analyze the grey system with mathematical theory. Its characteristic is “the data is little, the information is poor”, take the known information as the reference, the quantitative acquisition unknown information development trend. Aiming at the problem that the detection effect of the classical edge detection operator on the image with sufficient edge information and the weak edge image is not ideal, the traditional Sobel operator is improved and optimized by combining the grey relevancy degree.

In this paper, a new edge detection algorithm based on an improved eight- direction Sobel operator combined with a grey relevancy degree is proposed. This algorithm firstly improves and expands the traditional Sobel, and then uses the improved Sobel operator as a reference sequence to calculate the relevant degree of each point in the image for edge detection. The experimental results show that this method can accurately detect useful edge information, and has a certain anti-noise ability, and is an effective new edge detection method.

This paper is divided into the following parts. Section 1 introduces the research background, significance, and innovation points. Section 2 introduces traditional Sobel operators. Section 3 introduces how to improve and extend the Sobel operator. Section 4 introduces the concept of grey relevancy degree. Section 5 introduces how to combine the improved Sobel operator and grey relevancy degree. Section 6 compares and analyzes the method of this paper with other traditional detection methods. Section 7 introduces the feasibility and disadvantage of the edge detection method based on the Sobel eight-direction operator and grey relevancy degree.

2. Sobel Edge Detection Operator

Sobel proposed the Sobel edge detection method in 1970. In 2012, HE et al. [7] improved the traditional Sobel operator detection algorithm. In 2014, SUN et al. [1] expanded the Sobel operator into eight directions. In 2016, SHI et al. [8] added 6 templates with different directions to Sobel operator. The traditional Sobel edge detection is to do 3 × 3 pixel area through the corresponding template convolution operation. It is concluded that the centre pixel gradient values; it is greater than the threshold criterion for determining the pixel image edge pixels, the opposite is not.

The operator uses two 3 × 3 kernels, which are convolved with the original image to calculate approximations of the derivatives one for horizontal changes and one for vertical. If we define A as the source image, and G x and G y are two images which at each point contain the horizontal and vertical derivative approximations respectively, the computations are as follows [9]:

G y = 1 2 1 0 0 0 1 2 1 × A , G x = 1 0 1 2 0 2 1 0 1 × A (1)

The corresponding calculation process is as follows:

G y = [ f ( x 1 , y 1 ) + 2 f ( x , y 1 ) + f ( x + 1 , y 1 ) ] [ f ( x 1 , y + 1 ) + 2 f ( x , y + 1 ) + f ( x + 1 , y + 1 ) ] G x = [ f ( x + 1 , y 1 ) + 2 f ( x + 1 , y ) + f ( x + 1 , y + 1 ) ] [ f ( x 1 , y 1 ) + 2 f ( x 1 , y ) + f ( x 1 , y + 1 ) ] (2)

where, f ( x , y ) is the grey value at ( x , y ) in image A.

The Sobel operator is the magnitude of the gradient computed by

G = G x 2 + G y 2 (3)

The gradient direction is calculated as follows:

θ = arctan ( G y G x ) (4)

3. Improved Sobel Edge Detection Operator

3.1. Eight-Direction Edge Detection 5 × 5 Template

Edge detection is similar to difference operation, its essence is to detect the change of image brightness, so noise will inevitably affect the detection effect. To avoid the influence of noise, not only difference processing but also smoothing processing should be considered when constructing edge detection operators. Similar to the first-order difference template, the Roberts crossover operator only considers difference factors. The Prewitt operator expands the first-order difference template to size 3 × 3, introducing the mean operation. In the edge detection algorithm, the Sobel operator is used as the detection template, which considers both the difference factor and the optimal smoothing coefficient [10].

The theoretical basis of constructing the Sobel operator is a pascal triangle. The pascal’s triangle can calculate a set of coefficients of the smoothing operator, which is roughly the same as that of the gaussian smoothing operator in the limit case [11].

For different counts, the coefficient of position k is Pascal ( k , n ) :

Pascal ( k , n ) = n ! ( n k ) ! k ! , ( 0 k n ) (5)

Pascal ( k , n ) = 0 , otherwise (6)

For the template window size of winsize, the smoothing coefficient is:

S ( k ) = Pascal ( k , winsize 1 ) , ( 0 k winsize 1 ) (7)

For the template window size of winsize, the difference coefficient is:

D ( k ) = Pascal ( k , winsize 2 ) Pascal ( k 1 , winsize 2 ) ( 0 k winsize 1 ) (8)


Sobel X ( x , y ) = x = 0 winsize 1 y = 0 winsize 1 Smooth ( y ) Diff ( x ) (9)

Sobel Y ( x , y ) = y = 0 winsize 1 x = 0 winsize 1 Smooth ( x ) Diff ( y ) (10)

A new Sobel operator is calculated by using Pascal’s triangle to obtain a significant image detection effect. An eight-direction 5 × 5 edge detection template is reconstructed. The weight of each position in the template is determined by the distance from the position to the centre point and the direction in which the position is located in the template. Equidistant points have the same weight. The eight-direction 5 × 5 edge detection template of the improved Sobel operator is respectively:

G 0 = [ 1 4 6 4 1 2 8 12 8 2 0 0 0 0 0 2 8 12 8 2 1 4 6 4 1 ] (11)

G 45 = [ 1 4 8 2 0 4 12 8 0 2 8 8 0 8 8 2 0 8 12 4 0 2 8 4 1 ] (12)

G 90 = [ 1 2 0 2 1 4 8 0 8 4 6 12 0 12 6 4 8 0 8 4 1 2 0 2 1 ] (13)

G 135 = [ 0 2 8 4 1 2 0 8 12 4 8 8 0 8 8 4 12 8 0 2 1 4 8 2 0 ] (14)

G 180 = [ 1 4 6 4 1 2 8 12 8 2 0 0 0 0 0 2 8 12 8 2 1 4 6 4 1 ] (15)

G 225 = [ 1 4 8 2 0 4 12 8 0 2 8 8 0 8 8 2 0 8 12 4 0 2 8 4 1 ] (16)

G 270 = [ 1 2 0 2 1 4 8 0 8 4 6 12 0 12 6 4 8 0 8 4 1 2 0 2 1 ] (17)

G 315 = [ 0 2 8 4 1 2 0 8 12 4 8 8 0 8 8 4 12 8 0 2 1 4 8 2 0 ] (18)

3.2. Template Convolution Calculation

In the above improved Sobel operator detection template, each template is composed of symmetric numbers that are opposite to each other and equal in absolute value. The current pixel in the original image is convolved with a certain template in the eight-direction Sobel operator detection template to obtain the grayscale value of the image in all directions [12].

Improved Sobel operator 0 edge template:

After convolution calculation of G 0 and the grey value of pixel point on the image, the form is H 0 , and each element in this form is the corresponding weight on the 0 edge template G 0 is the product of the value and the grey value f i j of the corresponding pixel in the image, where

G 0 = [ f 11 4 f 12 6 f 13 4 f 14 f 15 2 f 21 8 f 22 12 f 23 8 f 24 2 f 25 0 0 0 0 0 2 f 41 8 f 42 12 f 43 8 f 44 2 f 45 f 51 4 f 52 6 f 53 4 f 54 f 55 ] (19)

4. Edge Detection Grey Relevancy Degree

Grey system theory [13], which is found by the Chinese scholar professor Deng Julong in the 1980’s, is a method of studying the small sample and the uncertainty system of poor information. If we view a digital image as a random sequence, we can view an image as a grey system. Grey relevancy analysis is an important part of the grey system theory. Its basic idea is to measure the correlation degree among factors by the similarity degree of geometric relation or curve. The curvilinear relationship or geometric relationship between the comparison sequence and the reference sequence, if they are similar in shape, the degree of correlation is greater. The reference sequence is the representation of the change of system characteristics, while the comparison sequence is the description of the change of the affected system. Qi, Yingjian et al. [14] proposed a new image edge detection algorithm based on the grey system theory. When edge detection is carried out on a grayscale image, a certain pixel K and its 8-field pixels can be arranged to form a sub-sequence K i , and the ideal non-edge points and their 8-field pixels can be formed into a mother sequence K 0 . When the correlation degree of K i and K 0 is large, it means that the geometric shapes of the two sequences are relatively similar. Therefore, it is considered that the intensity of grey value change of pixel point at adjacent pixel point K is similar to that of an ideal non-edge point. So the pixel K can be considered as a non-edge point. Similarly, when the correlation between two sequences is small, pixel K can be regarded as the edge point.

Grey relevancy calculation procedure [15] as follows:

1) Select the reference sequence y ( k ) , and find the conversion sequence of the sequence X i = ( x i ( 1 ) , x i ( 2 ) , , x i ( n ) ) ( i = 0 , 1 , , n ) .

2) Because the data in each factor column in the system may differ in dimension, it is not easy to compare, or it isn’t easy to get the correct conclusion when comparing. In grey relevancy analysis, and data should be processed dimensionless. [i)]

i) Initial value processing: x i ( k ) = x i ( k ) x i ( 1 ) , k = 1 , 2 , , n ; i = 0 , 1 , 2 , , m .

ii) Averaging treatment: x i ( k ) = x i ( k ) x ¯ i , k = 1 , 2 , , n ; i = 0 , 1 , 2 , , m .

where k corresponds to a time period, and i corresponds to a column in the comparison sequence.

3) Calculated correlation coefficient:

ξ i ( k ) = min i min k Δ i ( k ) + ρ max i max k Δ i ( k ) Δ i ( k ) + ρ max i max k Δ i ( k )

where Δ i ( k ) = | y ( k ) x i ( k ) | .

For ρ ( 0, ) , which is called the resolution coefficient, the smaller ρ , the greater the resolution, The value range of ρ is generally ( 0,1 ) , The specific value depends on the situation. When ρ 0.5463 , the resolution is the best. Usually ρ = 0.5 .

4) Calculate the grey correlation degree r i between the comparison sequence formed with each pixel as the centre and the reference sequence and r i is the overall correlation the degree between the reference sequence y ( k ) and the comparison sequence x i ( k ) at each moment

r i = 1 n k = 1 n ξ i ( k ) , k = 1 , 2 , , n .

5) The judgment method of edge points is as follows: when r i is higher than θ given threshold of correlation degree, it indicates that this point has the same characteristics as the reference sequence and is not an edge point. Otherwise, it’s the edge point.

5. Image Edge Detection Based on Grey Relevancy Degree and Sobel Operator with Eight Directions

The edge extracted by the traditional Sobel operator has noise interference, the boundary between the edge and the background is fuzzy, and the continuity of the detected image edge is poor. The improved Sobel operator has enhanced noise resistance, the boundary between the edge contour and the background is clear, and the overall edge continuity is good. However, there still exists a phenomenon of too thick edge texture. In the improved Sobel operator, grey relevancy is introduced to solve the problem of edge thickness, so that the contour and texture details of the image can be improved [16].

In the Grey relevancy method of image edge detection, the grey values of pixels as reference sequences are equal. This paper presents a new method based on grey relevancy degree and eight-direction Sobel operator. It is mainly divided into the following steps:

1) Select eight templates of Sobel operator as the reference sequence and the behavioral sequence which consists of each pixel and neighborhood pixels as the comparative sequence.

2) Calculating the grey relevancy degree of the eight-direction for each pixel, for the R i .

3) Setting the threshold θ , when R i > θ , then the pixel X i is the edge point, and the grey value is defined as 255; Otherwise, X i is not the edge point and the grey value is defined as 0.

4) It can get the edge point of the whole image with a 5 × 5 window over the entire image sequence, and then connect the edge points to get the edge of the image.

6. Experimental and Simulation Results

The feasibility of the proposed algorithm is verified by qualitative and quantitative analysis. The peak signal-to-noise ratio, average gradient and structural similarity index were used for quantitative comparison.

Peak signal to noise ratio (PSNR): provides an objective standard to measure image distortion or noise level. It is often used to evaluate image degradation before and after compression in areas such as image compression. It is often defined simply by mean square error (MSE). If one of the two M × N monochromatic images I and K is the noise approximation of the other, then their mean square error is defined as:

M S E = I M × N i = 0 M 1 j = 0 N 1 [ I ( i , j ) K ( i , j ) ] 2 (20)

The PSNR is defined as:

PSNR = 10 × lg MAX I 2 MSE (21)

where MAXI is the maximum value representing the colour of the image points, if each sampling point is represented by 8 bits, then it is 255.

Average Gradient: also known as sharpness, it reflects the contrast and texture variations of tiny details in the image, as well as the sharpness of the image, the bigger, the better.

g ¯ = i = 0 M 1 j = 0 N 1 ( Δ I x 2 + Δ I y 2 ) / 2 M × N (22)

Structural similarity index (SSIM): is a measure of the similarity between two images.

7. Qualitative and Quantitative Analysis

1) To verify the effectiveness of the algorithm, we take Lena image with a size of 256 × 256 as an example to set the optimal threshold T = 0.54 for edge detection in the new method proposed in this paper. The test results are shown in Figure 1.

It can be seen from Figure 1 that the image edge lines detected by the improved

Figure 1. Comparison of various methods of edge detection. (a) Original image; (b) Eight-direction Sobel operator; (c) Grey relevancy degree; (d) Proposed method.

eight-direction Sobel operators are relatively thick and the edge details are obvious. The algorithm based on the grey relevancy degree has poor edge continuity and some real edge missing. The algorithm based on grey relevancy degree and eight-direction Sobel operator has better edge continuity and fewer non- edge points. Although the new algorithm has the missing phenomenon of the boundary image, the integrity of the main image edge is better than that of the traditional algorithm.

2) The algorithm can detect the edges of Lena images with different parameters. In the experiment, a threshold value is used for segmentation. If the threshold value is set too large, the edge contour may be discontinuous or not smooth enough. An initial threshold value is selected and continuously adjusted during the experiment to obtain the best threshold value. First, select T = 0.48. With the increase of the threshold, the extracted texture details gradually increase, as shown in Figure 2. However, after a certain threshold is exceeded, when more edges are detected, the image texture is too complex, resulting in the image edge contour is not smooth enough for better observation. Thus, when the threshold value is T = 0.54, the image can be observed with clear texture and smooth edges. In Table 1, it can be intuitively seen through structure similarity index (SSIM) and average gradient ( A G ) that with the increase of threshold, the value of SSIM also increases. Still, when it exceeds 0.54, SSIM starts to decrease, and the average gradient increases with the increase of threshold. The average

Figure 2. Edge detection results under different parameters. (a) Origin image; (b) Threshold value of 0.48; (c) Threshold value of 0.50; (d) Threshold value of 0.52; (e) Threshold value of 0.54; (f) Threshold value of 0.55.

Table 1. Comparison of objective evaluation indicators for edge detection.

gradient is the clarity, and the greater the value, the higher the clarity. Through experimental results and quantitative analysis, the optimal threshold value of this algorithm is T = 0.54.

3) Figure 3 is an image of a cell with salt & pepper noise added to it. See Figure 3(b) after the random noise, Figures 3(c)-(f) is the edge result extracted by combining Sobel and grey relevancy degree in eight directions under different parameters, obviously, with the increase of the threshold, the noise resistance gradually increases.

4) Firstly, a building image with rich texture is selected. Then, the traditional algorithm and the algorithm proposed in this paper are respectively used for edge detection to verify the effectiveness of the proposed algorithm. In order not to lose fairness, the parameter selection of each algorithm in the experiment is adjusted to the best value. Figure 4(a) shows images of buildings with rich textures,

Figure 3. Edge detection results of noisy images with different parameters. (a) Origin image; (b) Noise image; (c) Threshold value of 0.48; (d) Threshold value of 0.52; (e) Threshold value of 0.55; (f) Threshold value of 0.58.

Figure 4. Contrast of detection results with different method. (a) Origin image; (b) Roberts; (c) Sobel; (d) Prewitt; (e) Log; (f) Canny; (g) Eight-direction Sobel; (h) Grey relevancy degree; (i) Proposed method.

and Figures 4(b)-(i) shows the extraction effects of different algorithms.

5) Figure 5 shows the anti-noise comparison of the cell images and Figures 5(b)-(i) is the comparison of detection results. It can be seen from the experimental results that different edge detection operators have obvious differences in processing noisy images, and the traditional operators have a poor effect on edge extraction and lack of noise resistance. Although the improved Sobel operator enhances the edge extraction effect, the noise resistance is not very ideal. The algorithm proposed in this paper shows clear edges and good noise resistance. In Table 2, the entropy value of Prewitt algorithm is the lowest, which means that Prewitt makes the de-noised image lose some details. Through the table, it can be seen clearly that the PSNA value of the algorithm in this paper is the largest, indicating that the algorithm in this paper has good visual effect and noise resistance.

Figure 5. Contrast of noise immunity with different method. (a) Origin image; (b) Roberts; (c) Sobel; (d) Prewitt; (e) Log; (f) Canny; (g) Eight-direction Sobel; (h) Grey relevancy degree; (i) Proposed method.

Table 2. Comparison of objective evaluation indexes of edge detection denoising.

8. Conclusions

This paper mainly introduces the research background of digital image edge detection and introduces various researches on edge detection in recent years. The traditional edge detection operator is improved to achieve a better detection effect.

In this paper, a new image edge detection algorithm is constructed by combining grey correlation degree and eight-direction Sobel operator. The eight-direction Sobel operator is used as the reference sequence, and the grey value of the central pixel and the surrounding 25 pixels is used as the comparison sequence of 5 × 5 pixels in the template. The experimental results show that this method can accurately extract useful edge information compared with the traditional Prewitt, Sobel, and LOG operators, which have strong anti-noise performance, can improve the image edge PSNR, and has a better adaptive ability.

Conflicts of Interest

The authors declare no conflicts of interest regarding the publication of this paper.


[1] Sun, L.H., Zhao, E.L., Ma, L., et al. (2014) An Edge Detection Method Based on Improved Sobel Operator. Advanced Materials Research, 971-973, 1529-1532.
[2] Xiang, Y., Ye, Q.H., Liu, J.G. and Zhang, T.S. (2016) Retrieve of Planetary Boundary Layer Height Based on Image Edge Detection. Chinese Journal of Lasers, 43, 185-191.
[3] Rosenfeld, A. (1989) Computer Vision: A Source of Models for Biological Visual Processes? IEEE Transactions on Biomedical Engineering, 36, 93-96.
[4] Sobel, I. (1978) Neighborhood Coding of Binary Images for Fast Contour Following and General Binary Array Processing. Computer Graphics & Image Processing, 8, 127-135.
[5] Marr, D and Hildreth, E. (1980) Theory of Edge Detection. Proceedings of the Royal Society B: Biological Sciences, 207, 187-217.
[6] John, C. (1986) A Computational Approach to Edge Detection. IEEE Transactions on Pattern Analysis and Machine Intelligence, 8, 679-698.
[7] Shi, T., Kong, J.-Y., Wang, X.-D., et al. (2016) Improved Sobel Algorithm for Defect Detection of Rail Surfaces with Enhanced Efficiency and Accuracy. Journal of Central South University, 23, 2867-2875.
[8] He, C., Zhang, X. and Hu, Y. (2012) A Study on the Improved Algorithm for Sobel on Image Edge Detection. Optical Technique, 38, 323-327.
[9] Zadeh, L.A. (1973) Outline of a New Approach to the Analysis of Complex Systems and Decision Processes. IEEE Transactions on Systems Man and Cybernetics, 3, 28-44.
[10] Gao, W.S., Zhang, X.G, Yang, L. and Liu, H.Z. (2010) An Improved Sobel Edge Detection. 2010 3rd International Conference on Computer Science and Information Technology, Chengdu, China, 9-11 July 2010, 61-71.
[11] Mathur, N., Mathur, S. and Mathru, D. (2016) A Novel Approach to Improve Sobel Edge Detector. Procedia Computer Science, 93, 431-438.
[12] Qu, Y.-D. Cui, C.-S., Chen, S.-B. and Li, J.-Q. (2005) A Fast Subpixel Edge Detection Method Using Sobel-Zernike Moments Operator. Image and Vision Computing, 23, 11-17.
[13] Deng, J.L. (1989) Introduction to Grey System Theory. Journal of Grey System, 1, 1-24.
[14] Qi, Y.J., Li, Q., Wu, Z.P., Zhang, B. and Li, Y. (2011) An Algorithm of Image Edge Detection Based on Grey System Theory. 2011 Fourth International Joint Conference on Computational Sciences and Optimization, Kun Ming and Li Jiang, China, 15-19 April 2011, 835-837.
[15] Shi, J.-T., Zhu, Y., Chu, X.-L. and Chen, X. (2010) A Novel Approach of Edge Detection Based on Gray Weighted Absolute Correlation Degree and Prewitt Operator, 2010 International Conference on Intelligent Computing and Integrated Systems, Guilin, China, 22-24 October 2010, 232-234.
[16] Kim, D.S., Lee, W.-H. and Kweon, I.-S. (2004) Automatic Edge Detection Using Ideal Binary Pixel Patterns and Fuzzy-Based Edge Thresholding. Pattern Recognition Letters, 25, 101-106.

Copyright © 2023 by authors and Scientific Research Publishing Inc.

Creative Commons License

This work and the related PDF file are licensed under a Creative Commons Attribution 4.0 International License.