Sobel Edge Detection Based on Weighted Nuclear Norm Minimization Image Denoising

: As a classic and effective edge detection operator, the Sobel operator has been widely used in image segmentation and other image processing technologies. This operator has obvious advantages in the speed of extracting the edge of images, but it also has the disadvantage that the detection effect is not ideal when the image contains noise. In order to solve this problem, this paper proposes an optimized scheme for edge detection. In this scheme, the weighted nuclear norm minimization (WNNM) image denoising algorithm is combined with the Sobel edge detection algorithm, and the excellent denoising performance of the WNNM algorithm in a noise environment is utilized to improve the anti-noise performance of the Sobel operator. The experimental results show that the optimization algorithm can obtain better detection results when processing noisy images, and the advantages of the algorithm become more obvious with the increase of noise intensity.


Introduction
Image edge means the end of one area and the beginning of another area in an image. The collection of pixels at the junction of adjacent areas in the image constitutes the edge of the image [1]. Because the grayscale difference of pixels between different areas is often very large, the purpose of edge detection is to identify pixels with obvious brightness changes in the image. The significance of edge detection is that it greatly reduces the amount of data that need to be processed. It removes the data that carry less information and retains the important structural information of the image, so it is an important research direction in the field of image processing and computer vision, especially in the area of feature extraction.
With the development of edge detection technology, there are some mature classical edge detection operators, including the Roberts operator, the Prewitt operator, the Sobel operator and the Laplacian operator. On this basis, many scholars have conducted indepth research on the above operators over the years and proposed a series of improved algorithms with much superior performance. For example, Zhang et al. proposed a fusion edge detection algorithm based on an improved Sobel operator, using a fusion algorithm that combines an improved Sobel operator, a Canny operator and a Laplacian-of-Gaussian operator to optimize the edge detection result [2]. Topno et al. proposed an improved edge detection method based on median filtering. After edge detection, the median filter is used to protect the edge from salt and pepper noise [3]. Yoon et al. proposed an edge detection method based on the Bhattacharyya distance with adjustable block space. In this algorithm, in order to calculate the Bhattacharyya distance, a pair of blocks were extracted for each pixel. The Bhattacharyya distance was used to detect edges, which was calculated from the mean vector and covariance matrix of each block. By adjusting the block space, weak edges can also be accurately detected [4]. Chetia et al. proposed a quantum-improved Sobel edge detection algorithm with nonmaximum suppression. In this algorithm, the Sobel operator with 45 • and 135 • direction masks was used for quantum 2 of 14 edge extraction, and then the non-maximum suppression technique with dual thresholds was used to sharpen the edges. This algorithm can significantly improve edge information and circuit complexity [5]. Sung et al. proposed an edge detection method based on the edge-preserving filter. The algorithm used an edge-preserving filter to smooth the image, and then used the Canny operator and morphological operations to detect edges, which can detect the edge of the image more accurately [6]. Xie et al. proposed an improved subpixel edge detection algorithm combining coarse and precise locations. The algorithm used an improved Roberts operator to detect pixel-level edges and used the Zernike moment method to locate subpixel edges, which effectively improved the detection efficiency and the detection accuracy [7]. Raheja et al. proposed a fuzzy-logic-based edge detection method. The algorithm used a sharpening guided filter to enhance the edge quality and a Gaussian filter to remove noise, which can obtain a significant improvement in the detected edges [8] and so on. However, in general, the existing edge detection algorithms have problems such as poor anti-noise performance and sensitivity to noise [9]. Based on this, this paper proposes a Sobel-operator-based edge detection optimization algorithm. This algorithm uses a low-rank image denoising algorithm to improve the traditional edge detection algorithm. The experimental results verified that the proposed algorithm has better anti-noise performance and can obtain clear and continuous edge information under high noise levels, thus confirming the effectiveness of the algorithm.

Sobel Edge Detection Operator
The edge of an image is some continuous pixels in the image that have drastic changes in grayscale [10]. From the feature that the pixel at the edge of the image has the largest grayscale jump, the following information can be obtained: along the edge direction, the grayscale value changes slowly; perpendicular to the edge direction, the grayscale value jumps significantly. Based on this feature, the first-order derivative and the second-order derivative are usually used to detect edges. The Sobel operator is a typical first-order derivative edge operator, also known as a gradient edge operator [11].

Image Gradient
The partial derivative of the image f (x,y) at the point (x,y); that is, the gradient of the image at that point, can be expressed by the vector shown in Equation (3): its amplitude is: since the calculation amount of this equation is too large, Equation (5) is usually used as an approximate substitute: its direction is:

Sobel Operator
The Sobel operator uses Equation shown in (7) to calculate the image gradient: It can be seen that when using 8 surrounding pixels to estimate the central pixel gradient, the Sobel operator sets the weight of pixels in the neighborhood of the central pixel as 2 or −2 [12] to distinguish the influence of pixels of different distances on the central pixel, so as to make the edge contour more prominent and the detection and positioning more accurate.
After calculating the gradient of the center pixel, we only need to set a threshold value and compare the gradient with it. If the gradient of this point is greater than the threshold value, it is considered the edge point of the image. In the traditional Sobel operator, the threshold can be customized, or the average of the grayscale values of all pixels can be used as the threshold.
The Sobel operator can detect the edges of a noise-free image quickly and accurately; however, it is usual that the traditional Sobel operator wrongly marks the noise points as edges when it is used for edge detection of noisy images, resulting in low detection accuracy and a high error rate

WNNM Image Denoising Algorithm
The WNNM image denoising algorithm is a kind of low-rank matrix recovery algorithm. It uses the low-rank property of the image to recover the original image from the noisy image. In the WNNM denoising algorithm, the image is first divided into blocks with overlapping pixels. By exploiting the nonlocal self-similarity prior [13] to the image, many nonlocal similar patches can be searched across the whole image for a given patch. By stacking those nonlocal similar patches into a matrix, denoted by Y j , the noisy image can be regarded as the model shown in Equation (10): where V j represents the additive noise matrix, and X j represents the low-rank image to be restored. Therefore, the task of restoring the original image can be accomplished by solving the following inverse problem: Equation (11) is an NP problem [14], so the objective function needs to be relaxed. In 2009, Candès and Recht proved that the nuclear norm minimization (NNM) is a convex optimization of the rank function [15], so Equation (11) can be relaxed to the following problem:X where X j * is the nuclear norm, and λ is a positive number. The model can be solved in the following ways: Electronics 2021, 10, 655

of 14
The method is called the singular value threshold method (SVT), where Y j = U ∑ V T is the singular value decomposition of matrix Y j , and S λ (∑) is the soft threshold shrinkage of singular value ∑. This method has been widely used in many NNM-based problems [16]. However, this method shrinks all the singular values to the same degree, resulting in the loss of flexibility. For this reason, the concept of weight is introduced, and different singular values are given different weights [17]. Then, Equation (14) becomes: where c is a constant, n is the number of similar blocks in the block group and σ i (X j ) is the i-th singular value of X j . ε = 10 −16 , this is to avoid the situation that the denominator is 0. Since the singular value of X j is unknown, σ i (X j ) can be estimated by the following equation on the assumption that the noise energy is uniformly distributed in the noise space [18]:σ After the above processing for each block group, matrix X can be reconstructed; that is, the denoised image can be obtained.

Improved Sobel Edge Detection Operator
At present, several classical edge detection operators widely used in image processing technology mostly have performance defects that are very sensitive to noise [19]; even the presence of a small amount of noise will affect the detection results. Therefore, it is of great practical significance to improve the anti-noise performance of edge detection operators. Taking the Sobel operator as an example, this paper proposes an improvement scheme that can enhance the anti-noise performance of edge detection operators. The specific process is as follows: 1.
Dividing the noisy image into blocks. In order to eliminate the problem of seams when reconstructing an image, there needs to be some overlap between adjacent blocks. After block segmentation, similar image blocks are gathered according to the nonlocal similarity to form a low-rank matrix. The common criterion for judging whether blocks are similar is the Euclidean distance; that is, for blocks p i and p j , there is: where n represents the number of pixels in the block. The larger the value of D ij , the smaller the similarity between the two blocks, and vice versa.

2.
Mathematical modeling and solving the objective function. Using the low-rank characteristic of the matrix obtained in the previous step to perform WNNM mathematical modeling of the image denoising problem, and using the singular value threshold method to solve the objective function to obtain the denoised block groups.

3.
Reconstructing the image. In the process of reconstructing the image, due to the different selection of the center block of the block group, the same block may belong to multiple block groups at the same time, so it is necessary to average all the denoising results containing this block to get the final denoising result. Similarly, the averaging method is also used for the overlapping part between adjacent blocks to obtain a denoised complete image.

4.
Obtaining the edge pixels of the image. After WNNM denoising, the interference factors of edge detection are greatly reduced. At this time, the Sobel operator is used to calculate the grayscale difference approximation of the horizontal and vertical directions of each pixel in the image, and then the estimated gradient value is obtained. Finally, these gradient values are compared with the preset threshold, and the edge pixels of the image are those that exceed the threshold.

Experimental Results and Analysis
In order to verify the effectiveness of the algorithm in this paper, several images with a gray level of 256 and a BMP format are used for simulation experiments. The simulation software is MATLAB 2016a, and the running environment is the Windows 10 operating system with a 64-bit processor.
As a contrast, the Sobel edge detection algorithm based on WNNM denoising proposed in this paper, the traditional Sobel edge detection algorithm and the improved edge detection algorithm based on median filtering proposed in Reference [3] will be applied to the Cameraman image, respectively. The experimental results and analysis are listed as follows.
The first row in Figure 1 shows the detection results of the three algorithms when no noise is added. It can be seen that there is no significant difference in the performance of the three algorithms. The second to fourth rows show the detection results of the three algorithms after adding Gaussian noise with standard deviations of 30, 40 and 80 to the original image. It can be seen from the second and third rows that under the low and medium intensity noise levels, the traditional Sobel edge detection operator detects more noise points, while the median filter-based method proposed in [3] can eliminate most of the noise points, but it causes obvious damage to the real edges. By contrast, the algorithm proposed in this paper retains the true edge of the image to the greatest extent while eliminating the noise and achieves better detection results. Finally, this paper also selects high-intensity noise with a standard deviation of 80 for the experiment, and the experimental results are shown in the fourth row of Figure 1. At this time, the detection result of the traditional Sobel operator has been completely submerged in a large amount of noise, and the edge pixels cannot be distinguished. Similarly, after median filtering, the result of the algorithm in Reference [3] only has some isolated pixels, and both of them are difficult to achieve the purpose of extracting the edges of the image. The detection method in this paper can still obtain clear and relatively complete edges in this environment.
In addition, this paper also compares the mean square error (MSE), peak signal-tonoise ratio (PSNR) and structural similarity index metric (SSIM) of the three algorithms under different noise levels (Tables 1-3) and draws the corresponding line graphs for intuitive comparison (Figures 2-4); "sigma" in the graph represents the standard deviation of added noise. As can be seen from the chart, the edges detected by the algorithm in this paper obtain smaller MSE, larger PSNR and SSIM values compared with other algorithms at various noise levels in the experiment, and the MSE decreases by 0.0014-0.0532, the PSNR increases by 0.5090-4.0472 dB and the SSIM increases by 0.0230-0.5833. It is worth noting that when the standard deviation of Gaussian noise is 80, compared with the original algorithm and the algorithm proposed in Reference [3], the PSNR of the algorithm in this paper increases by 3.2243 and 1.6941 dB, respectively, and the SSIM increases by 0.5029 and 0.5762, respectively.
Combined with the previous qualitative analysis, it can be seen that the results detected by the algorithm in this paper have fewer noise points and more real edges, and the detection results are less affected by noise. Both the visual effect and objective evaluation index of the algorithm in this paper are superior to the traditional Sobel operator and the algorithm in Reference [3], indicating that the proposed algorithm has stronger anti-noise Electronics 2021, 10, 655 6 of 14 performance, and the superiority of the algorithm in this paper is more obvious in the high-noise environment.
noise points, while the median filter-based method proposed in [3] can eliminate most of the noise points, but it causes obvious damage to the real edges. By contrast, the algorithm proposed in this paper retains the true edge of the image to the greatest extent while eliminating the noise and achieves better detection results. Finally, this paper also selects highintensity noise with a standard deviation of 80 for the experiment, and the experimental results are shown in the fourth row of Figure 1. At this time, the detection result of the traditional Sobel operator has been completely submerged in a large amount of noise, and the edge pixels cannot be distinguished. Similarly, after median filtering, the result of the algorithm in Reference [3] only has some isolated pixels, and both of them are difficult to achieve the purpose of extracting the edges of the image. The detection method in this paper can still obtain clear and relatively complete edges in this environment. In addition, this paper also compares the mean square error (MSE), peak signal-tonoise ratio (PSNR) and structural similarity index metric (SSIM) of the three algorithms under different noise levels (Tables 1-3) and draws the corresponding line graphs for intuitive comparison (Figures 2-4); "sigma" in the graph represents the standard deviation of added noise. As can be seen from the chart, the edges detected by the algorithm in this paper obtain smaller MSE, larger PSNR and SSIM values compared with other algorithms at various noise levels in the experiment, and the MSE decreases by 0.0014-0.0532, the PSNR increases by 0.5090-4.0472 dB and the SSIM increases by 0.0230-0.5833. It is worth                     Similarly, in terms of visual effects, when Gaussian noise with standard deviations of 30 and 40 are added, compared with the traditional Sobel edge detection algorithm, there are fewer noise points in the detection results of the proposed algorithm, which indicates that the proposed algorithm has a stronger anti-noise performance. Compared with the algorithm in Reference [3], the edge detection results obtained by the proposed algorithm are clearer and more continuous, indicating that the proposed algorithm can preserve image edges better. In terms of objective evaluation indicators, the MSE of the proposed algorithm decreases by 0.0063-0.0800, the PSNR increases by 1.4580-4.2517 dB and the SSIM increases by 0.0287-0.5262. With the increase of noise intensity, the competitiveness of the algorithm in this paper is stronger.
The edge detection results of the MIT image are as follows: Figure 9 shows the detection results of the tested algorithms under different noise levels. Tables 7-9 show the values of MSE, PSNR, and SSIM of the tested algorithms, and Figures 10-12 are the corresponding line graphs, respectively. Similarly, in terms of visual effects, when Gaussian noise with standard deviations of 30 and 40 are added, compared with the traditional Sobel edge detection algorithm, there are fewer noise points in the detection results of the proposed algorithm, which indicates that the proposed algorithm has a stronger anti-noise performance. Compared with the algorithm in Reference [3], the edge detection results obtained by the proposed algorithm are clearer and more continuous, indicating that the proposed algorithm can preserve image edges better. In terms of objective evaluation indicators, the MSE of the proposed algorithm decreases by 0.0063-0.0800, the PSNR increases by 1.4580-4.2517 dB and the SSIM increases by 0.0287-0.5262. With the increase of noise intensity, the competitiveness of the algorithm in this paper is stronger.
The edge detection results of the MIT image are as follows: Figure 9 shows the detection results of the tested algorithms under different noise levels. Tables 7-9 show the values of MSE, PSNR, and SSIM of the tested algorithms, and Figures 10-12 are the corresponding line graphs, respectively.
In this experiment, compared with the other algorithms listed, the MSE of the proposed algorithm decreases by 0.0138-0.0633, the PSNR increases by 1.5558-4.2135 dB and the SSIM increases by 0.0663-0.3909.
The above experiments show that the proposed algorithm can effectively eliminate the influence of noise on edge detection and can retain the true edge of the image to a greater extent. The detection results are superior to other algorithms listed in this paper in terms of visual effect and objective evaluation index. The results are highly consistent after many comparative experiments.             In this experiment, compared with the other algorithms listed, the MSE of the proposed algorithm decreases by 0.0138-0.0633, the PSNR increases by 1.5558-4.2135 dB and the SSIM increases by 0.0663-0.3909.
The above experiments show that the proposed algorithm can effectively eliminate the influence of noise on edge detection and can retain the true edge of the image to a greater extent. The detection results are superior to other algorithms listed in this paper in terms of visual effect and objective evaluation index. The results are highly consistent after many comparative experiments.

Conclusions
The conventional Sobel edge detection operator can quickly and accurately extract the edge pixels of an image, which has been widely used in various image processing fields. However, when there is noise in the image, there will be many noise points in the detection results, which will affect the subsequent processing. In response to this problem, this paper proposes an improved algorithm, which combines WNNM image denoising with Sobel edge detection and utilizes the stable and excellent denoising ability of the WNNM image denoising algorithm at various noise levels to achieve the purpose of improving the anti-noise performance of the Sobel operator. The experimental results verify the effectiveness of the algorithm.
Compared with the conventional Sobel edge detection operator, the running time of the improved algorithm proposed in this paper increased. When Gaussian noise with a standard deviation of 20 is added, the running time of the three algorithms is showed in the Table 10 as follow: The algorithm in this paper improves the anti-noise performance of the Sobel operator, and at the same time, the running time of the algorithm also increases to a certain extent. Improving the anti-noise performance of the operator and the running speed of the algorithm at the same time remains to be further studied.

Conclusions
The conventional Sobel edge detection operator can quickly and accurately extract the edge pixels of an image, which has been widely used in various image processing fields. However, when there is noise in the image, there will be many noise points in the detection results, which will affect the subsequent processing. In response to this problem, this paper proposes an improved algorithm, which combines WNNM image denoising with Sobel edge detection and utilizes the stable and excellent denoising ability of the WNNM image denoising algorithm at various noise levels to achieve the purpose of improving the anti-noise performance of the Sobel operator. The experimental results verify the effectiveness of the algorithm.
Compared with the conventional Sobel edge detection operator, the running time of the improved algorithm proposed in this paper increased. When Gaussian noise with a standard deviation of 20 is added, the running time of the three algorithms is showed in the Table 10 as follow: The algorithm in this paper improves the anti-noise performance of the Sobel operator, and at the same time, the running time of the algorithm also increases to a certain extent. Improving the anti-noise performance of the operator and the running speed of the algorithm at the same time remains to be further studied.