International Journal of Computer Applications (0975 – 8887)
Volume 87 – No.9, February 2014
PCB Defect Detection, Classification and Localization
using Mathematical Morphology and Image Processing
Tools
Malge P.S. Nadaf R.S.
Department of Electronics, Department of Electronics,
Walchand Institute of Technology, Solapur.413006 Walchand Institute of Technology, Solapur.413006
ABSTRACT defects, none is able to classify the defects.In a non contact
An automated visual printed circuit board (PCB) inspection reference based, image processing approaches template of a
is an approach used to counter difficulties occurred in defect free PCB image and a defected test PCB image are
human’s manual inspection that can eliminates subjective segmented and compared with each other using image
aspects and then provides fast, quantitative, and subtraction and other procedures.
dimensional assessments. Various concentrated work on This project utilizes a non contact reference based, image
detection of defects on printed circuit boards (PCBs) have processing approach for defect detection and classification
been done, but it is also crucial to classify these defects in and simple image processing algorithm for locating those
order to analyze and identify the root causes of the defects. defects on PCB board. A template of a defect free PCB
This project proposes a PCB defect detection and image and a defected test PCB image are segmented and
classification system using a morphological image compared with each other using image subtraction and
segmentation algorithm and simple the image processing other procedures. Discrepancies between the images are
theories. However, besides the need to detect the defects, it considered defects and are classified based on similarities
is also essential to classify and locate these defects so that and area of occurrences. After obtaining patterns
the source and location of these defects can be identified. concerning the results these are located on the PCB.
Based on initial studies, some PCB defects can only exist in
certain groups. Thus, it is obvious that the image This paper is organized as follows. Section 2 defines the
processing algorithm could be improved by applying a review of previous works and research methodology
segmentation exercise. This project uses template and test chosen for this project. Section 3 and describes the details
images of single layer, bare, grayscale computer generated of mathematical morphology for image segmentation and
PCBs. image processing algorithm for detection and classification
of PCB defects. Section 4 contains the experimental results
Keywords for defect detection and classification while the discussion
PCB panel, vision, image processing, segmentation and and conclusion is described in section 5.
Image Processing.
2. LITERATURE REVIEW
1. INTRODUCTION Bare printed circuit board (PCB) is a PCB without any
The PCB (printed circuit board) manufacturing is becoming placement of electronic components (Hong et al., 1998)
more and more important as the consumer electronics which is used along with other components to produce
products, such as mobile phones, tablet PCs, automatic electrics goods. In order to reduce cost spending in
washing machines and so on, are indispensable for our manufacturing caused by the defected bare PCB, the bare
everyday life. Visual inspection is generally the largest cost PCB must be inspected. Moganti et al. (1996) proposed
of PCB manufacturing. It is responsible for detecting both three categories of PCB inspection algorithms: referential
cosmetic and functional defects and attempts are often approaches, non-referential approaches, and hybrid
made to ensure 100% quality assurance for all finished approaches.
products. There are three main processes in PCB
inspection: defect detection, defect classification and defect Referential approaches consist of image
location. Currently there are many algorithms developed comparison and model-based technique.
for PCB defect detection and classification using contact or Non-referential approaches or design-rule
noncontact methods [3]. Contact method tests the verification methods are based on the verification
connectivity of the circuit but is unable to detect major of the general design rules that is essentially the
flaws in cosmetic defects such as mouse-bite or spurious verification of the widths of conductors and
copper and is very setup-sensitive [12]. Any misalignment insulators.
can cause the test to fail completely. Hybrid approaches involve a combination both of
Non contact methods can be from a wide range of selection the referential and the non-referential approaches.
from x-ray imaging, ultrasonic imaging, thermal imaging
and optical inspection using image processing [5 - 6]. These PCB inspection approaches mainly concentrated on
Although these techniques are successful in detecting defects detection (Moganti et al., 1996). However, defects
40
International Journal of Computer Applications (0975 – 8887)
Volume 87 – No.9, February 2014
detection did not provide satisfactory information for Table 1. Defect On Single Layer Bare PCB
repairing and quality control work, since the type of
detected defects cannot be clearly identified. Based on this
No Defect Name
incapability of defects detection, defect classification
operation is needed in PCB inspection. Therefore, an 1 Breakout
accurate defect classification procedure is essential 2 Pin hole
especially for an on-line inspection system during PCB 3 Open circuit
production process.
4 Under etch
Human operators simply inspect visually against prescribed 5 Mouse-bite
standards. The decisions made by them often involve 6 Missing conductor
subjective judgment, in addition to being labor intensive 7 Spur
and therefore costly, whereas automatic inspection systems
remove the subjective aspects and provide fast, quantitative 8 Short
dimensional assessments. Due to the following criteria, the 9 Wrong size hole
sophistication in automated visual inspection has become a 10 Conductor too close
part of the modern manufacturing environment. 11 Spurious copper
They relieve human inspectors of the tedious jobs
12 Excessive short
involved.
Manual inspection is slow, costly, leads to 13 Missing hole
excessive scrap rates, and does not assure high 14 Over etch
quality.
Multi-layer boards are not suitable for human
eyes to inspect.
With the aid of a magnifying lens, the average
fault- finding rate of a human being is about90%.
However, on multi-layered boards (say 6
layered), the rate drops to about 50%. Even with
fault free power and ground layers, the rate does
not exceed 70% [9].
Industry has set quality levels so high that
sampling inspection is not applicable.
Production rates are so high that manual
inspection is not feasible.
Tolerances are so tight that manual visual
inspection is inadequate.
A variety of approaches for automated optical inspection of
printed circuit boards (PCBs) have been reported over the Fig.1: Template Grayscale PCB Image
last two decades.
PCB defects can be categorized into two groups; functional
defects and cosmetic defects [5]. Functional defects can
seriously affect the performance of the PCB or cause it to
fail. There are 14 known types of defects for single layer,
bare PCBs as shown in Table 1. Figure 1 shows a grayscale
image of a single layer, bare PCB and Figure 2 shows the
same image but with defects as listed in Table 1.
Based on reviews of previous works, Heriansyah et al [1]
developed a PCB image segmentation algorithm by
clustering primitive patterns of a PCB image into four main
segments using mathematical morphology and windowing
technique. Later Heriansyah [9] classifies 12 out of the 14
known PCB defects by combining the image segmentation
with artificial neural network (ANN). Recently, Khalid [2] Fig.2: Test Grayscale PCB Image
produced an image processing algorithm using MATLAB
by subtracting the images and performing X-OR operation. This project combines two previous works. First, the
The 14 defects are then grouped into 5 categories. complex PCB images are divided into four different
segments of well-defined generic patterns [1], and later fed
into the image processing algorithm [2] where defects are
41
International Journal of Computer Applications (0975 – 8887)
Volume 87 – No.9, February 2014
detected and classified. Then by using these patterns we
locate these patterns on defected PCB.
3. METHODOLOGY
3.1 Mathematical Morphology for Image
Segmentation
The algorithms to segment the image into basic primitive
patterns, enclosing the primitive patterns, patterns
assignment, patterns normalization, and classification have
been developed based on binary morphological image
processing.
After segmenting the PCB image into basic primitive
patterns, the next step is to enclose each pattern so that only
pixels under this window will be processed. Windowing
operation is also employed to the detected defective
patterns .The defects detection applied in this work is based
on the image subtraction operation [1]. Fig.3: Morphological Segmentation for Template
Image
The segmented primitive patterns of the reference image
will be enclosed using the windowing technique, and these
window coordinates will be mapped onto the test image to
generate the same window coordinates for the test image.
At the same time, the detected defects from previous
subtraction operation will also be enclosed using the same
windowing technique.
The next step is to do the assignment operation. The aim of
this assignment operation is to define the position of the
enclosed defect patterns relative to the enclosed test image
patterns.
This research does an adaptation of the mathematical
morphology for image segmentation by Heriansyah et al [1]
in preparing the images for defect detection and
classification. MA TLAB is used for this purpose. A
template image is a grayscale image of a perfect PCB
pattern without any defects or deformation which is used as
reference as in Figure 1.
A test image is a grayscale image of a defective PCB as in
Figure 2 which is synthetically generated to contain all 14
defects as listed in Table 1. Both the images are segmented
into 4 segments each; square segment, hole-segment, thick-
line segment and thin-line segment as in Figure 3 and Fig.4: Morphological Segmentation for Test Image
Figure 4. The square segment contains the image of square
pads, the hole-segment contains the image of hole pads, the
thick-line segment contains the image of thick conductors
3.2 Image Processing For PCB Defect
and the thin-line segment contains the images of thin Detection and Classification
conductors. Once the template and test images are segmented, threshold
values for the grey scale images are determined to convert
Some defects only occur on particular segments of test the images into binary. Grey scale images with levels of
image such as wrong size hole, breakout and missing hole between 0 and 255 are converted into binary images with
for hole segment or missing conductor and open circuit for only two levels; 0s and 1s. This is to simplify further
thin-line segment. Other defects might exist in multiple processes. This project will not consider uneven binary
segments. Mouse-bite and under-etch might exist in both convergence that can cause unwanted noise. It is observed
hole and square segments. By breaking the image into that unwanted noise occurs occasionally in the thin-line and
clusters, some of the defects associated with certain thick-line segments which can be removed by using median
segments can easily be identified and classified. filtering.
The binary images are fed into the image processing
algorithm developed by Khalid [2], using MATLAB image
processing tools. The algorithm uses following operations:
42
International Journal of Computer Applications (0975 – 8887)
Volume 87 – No.9, February 2014
3.2.1 Image difference operation Group 5: pinhole and breakout.
Image difference, which is the simplest technique, consists
of comparing both images pixel-by-pixel by XOR logic The image processing algorithm produces 5 new images for
operator. The operation is also called as image comparison each pair of segmented template and test images processed.
operation. The truth table of XOR is given in Table Since the morphological segmentation algorithm is able to
2.Image difference operation is developed in order to get produce 4 images for both template and test image, thus,
the differences between two images. the image processing algorithm is able to generate 4x5
images (20 images) which will improve the overall defect
detection and classification ability of the system.
Table 2: Truth Table of XOR Logic Operator
Bit 1 Bit 2 Output
0 0 0 3.3 Defect Location
0 1 1 By using defected patterns generated by above algorithm
1 0 1 and defected PCB image we can locate those defects on
1 1 0 PCB. Its advantage is it possible to tell where exactly
defect has occurred, which not possible only seeing at
defects. Function regionprops () is used for above
3.2.2 NOT operator purpose.
NOT operator is normally used to change an image from
black to white and vice versa. This operator inverts the bit
values of any variable and sets the corresponding bit 4. RESULTS
according to Table 3. Based on exercises conducted for several test and template
images, an example of result obtained is shown in Figure 5.
From the 20 images generated by the image processing
Table 3: NOT Truth Table algorithm, 7 images were identified as beneficial. The
Input Output images are named G13, G21, G22, G24, G32, G43 and
0 1 G44.
1 0
3.2.3 Flood-fill operator
The flood-fill operator changes the color of a region, given
an initial pixel in that region on binary and grayscale
images. For binary images, flood-fill operator changes
connected background pixels to foreground pixels until it
reaches object boundaries. This operation could be useful
in removing irrelevant artifacts from images. In this study,
this operator is used to fill the holes in a binary image.
(a) G13 (b) G21 (c) G22
3.2.4 Image Subtraction
Image subtraction method used the concept of simple
subtraction and rule. In this work, both images of template
image and defective image are compared pixel by pixel.
The subtract operation produces either negative or positive
pixel value. Therefore, the outcome of this operation is
divided into negative image and positive image.
(d) G24 (e) G32 (f) G43
3.2.5 Image addition
Image addition is a method for combining objects in two
images into one image. In this paper, this operator
combines the defects from one group with the defects from
another group in one image. This is possible using OR
logic operator. Five algorithms shown in Figure 7 to Figure
11 are developed to detect and classify the defects into five
groups. Those groups with the respective defects areas (g) G44
follow:
Fig.5 (a-g): Classified Defect Images
Group 1: missing hole and wrong size hole
Group 2: spur, short, spurious copper, excessive short, Figure 5 (a-g) shows classified defect images. By using
underetch negative, and conductor too close negative. above patterns and defected PCB image defects are located
Group 3: open circuit, mouse bite, overetch, conductor too as shown in figure 6(a-g). For this particular exercise, each
close positive. group is able to classify a minimum of 1 defect to a
Group 4: underetch positive. maximum of 4 defects, and is able to improve the image
43
International Journal of Computer Applications (0975 – 8887)
Volume 87 – No.9, February 2014
processing algorithm by Khalid [2] by increasing the Table 4:Classified Defect Groups
classification groups from 5 to 7.
No. Image Defect Classified
1 G13 Under etch
Wrong size hole
2 G21
Missing hole
Over etch
3 G22
Mouse bite
4 G24 Breakout
Short
(a) G13 (b) G21 Excessive short
5 G32
Spurious copper
Spur
Missing conductor
6 G43
Open circuit
7 G44 Conductor too close
5. CONCLUSION
From the above experiment, the given algorithm
successfully detects and classifies defects into 7 groups.
(c)G22 (d) G24 (G13, G21, G22, G24, G32, G43, G44). Due to these
results, the proposed algorithm detects successfully several
types the defects such as breakout, short, pin hole, wrong
size hole, open circuit, conductor too close, under etch,
spurious copper, mouse bite, excessive short, missing
conductor, missing hole, spur and over etch. After detecting
defects localization of defects makes inspection easy and
precise. The limitation of this algorithm is that some groups
are unable to address each defect individually. Unwanted
images were also generated by noise during grayscale to
binary conversion. Future improvement for the algorithm
(e) G32 (f) G43 should include the ability to detect and classify all 14
defects individually.
6. REFERENCES
[1] R. Heriansyah, S.A.R AI-Attas, and M.M. Ahmad
Zabidi,'Segmentation of PCB Images into Simple
Generic Patterns usingMathematical Morphology and
Windowing Technique', CoGRAMMMelaka,
Malaysia 2002
[2] N.K. Khalid. 'An Image Processing Approach
(g) G44 Towards Classification of Defects on Printed Circuit
Board', Projek Sarjana Muda, Universiti Teknologi
Fig. 6 (a-g): Classified Defect Images Malaysia, 2007.
[3] M. Moganti, F. Ercal, C.H. Dagli, and S. Shunekawa,
G 13 is generated from the square segment, G21, G22 and
'Automatic PCB Inspection Agorithm: A Survey',
G24 from the hole segment, G32 from the thick-line
1996, 63. No. 2.
segment and G43 and G44 from the thin line segment. The
defects classified by these groups are listed in Table 4. [4] T. Taniguchi, D. Kacprzak, S. Yamada, M. Iwahara,
Once the overall result for classification has been obtained, and T.Miyogashi, 'Defect Detection on Printed Circuit
the localization operating will take place so that the defect Board by using Eddy-Current Technique and Image
will be highlighted on the fine (original) image. The Processing', 101 Press, 2000
location will be superimposed on the original image with a
red marker as shown in Figure 6(a-g). [5] Wen-Yen Wu, Mao-Jiun J.Wang and Chih-Ming Liu,
'Automated Inspection of Printed Circuit Board
Through Machine Vision', Computers in Industry, 28
(1996) pp.I03-III.
44
International Journal of Computer Applications (0975 – 8887)
Volume 87 – No.9, February 2014
[6] Z. Ibrahim, S.A.R AI-attas and Z. Aspar, 'Analysis of [10] D.M. Tsai and B.T. Lin, 'Defect Detection of Gold-
the WaveletBased Image Difference Algorithm for Plated Surfaces on PCBs Using Entropy', Int J. Adv
PCB Inspection', in proceedings of SICE, Osaka, Manuf Technol (2002) 20:420-428
Japan, 2002
[11] K. Chomsuwan, S. Yamada and M. Iwahara,'
[7] Z. Ibrahim, S.A.R AI-attas, Z. Aspar and M.M. Mokji Improvement on Defect Detection Performance of
'PerformanceEvaluation of Wavelet-based PCB Defect PCB Inspection Based on ECT Technique With Multi-
Detection and Localization Algorithm', in proceedings SV-GMR Sensor', IEEE Transaction on Magnetics
of ICIT, 2002, Bangkok, Thailand vol.43, no. 6, June 2007.
[8] Z.lbrahim, S.A.R AI-attas and Z. Aspar, 'Coarse [12] F. Wang, X. Li and G. Xu, 'The PCB Defect
Resolution Defect Localization Algorith for an Inspection System Design Based on Lab
Automated Visual PCB Inspection', Jurnal Teknologi, Windows/CVI', International Conference on Industrial
37(D) Dis. 2002: 79-92 Mechatronics and Automation, ICIMA, 2009.
[9] R. Heriansyah. 'Classification of Defect on Bare PCB
using Neural Network Technique', Masters Thesis,
Universiti Teknologi Malaysia.2004.
IJCATM : www.ijcaonline.org 45