2D image edge detection enhancement using convolutional neural network

Research Article
Open access

2D image edge detection enhancement using convolutional neural network

Gaoming Lin 1*
  • 1 University of Florida, Gainesville FL 32611, USA    
  • *corresponding author gaominglins@gmail.com
Published on 22 March 2023 | https://doi.org/10.54254/2755-2721/2/20220519
ACE Vol.2
ISSN (Print): 2755-273X
ISSN (Online): 2755-2721
ISBN (Print): 978-1-915371-19-5
ISBN (Online): 978-1-915371-20-1

Abstract

Traditional edge detection operators are usually applied on edge detection in 2D image processing. However, the edge detection system equipped with simple operators has many disadvantages, such as high sensitivity to noise and neglect of significant edge details. This work proposed a method to enhance edge detection with convolutional neural net-work. To overcome the shortcomings of the system using simple edge detection operators in 2D image processing, an edge detection system using convolutional neural network was developed with Python language. In the convolutional neural network, two convolutional layers were designed to extract 2D image features that were relative to edge information. Then a normalization layer was applied to normalize the convoluted output. After that, pre-processing was utilized to denoise and smooth the image input. The final step was edge detection using traditional operators. Experiments were also implemented to verify the improvement of the plugin of the three-layer convolutional neural network in the de-signed edge detection system. Relative frequencies were utilized to quantify the edge de-tection performance. Results showed that the involvement of convolutional neural net-work could strengthen edge detection operators’ performance obviously in computer vi-sion.

Keywords:

edge detection, convolutional neural network, image processing, computer vision

Lin,G. (2023). 2D image edge detection enhancement using convolutional neural network. Applied and Computational Engineering,2,1-8.
Export citation

1. Introduction

In 2D image processing, edge detection is a fundamental tool for object identification. Edges are characterized by the significant changes in image pixel brightness, or special pixels with discontinuities. Edges contain vital information of 2D images, as they define the boundaries between regions in 2D images, which contribute to segmentation and object recognition in 2D image processing and machine learning [1]. Based on direction, there are three types of common edges in digital images: horizontal edges, vertical edges, and diagonal edges. Generally, an edge detection method will detect two or three types of edges separately and treat them with mathematical processes for more accurate detection results. Fig.1 shows the edge detection results of hand-painted geometric patterns. The handwriting tracks of patterns, which are not obvious in the original image, have also been detected.

/word/media/image1.png

Figure 1. A example of edge detection in 2D image.

There are many edge detection methods that can be classified into three categories based on the derivatives they apply. The first category is gradient-based methods, also named as search-based methods. These methods calculate first-order derivatives or gradient magnitude for edge detection. The Robert cross operator, the Prewitt operator, and the Sobel operator are commonplace gradient-based methods. The Robert cross operator is first proposed by Lawrence Roberts in 1963. It is one of the simplest operators in edge detection, but its results are usually unreliable due to its small kernels. The Sobel operator is a discrete differentiation operator, named after Irwin Sobel and Gary Feldman at the Stanford Artificial Intelligent Laboratory in 1968 [2]. The Sobel operator places a proper estimation to the first-order derivatives, making it simpler compared with other edge detection operators. Therefore, Sobel operator is popular among artificial intelligent systems with limited computational ability. G. Chaple and R. D. Daruwala integrated Sobel operator-based image edge detection in low-cost field-programmable gate array (FPGA) devices of intelligent transport system, autonomous vehicles, and self-guided armaments etc. [3]. The Prewitt operator was developed by Judith M. S. Prewitt in 1970 [4]. The Prewitt operator shares many similarities with the Sobel operator. The Prewitt operator utilizes a compact filter to convolve the 2D image in horizontal and vertical directions. The Prewitt operator is also applied to edge detection with cost-efficient hardware. Nguyen et al. presented cost-efficient hardware co-simulation with Prewitt operator-based algorithm [5].

The second category is zero-crossing based methods. These methods look for pixels where a 2D image’s Laplacian value passes through zero, during which second-order derivatives are applied. The typical zero-crossing based method is Laplacian operator. Compared with gradient-based methods, the Laplacian operator has better edge localization. Bansal et al. used Laplacian operator and Open-CV for blur image detection [6].

The third category is optimal methods. These methods are optimized by several criteria for applications under noisy conditions. One of the most well-known optimal methods is the Canny operator. The Canny operator is an optimal method proposed by John Canny in 1986 [7]. The Canny operator has been optimized by three vital criteria: SNR criterion, localization precision criterion and single edge response criterion. As a result, the Canny operator has good edge detection performance under noisy conditions, and it has been widely applied in image processing. Compared with common edge detection algorithms, in most cases, the Canny algorithm has better performance [8-9]. Nevertheless, the traditional Canny operators’ edge detection accuracy can hardly meet higher and higher requirement of modern applications. Researchers tried many efforts to improve Canny operator. Deng et al. developed an improved Canny operator that can make selection of variance of Gaussian filtering for higher detection accuracy [10].

There are also some advanced edge detection methods, such as phased congruency-based methods, an edge detection approach in frequency domain. But these methods will lead to larger computational load, compared with the three categories of edge detection methods mentioned above.

The convolutional neural network (CNN) is a kind of biologically inspired artificial neural network for visual image analysis [11]. A convolutional neural network has three parts: an input layer, several hidden layers, and an output layer. CNN hidden layers contain convolutional layers, pooling layers, fully connected layers, and normalization layers. A convolutional layer is a kernel to extract certain features and reduce image dimensionality. A pooling layer is another kernel which can also reduce image dimensionality. Furthermore, a pooling layer can extract dominate features. A fully connected layer plays a role as classification. A normalization layer, which is optional, standardizes the data and accelerates training.

The convolutional neural network is one of the most popular topics in 2D image processing because of its efficiency in the object identification and prediction. During edge detection, the convolutional neural network can identify the pixels that belong to edges and predict edge positions, which are beneficial to detection accuracy.

This work tries to utilize convolutional neural network to enhance different edge detection methods for 2D images. An overview of the edge detection system is provided at first. Then the experiments are implemented and the results are shown, along with some discussion. Finally, some conclusions are synthesized.

2. Edge detection system

An edge detection system using convolutional neural network was developed, as shown in fig.2. Firstly, the designed convolutional neural network implemented image processing on the input original image (a classical image: Pepper.tiff), extracting important features that were useful for edge detection. Secondly, denoising or smoothing operations was applied as pre-processing step to enhance feature extraction, which was optional in the system. Finally, a simple edge detection operator (Canny, Laplacian, Sobel, or Prewitt) was utilized to output 2D image edge information.

/word/media/image2.png

Figure 2. An overview of the edge detection system.

2.1. Convolutional neural network

The convolutional neural network in the designed edge detection system had three-layer structure: two convolutional layers and one normalization layer, in which a 3x3 kernel and a 5x5 kernel were utilized. The main function of the convolutional neural network was to extract edge-related features in 2D images.

2.2. Pre-processing

The output of convolutional neural network might contain noise and inaccurate edge pixels [12]. As a result, denoising and smoothing operations should be implemented as a pre-processing step, granting a simpler and more reliable input for edge detection operators in next step.

2.3. Edge detection operator

There are many edge detection operators can be used in edge detection system. A comparison among four edge detection operators (Canny, Laplacian, Sobel, and Prewitt) was performed.

2.3.1. Canny operator. There are three complex steps in the Canny edge detection: Gaussian convolution smoothing, differentiation, and non-maximum suppression, accounting for Canny operator’s time consuming compared to gradient-based methods or zero-crossing based methods. Two thresholds are applied in a Canny operator. The lower and the higher thresholds are T1 and T2, respectively. The pixels with magnitudes above T2 are regarded as edge components, while the pixels, whose magnitudes are below T1, have no contribution to edge. As for pixels with magnitudes between T1 and T2, they are referred to as a part of edge only when they have direct connections with a magtitude-above-T2 pixel [13]. The Canny edge detection provides better edge detection, better localization and direct response [14-15]. For Canny operators in this work, T1 was set to 110 and T2 was set to 220 for all experiments.

2.3.2. Laplacian operator. The Laplacian operator, a zero-crossing based operator, relies on a certain edge classification rather than edge XY direction in 2D image edge detection. There are two kinds of edges: outward and inward edges, resulting in two kinds of Laplacian operators, as shown in Fig.3, positive Laplacian operators and negative Laplacian operators, respectively.

/word/media/image3.png

Figure 3. Two kinds of Laplacian Operators.

2.3.3. Sobel operator. The Sobel operator detects horizontal and vertical edges with Sobel Gx operator and Sobel Gy operator, receptively. The operators shown in Fig.4 are the standard Sobel Gx and Gy. According to practical requirement, more or less weight can be applied on Gx and Gy. For example, 2 and -2 can be changed to 5 and -5, respectively.

/word/media/image4.png

Figure 4. Two kinds of Sobel Operators.

2.3.4. Prewitt operator. The Prewitt operator is similar to the Sobel operator, but has more limitations due to its fixed coefficients. The Prewitt operator should have a sum equal to zero. Therefore, it is impossible to adjust this method to meet users’ requirements. Usually, Sobel and Prewitt operators are used to detect objects, but they are not recommended owing to their high noise sensitivity, resulting in compromised accuracy [16].

/word/media/image5.png

Figure 5. Two kinds of Prewitt Operators.

3. Materials and methods

3.1. Hardware and software

The experiments were implemented with Python language in software PyCham CE on MacOS Big Sur computer system. The samples used in the experiments was the classical image, Lena.tiff.

3.2. Experiment design

The Canny operator, Laplacian operator, Sobel operator, and Prewitt operator were tested in the designed edge detection system for the best performance. Serving as a control group, these four operators were also applied directly on original images for their results without enhancement of the convolutional neural network.

3.3. Evaluation method

Because of the ground truth reference’s absence, it was difficult to calculate accuracy of results directly. Therefore, relative frequencies of different results were considered as an evaluation parameter for different systems’ performances. The evaluation code was written with Python. Quality of edge detection plays a very important role in the focused area selection, image segmentation and object recognition [17].

4. Results and discussion

The detection results of the experiment on Lena.tiff are shown in Fig.6. The images in the first row are the control group’s edges without convolutional neural network (CNN). The images in the second row are edges detected by the designed edge detection system. In the calculation of the images in different groups, the same operators were used with identified parameters.

/word/media/image6.png

Figure 6. The results of the experiment on Lena.tiff.

Through the comparison of the edge results using same operators, the Canny operator had best performance either without or with convolutional neural network, as Canny edge detection’s results had the clearest edge of the woman and the least noise. Through line to line comparison, many edge details, such as the woman’s chin and the decoration on her hat, had been lost in Canny edge detection’s results without CNN while edges detected by Canny operators with CNN could preserve these important details. Laplacian edge detection’s results without CNN had similar problems: the information of the woman’s nose was missing while Laplacian edge detection’s results with CNN showed a better shape of the woman facial features. Sobel edge detection’s results without CNN contained too much noise, so the edge of the women was not clear while Sobel edge detection’s results with CNN got rid of this problem. Prewitt edge detection’s results without CNN was too sharp compared with Prewitt edge detection’s results with CNN. To sum up, the CNN could enhance edge detection performance.

The relative frequencies (R) between results of the control group and the designed edge detection system are shown in Tables 1 and 2, respectively. The relative frequencies can represent the relationship between different edges detected by different operators, which can serve as an alternative evaluation of edge detection qualities quantitatively at the absence of ground truth references. Higher relative frequencies means higher edge detection qualities.

Table 1. Relative frequencies between different edge detection operators’ results without CNN.

Operator

Canny

Laplacian

Sobel

Prewitt

Canny

1

0.77348

0.57788

0.75519

Laplacian

0.77348

1

0.52482

0.62874

Sobel

0.57788

0.52482

1

0.63625

Prewitt

0.75519

0.62874

0.63625

1

Average R

0.77664

0.73176

0.68474

0.75505

Table 2. Relative frequencies between different edge detection operators’ results with CNN.

Operator

Canny

Laplacian

Sobel

Prewitt

Canny

1

0.92533

0.86702

0.90452

Laplacian

0.92533

1

0.88753

0.91562

Sobel

0.86702

0.88752

1

0.85505

Prewitt

0.90452

0.91562

0.85505

1

Average R

0.92422

0.93212

0.90240

0.91880

The quantitative evaluation using relative frequencies in Table 1 shows the Canny operators have the best performance, and the Prewitt operators’ performance is little worse. The third best is the Laplacian operators’s performance. The Sobel operators have the worst performance. While in Table 2, the Laplacian operators had the best edge detection performance. Based on the comparison of these two tables, it can be concluded that the CNN increased relative frequencies dramatically of all operators, so the qualities of edges were improved.

5. Conclusion

This work developed an edge detection system using CNN. In this system, a CNN with two convolutional layers and one normalization layer were utilized for edge-related feature extraction. Then a pre-process was applied to denoise and smooth convoluted outputs. Finally pre-processed images were treated by edge detection operators (Canny, Laplacian, Sobel, and Prewitt). Compare with the results using a simple edge detection operator, the system with CNN showed a higher edge detection quality, according to edge detection results and their quantitative evaluation based on relative frequencies. What’s more, the designed edge detection system had easy-to-use structure that could be implemented and integrated in various 2D image processing applications.


References

[1]. D. R. Waghule and R. S. Ochawar, "Overview on Edge Detection Methods," 2014 International Conference on Electronic Systems, Signal Processing and Computing Technologies, 2014, pp. 151-155, doi: 10.1109/ICESC.2014.31.

[2]. Sobel, Irwin. (2014). An Isotropic 3x3 Image Gradient Operator. Presentation at Stanford A.I. Project 1968.

[3]. G. Chaple and R. D. Daruwala, "Design of Sobel Operator Based image Edge Detection Algorithm on FPGA," 2014 International Conference on Communication and Signal Processing, 2014, pp. 788-792, doi: 10.1109/ICCSP.2014.6949951.

[4]. J. M. S. Prewitt, “Object Enhancement and Extraction,” Picture Processing and Psychopictorics, B. Lipkin and A. Rosenfeld, Eds., New York: Academic Press, 1970, pp. 75-149.

[5]. P. Nguyen, J. Cho and S. B. Cho, "An Architecture for Real-time Hardware Co-simulation of Edge Detection in Image Processing using Prewitt edge operator” 2014 International Conference on Electronics, Information and Communications (ICEIC), 2014, pp. 1-2, doi: 10.1109/ELINFOCOM.2014.6914387.

[6]. R. Bansal, G. Raj and T. Choudhury, "Blur Image Detection Using Laplacian Operator and Open-CV," 2016 International Conference System Modeling & Advancement in Research Trends (SMART), 2016, pp. 63-67, doi: 10.1109/SYSMART.2016.7894491.

[7]. J. Canny, "A Computational Approach to Edge Detection," in IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. PAMI-8, no. 6, pp. 679-698, Nov. 1986, doi: 10.1109/TPAMI.1986.4767851.

[8]. F. A. Pellegrino. “Edge Detection Revisited,” IEEE Trans on System Man and Cybernetics, vol.34, no.3, pp. 1500-1517, 2004.

[9]. T. B. Nguyen,D Ziou. “Contextual and Non-contextual Performance Evaluation of Edge detectors,” Pattern Recognition Letters, vol.21 no.8, pp.805-816,2000

[10]. Cai-Xia Deng, Gui-Bin Wang and Xin-Rui Yang, "Image Edge Detection Algorithm Based on Improved Canny Operator," 2013 International Conference on Wavelet Analysis and Pattern Recognition, 2013, pp. 168-172, doi: 10.1109/ICWAPR.2013.6599311.

[11]. Masakazu Matsugu, Katsuhiko Mori, Yusuke Mitari, Yuji Kaneda, “Subject Independent Facial Expression Recognition with Robust Face Detection Using a Convolutional Neural Network” Neural Networks, Volume 16, Issues 5–6, 2003, pp. 555-559, doi: 10.1016/S0893-6080(03)00115-1.

[12]. J. J. Lim, C. L. Zitnick and P. Dollár, "Sketch Tokens: A Learned Mid-level Representation for Contour and Object Detection" 2013 IEEE Conference on Computer Vision and Pattern Recognition, 2013, pp. 3158-3165, doi: 10.1109/CVPR.2013.406.

[13]. Juneja, Mamta & Sandhu, Parvinder. (2009). Performance Evaluation of Edge Detection Techniques for Images in Spatial Domain. International Journal. 1. 614-621. 1

[14]. S. Yaman, M. Yildrim, B. Karmşhoğlu, Y. Erol and H. Kürüm, "Image and Video Processing Applications Using Xilinx System Generator," 2019 7th International Symposium on Digital Forensics and Security (ISDFS), 2019, pp. 1-5, doi: 10.1109/ISDFS.2019.8757540.

[15]. L. Yuan and X. Xu, "Adaptive Image Edge Detection Algorithm Based on Canny Operator," 2015 4th International Conference on Advanced Information Technology and Sensor Application (AITS), 2015, pp. 28-31, doi: 10.1109/AITS.2015.14.

[16]. Aisha Baloch, Tayab D. Memon, Farida Memon, Bharat Lal, Ved Viyas and Tony Jan, “Hardware Synthesize and Performance Analysis of Intelligent Transportation Using Canny Edge Detection Algorithm” I. J. Engineering and Manufacturing, 2021, 4, 22-32, DOI: 10.5815/ijem.2021.04.03

[17]. G. Baraskar and P. Thakre, “Evaluation of Canny and Sobel Edge Detection Technique using Xilinx System Generator,” vol. 2, no. 2, pp. 53–56, 2017, [Online]. Available: http://ijsrst.com/paper/872.pdf.


Cite this article

Lin,G. (2023). 2D image edge detection enhancement using convolutional neural network. Applied and Computational Engineering,2,1-8.

Data availability

The datasets used and/or analyzed during the current study will be available from the authors upon reasonable request.

Disclaimer/Publisher's Note

The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of EWA Publishing and/or the editor(s). EWA Publishing and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

About volume

Volume title: Proceedings of the 4th International Conference on Computing and Data Science (CONF-CDS 2022)

ISBN:978-1-915371-19-5(Print) / 978-1-915371-20-1(Online)
Editor:Alan Wang
Conference website: https://www.confcds.org/
Conference date: 16 July 2022
Series: Applied and Computational Engineering
Volume number: Vol.2
ISSN:2755-2721(Print) / 2755-273X(Online)

© 2024 by the author(s). Licensee EWA Publishing, Oxford, UK. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license. Authors who publish this series agree to the following terms:
1. Authors retain copyright and grant the series right of first publication with the work simultaneously licensed under a Creative Commons Attribution License that allows others to share the work with an acknowledgment of the work's authorship and initial publication in this series.
2. Authors are able to enter into separate, additional contractual arrangements for the non-exclusive distribution of the series's published version of the work (e.g., post it to an institutional repository or publish it in a book), with an acknowledgment of its initial publication in this series.
3. Authors are permitted and encouraged to post their work online (e.g., in institutional repositories or on their website) prior to and during the submission process, as it can lead to productive exchanges, as well as earlier and greater citation of published work (See Open access policy for details).

References

[1]. D. R. Waghule and R. S. Ochawar, "Overview on Edge Detection Methods," 2014 International Conference on Electronic Systems, Signal Processing and Computing Technologies, 2014, pp. 151-155, doi: 10.1109/ICESC.2014.31.

[2]. Sobel, Irwin. (2014). An Isotropic 3x3 Image Gradient Operator. Presentation at Stanford A.I. Project 1968.

[3]. G. Chaple and R. D. Daruwala, "Design of Sobel Operator Based image Edge Detection Algorithm on FPGA," 2014 International Conference on Communication and Signal Processing, 2014, pp. 788-792, doi: 10.1109/ICCSP.2014.6949951.

[4]. J. M. S. Prewitt, “Object Enhancement and Extraction,” Picture Processing and Psychopictorics, B. Lipkin and A. Rosenfeld, Eds., New York: Academic Press, 1970, pp. 75-149.

[5]. P. Nguyen, J. Cho and S. B. Cho, "An Architecture for Real-time Hardware Co-simulation of Edge Detection in Image Processing using Prewitt edge operator” 2014 International Conference on Electronics, Information and Communications (ICEIC), 2014, pp. 1-2, doi: 10.1109/ELINFOCOM.2014.6914387.

[6]. R. Bansal, G. Raj and T. Choudhury, "Blur Image Detection Using Laplacian Operator and Open-CV," 2016 International Conference System Modeling & Advancement in Research Trends (SMART), 2016, pp. 63-67, doi: 10.1109/SYSMART.2016.7894491.

[7]. J. Canny, "A Computational Approach to Edge Detection," in IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. PAMI-8, no. 6, pp. 679-698, Nov. 1986, doi: 10.1109/TPAMI.1986.4767851.

[8]. F. A. Pellegrino. “Edge Detection Revisited,” IEEE Trans on System Man and Cybernetics, vol.34, no.3, pp. 1500-1517, 2004.

[9]. T. B. Nguyen,D Ziou. “Contextual and Non-contextual Performance Evaluation of Edge detectors,” Pattern Recognition Letters, vol.21 no.8, pp.805-816,2000

[10]. Cai-Xia Deng, Gui-Bin Wang and Xin-Rui Yang, "Image Edge Detection Algorithm Based on Improved Canny Operator," 2013 International Conference on Wavelet Analysis and Pattern Recognition, 2013, pp. 168-172, doi: 10.1109/ICWAPR.2013.6599311.

[11]. Masakazu Matsugu, Katsuhiko Mori, Yusuke Mitari, Yuji Kaneda, “Subject Independent Facial Expression Recognition with Robust Face Detection Using a Convolutional Neural Network” Neural Networks, Volume 16, Issues 5–6, 2003, pp. 555-559, doi: 10.1016/S0893-6080(03)00115-1.

[12]. J. J. Lim, C. L. Zitnick and P. Dollár, "Sketch Tokens: A Learned Mid-level Representation for Contour and Object Detection" 2013 IEEE Conference on Computer Vision and Pattern Recognition, 2013, pp. 3158-3165, doi: 10.1109/CVPR.2013.406.

[13]. Juneja, Mamta & Sandhu, Parvinder. (2009). Performance Evaluation of Edge Detection Techniques for Images in Spatial Domain. International Journal. 1. 614-621. 1

[14]. S. Yaman, M. Yildrim, B. Karmşhoğlu, Y. Erol and H. Kürüm, "Image and Video Processing Applications Using Xilinx System Generator," 2019 7th International Symposium on Digital Forensics and Security (ISDFS), 2019, pp. 1-5, doi: 10.1109/ISDFS.2019.8757540.

[15]. L. Yuan and X. Xu, "Adaptive Image Edge Detection Algorithm Based on Canny Operator," 2015 4th International Conference on Advanced Information Technology and Sensor Application (AITS), 2015, pp. 28-31, doi: 10.1109/AITS.2015.14.

[16]. Aisha Baloch, Tayab D. Memon, Farida Memon, Bharat Lal, Ved Viyas and Tony Jan, “Hardware Synthesize and Performance Analysis of Intelligent Transportation Using Canny Edge Detection Algorithm” I. J. Engineering and Manufacturing, 2021, 4, 22-32, DOI: 10.5815/ijem.2021.04.03

[17]. G. Baraskar and P. Thakre, “Evaluation of Canny and Sobel Edge Detection Technique using Xilinx System Generator,” vol. 2, no. 2, pp. 53–56, 2017, [Online]. Available: http://ijsrst.com/paper/872.pdf.