Using Convolutional Neural Networks and Pattern Matching for Digitization of Printed Circuit Diagrams
Abstract
1. Introduction
2. Description of Data
3. Methods
3.1. Text Removal and Dashed Line Connection
3.2. Object Detection
3.3. Line Detection and Clustering
- Line detection algorithm. For detecting horizontal lines, we use a horizontal opening operation [33], i.e., any foreground pixel which is not included in the union of all sets of k horizontally consecutive foreground pixels is replaced with a background pixel. For vertical lines, a similar vertical opening is performed, where the number k must be chosen as the pixel length of the shortest line to detect. We set for horizontal lines and for vertical lines, where denotes the width and height of the input image, respectively, and is the largest integer smaller than or equal to . While this method is not suitable for detecting curved or significantly inclined lines, thus possibly requiring additional preprocessing, it prevents the detection of false positives and is efficiently computable, using convolution. As will be shown, this approach performs reasonably well on synthetic and measured validation data.
- Classification of line crossings. To derive the connectivity information of wires, it remains to cluster the family of detected lines into connected components. For this, it is important to note that there is a variety of junction styles, with different meanings, see Figure 2 and Figure 5. Thus, in the following, we employ another (small) CNN to determine the type of line crossings.
- Layers of the classification network. The convolutional layer in Equation (4) consists of 32 filters of size , whereas the convolutional layer consists of 64 filters of size . Both convolutional layers utilize a stride of 1 and no padding. Formally, for any integers and , a convolution layer is given by
- Training of network parameters. To train the parameters of the classification network S, i.e., the parameters of the convolutional layers and the linear layer, we generate synthetic training data consisting of pairs of image data and junction label. Thereby is a (binary) image of a junction, and represents the corresponding intersection class as one hot encoding, i.e., if and only if the intersection class of c is the i-th class. In total, we generate 500 samples for each of the 9 connection classes by applying random augmentations to the line crossings. More precisely, we apply random translations to the line coordinates by up to 3 pixels, and we modify the size of dot markings by uniformly drawing their radius from the interval . Furthermore, for all intersection classes, we add noise close to the foreground by switching any background pixel, having a pixel distance of less than one to foreground, into a foreground pixel with a probability of 0.03. Finally, we generate 1000 samples for the undefined class by randomly placing rectangles, triangles, and off-center lines to capture ambiguous cases. The network is then trained for multi-class classification using the categorical cross-entropy loss function given by
- Clustering of detected lines. First, cutouts containing pairs of possibly intersecting lines are determined, which will be classified by the network S given in Equation (4). Therefore, for each pair of detected lines, where A is a horizontal line and B is a vertical line, the pair of the closest pixel positions and is computed. If the distance between a and b is larger than 25 pixels, the lines A and B are considered as non-intersecting. Otherwise, a cutout c centered at is computed, i.e., c is given by , where are the coordinates of . The network S is then used to determine whether the wires depicted in c are connected or not. For the remainder of this paper, by slight abuse of terminology, the term wire will denote a connected component of lines.
3.4. Connectivity Graph
4. Results
4.1. Quality of the U-Net Output
4.2. Synthetic Distortion of Input Images
- Varying magnitude of noise. For the analysis of the robustness of the noise, the test data were modified by changing each background pixel to a foreground pixel with a certain probability , while keeping all other parameters (scaling and gap size) constant. Figure 8a presents the resulting pipeline precision. Specifically, the metrics include the mean fraction of correctly classified foreground pixels in the ground truth image (orange), the mean fraction of correctly detected lines in the line detection step (blue), and the mean fraction of devices accurately identified in the pattern matching step (green; red). To evaluate the number of correctly identified lines and devices, these elements were manually labeled. A detected line was considered correct if its start and endpoint matched those of a labeled line within a tolerance of 10 pixels with respect to the maximum metric. Likewise, a device was classified as correctly detected if the intersection over union (see Equation (3)) between a detected template and the corresponding (pre-labeled) bounding box exceeded the value of 0.8, see Figure 6c,d.
- Effect of scaling. Similarly, to evaluate the effect of scaling, the same validation image was rendered at different resolutions ranging from 75 to 500 dpi, while keeping other distortion magnitudes unchanged. The results obtained in this case are shown in Figure 8b, where the performance of the pipeline decreases significantly at very low resolutions. For example, at 75 dpi, the pixel-wise error is still low; however, since lines are rendered with a width of just one pixel, device and line detection show a strong decrease in accuracy. Although 75 dpi is not a realistic resolution for most practical applications, since this corresponds to a line width of one pixel, we deliberately included these low-resolution cases to demonstrate the limits and stress-test the robustness of our pipeline under challenging conditions. Note that by simply synthetically increasing the resolution of such images before applying the U-net-based preprocessing, the quality of the result can be increased.
- Impact of gap size. Finally, the impact of gap size in dashed lines was studied. The validation image was modified to include dashed lines, where each line had a straight segment of 0.15 cm and gaps of size cm for some , with a probability of 0.5 for any given line being dashed. The parameter was varied within the range , see Figure 8c for the results obtained in this case. Note that the green line, corresponding to device detection, is omitted here because, as expected, variations in gap size do not have any notable effect on pattern matching quality. It can be observed that until the gap sizes are less than four times the length of the straight segment, the line detection quality remains unaffected.
4.3. Similarity of Graphs
4.4. Validation on Scanned Images
5. Discussion
6. Conclusions and Outlook
Author Contributions
Funding
Data Availability Statement
Conflicts of Interest
References
- Larick, S. Functional schematic diagrams. Proc. IRE 1946, 34, 1005–1007. [Google Scholar] [CrossRef]
- IEEE Std 315-1975 (Reaffirmed 1993); IEEE Standard for Graphic Symbols for Electrical and Electronics Diagrams (Including Reference Designation Letters). IEEE-SASB Coordinating Committees: Piscataway, NJ, USA, 1975; pp. 1–176. Available online: https://ieeexplore.ieee.org/document/8996120 (accessed on 16 July 2025).
- Garland, D.J.; Stainer, F.W. Modern Electronic Maintenance Principles; Elsevier: Amsterdam, The Netherlands, 2016. [Google Scholar]
- IEC 60617-DB; Graphical Symbols for Diagrams. International Electrotechnical Commission: Geneva, Switzerland, 2025.
- Mani, S.; Haddad, M.A.; Constantini, D.; Douhard, W.; Li, Q.; Poirier, L. Automatic digitization of engineering diagrams using deep learning and graph search. In Proceedings of the 2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops (CVPRW), Seattle, WA, USA, 14–19 June 2020; pp. 673–679. [Google Scholar]
- Li, X.; Liu, X. Optimizing parameter extraction in grid information models based on improved convolutional neural networks. Electronics 2024, 13, 2717. [Google Scholar] [CrossRef]
- Kelly, C.R.; Cole, J.M. Digitizing images of electrical-circuit schematics. APL Mach. Learn. 2024, 2, 016109. [Google Scholar] [CrossRef]
- Bayer, J.; Roy, A.K.; Dengel, A. Instance segmentation based graph extraction for handwritten circuit diagram images. arXiv 2023, arXiv:2301.03155. [Google Scholar]
- Ronneberger, O.; Fischer, P.; Brox, T. U-net: Convolutional networks for biomedical image segmentation. In Medical Image Computing and Computer-Assisted Intervention—MICCAI 2015: 18th International Conference, Munich, Germany, 5–9 October 2015, Proceedings, Part III 18; Springer: Cham, Switzerland, 2015; pp. 234–241. [Google Scholar]
- Du, G.; Cao, X.; Liang, J.; Chen, X.; Zhan, Y. Medical image segmentation based on U-net: A review. J. Imaging Sci. Technol. 2020, 64, 0710. [Google Scholar] [CrossRef]
- He, K.; Gkioxari, G.; Dollár, P.; Girshick, R. Mask R-CNN. In Proceedings of the 2017 IEEE International Conference on Computer Vision, Venice, Italy, 22–29 October 2017; pp. 2961–2969. [Google Scholar]
- Apostolico, A.; Galil, Z. Pattern Matching Algorithms; Oxford University Press: Oxford, UK, 1997. [Google Scholar]
- Diestel, R. Graph Theory; Springer: Berlin/Heidelberg, Germany, 2024. [Google Scholar]
- Open Source Hardware Park. Available online: https://oshpark.com/shared_projects/ (accessed on 16 July 2025).
- Charras, J.P.; Tappero, F.; Stambaugh, W. KiCad Complete Reference Manual; 12th Media Services: Suwanee, GA, USA, 2018. [Google Scholar]
- Zhang, Q.; Huang, V.S.J.; Wang, B.; Zhang, J.; Wang, Z.; Liang, H.; Wang, S.; Lin, M.; He, C.; Zhang, W. Document parsing unveiled: Techniques, challenges, and prospects for structured information extraction. arXiv 2024, arXiv:2410.21169. [Google Scholar]
- Zhang, Z.; Liu, Q.; Wang, Y. Road extraction by deep residual U-net. IEEE Geosci. Remote Sens. Lett. 2018, 15, 749–753. [Google Scholar] [CrossRef]
- Furat, O.; Kirstein, T.; Leißner, T.; Bachmann, K.; Gutzmer, J.; Peuker, U.A.; Schmidt, V. Multidimensional characterization of particle morphology and mineralogical composition using CT data and R-vine copulas. Miner. Eng. 2024, 206, 108520. [Google Scholar] [CrossRef]
- Alomar, K.; Aysel, H.I.; Cai, X. Data augmentation in classification and segmentation: A survey and new strategies. J. Imaging 2023, 9, 46. [Google Scholar] [CrossRef] [PubMed]
- Bock, S.; Goppold, J.; Weiß, M. An improvement of the convergence proof of the ADAM-Optimizer. arXiv 2018, arXiv:1804.10587. [Google Scholar]
- Brunelli, R. Template Matching Techniques in Computer Vision: Theory and Practice; John Wiley & Sons: Hoboken, NJ, USA, 2009. [Google Scholar]
- Bishop, C.M.; Nasrabadi, N.M. Pattern Recognition and Machine Learning; Springer: Berlin/Heidelberg, Germany, 2006. [Google Scholar]
- Redmon, J.; Divvala, S.; Girshick, R.; Farhadi, A. You only look once: Unified, real-time object detection. In Proceedings of the 2016 IEEE Conference on Computer Vision and Pattern Recognition, Las Vegas, NV, USA, 27–30 June 2016; pp. 779–788. [Google Scholar]
- Basu, J.K.; Bhattacharyya, D.; Kim, T. Use of artificial neural network in pattern recognition. Int. J. Softw. Eng. Appl. 2010, 4, 23–34. Available online: https://khaneprozhe.ir/wp-content/uploads/2024/02/Use_of_Artificial_Neural_Network_in_Pattern_Recogn.pdf (accessed on 16 July 2025).
- ANSI/IEEE Std 315A-1986; American National Standard—Supplement to Graphic Symbols for Electrical and Electronics Diagrams. IEEE: New York, NY, USA, 1986; pp. 1–64. [CrossRef]
- Woods, R.E.; Gonzalez, R.C. Digital Image Processing, 3rd ed.; Prentice Hall: Hoboken, NJ, USA, 2021. [Google Scholar]
- Neubeck, A.; Van Gool, L. Efficient non-maximum suppression. In Proceedings of the 18th International Conference on Pattern Recognition (ICPR’06), Hong Kong, China, 20–24 August 2006; Volume 3, pp. 850–855. [Google Scholar]
- Bradski, G. The OpenCV Library. Dr. Dobb’s J. Softw. Tools 2000, 25, 120–125. [Google Scholar]
- Kim, H.Y.; de Araújo, S.A. Grayscale template-matching invariant to rotation, scale, translation, brightness and contrast. In Advances in Image and Video Technology; Mery, D., Rueda, L., Eds.; Springer: Berlin/Heidelberg, Germany, 2007; pp. 100–113. [Google Scholar]
- Kim, J.; Kim, J.; Choi, S.; Hasan, M.A.; Kim, C. Robust template matching using scale-adaptive deep convolutional features. In Proceedings of the 2017 Asia-Pacific Signal and Information Processing Association Annual Summit and Conference (APSIPA ASC), Kuala Lumpur, Malaysia, 12–15 December 2017; pp. 708–711. [Google Scholar]
- Rublee, E.; Rabaud, V.; Konolige, K.; Bradski, G. ORB: An efficient alternative to SIFT or SURF. In Proceedings of the 2011 IEEE International Conference on Computer Vision, Barcelona, Spain, 6–13 November 2011; pp. 2564–2571. [Google Scholar]
- KiCad Symbols. Available online: https://gitlab.com/kicad/libraries/kicad-symbols/ (accessed on 18 July 2025).
- Dougherty, E. Mathematical Morphology in Image Processing; CRC Press: Boca Raton, FL, USA, 1992. [Google Scholar]
- Wu, Y.; Kirillov, A.; Massa, F.; Lo, W.Y.; Girshick, R. Detectron2. 2019. Available online: https://github.com/facebookresearch/detectron2 (accessed on 18 July 2025).
- Ren, S.; He, K.; Girshick, R.; Sun, J. Faster R-CNN: Towards real-time object detection with region proposal networks. In Advances in Neural Information Processing Systems; Cortes, C., Lawrence, N., Lee, D., Sugiyama, M., Garnett, R., Eds.; Curran Associates, Inc.: Red Hook, NY, USA, 2015; Volume 28. [Google Scholar]
- Lin, T.Y.; Dollár, P.; Girshick, R.; He, K.; Hariharan, B.; Belongie, S. Feature pyramid networks for object detection. In Proceedings of the 2017 IEEE Conference on Computer Vision and Pattern Recognition, Honolulu, HI, USA, 21–26 July 2017. [Google Scholar]
- Szeliski, R. Computer Bision: Algorithms and Applications; Springer: Berlin/Heidelberg, Germany, 2022. [Google Scholar]
- Lee, T.C.; Kashyap, R.L.; Chu, C.N. Building skeleton models via 3-D medial surface/axis thinning algorithms. CVGIP Graph. Model. Image Process. 1994, 56, 462–478. [Google Scholar] [CrossRef]
- Zhang, T.Y.; Suen, C.Y. A fast parallel algorithm for thinning digital patterns. Commun. ACM 1984, 27, 236–239. [Google Scholar] [CrossRef]
- Goodfellow, I. Deep Learning; MIT Press: Cambridge, MA, USA, 2016. [Google Scholar]
- 4lex4. ScanTailor Advanced. 2015. Available online: https://github.com/4lex4/scantailor-advanced (accessed on 3 July 2025).
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 MDPI and/or the editor(s). MDPI 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. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Fuchs, L.; Diesse, M.; Weber, M.; Rasim, A.; Feinauer, J.; Schmidt, V. Using Convolutional Neural Networks and Pattern Matching for Digitization of Printed Circuit Diagrams. Electronics 2025, 14, 2889. https://doi.org/10.3390/electronics14142889
Fuchs L, Diesse M, Weber M, Rasim A, Feinauer J, Schmidt V. Using Convolutional Neural Networks and Pattern Matching for Digitization of Printed Circuit Diagrams. Electronics. 2025; 14(14):2889. https://doi.org/10.3390/electronics14142889
Chicago/Turabian StyleFuchs, Lukas, Marc Diesse, Matthias Weber, Arif Rasim, Julian Feinauer, and Volker Schmidt. 2025. "Using Convolutional Neural Networks and Pattern Matching for Digitization of Printed Circuit Diagrams" Electronics 14, no. 14: 2889. https://doi.org/10.3390/electronics14142889
APA StyleFuchs, L., Diesse, M., Weber, M., Rasim, A., Feinauer, J., & Schmidt, V. (2025). Using Convolutional Neural Networks and Pattern Matching for Digitization of Printed Circuit Diagrams. Electronics, 14(14), 2889. https://doi.org/10.3390/electronics14142889