NDT&E International 37 (2004) 301–307 www.elsevier.com/locate/ndteint Automatic inspection of gas pipeline welding defects using an expert vision system H.I. Shafeeka, E.S. Gadelmawlab,*, A.A. Abdel-Shafyb, I.M. Elewab b a Mechanical Engineering Department, Higher Technological Institute, Tenth of Ramadan City, Egypt Production Engineering and Mechanical Design Department, Faculty of Engineering, Mansoura University, Mansoura 35516, Egypt Received 21 July 2003; revised 14 October 2003; accepted 15 October 2003 Abstract Automatic inspection of welded gas pipelines is desirable because human inspectors are not always consistent evaluators. In addition, automatic inspection decreases the cost of inspection process and improves the inspection quality. In this paper, an expert vision system for automatic inspection of gas pipeline welding defects from radiographic films is presented. The proposed system has been established in the Metrology lab, Mansoura University, Faculty of Engineering. The software, named AutoWDI, is fully written in lab using Microsoft Visual Cþ þ and is ready to run on any Windows environment. The proposed vision system is used to capture images for the radiographic films then applies various image processing and computer vision algorithms to recognize the defects and to make acceptance decisions according to international standards. The expert system is based on a knowledge base, which was gathered from specialists, textbooks and international standards. The proposed system is capable of identifying and testing the main types of welding defects (11 defects) in gas pipelines welded by shielded metal arc welding. q 2003 Elsevier Ltd. All rights reserved. Keywords: Expert system; Welding defects; Quality control; Computer vision; Radiography 1. Introduction The reliable detection of flaws by radiography is one of the most important tasks in non-destructive testing (NDT). Improvements in these methods are necessary, because the human factor still has great influences on the evaluation. Inspection of welding defects of gas pipelines is vital because some welding defects such as sharp weld cups and weld roof angle are contributing to failure in welding joints [1,2]. Human inspection of gas pipeline welding defects is a hard and difficult task when a great number of welds are to be counted and inspected. In addition, human visual inspection can only catch around 60 –75% of the signification defects [3]. Therefore, in order to lower the cost of inspection process and to improve the inspection quality, it is necessary to automate the inspection process [3,4]. More than 125 nondestructive testing technologies have been identified [5]. One of the most important areas of NDT is the welding inspection of oil and gas pipelines [6]. The film * Corresponding author. Tel.: þ 20-122808003; fax: þ 20-402977854. E-mail address: esamy@mans.edu.eg (E.S. Gadelmawla). 0963-8695/$ - see front matter q 2003 Elsevier Ltd. All rights reserved. doi:10.1016/j.ndteint.2003.10.004 radiography method has been the cornerstone of NDT for the last 50 years [7]. On the other hand, developments in image processing, computer vision, artificial intelligence and other related fields have significantly improved the capability of visual inspection techniques [8,9]. It was reported that about 60– 90% of all existing machine vision applications were classified as automated visual inspection [10]. Therefore, various algorithms were used to identify welding defects from radiographic films. These algorithms include image processing/computer vision [11 –13], neural networks [14, 15] and fuzzy algorithms [15,16]. 2. Problem description Automated visual inspection can be classified into two stages: measurement and quality control. In the measurement stage, the system is concerned with making accurate measurements of critical dimensions. In the quality control stage, the system emulates a human inspector who assesses manufactured parts for integrity and completeness. The first 302 H.I. Shafeek et al. / NDT&E International 37 (2004) 301–307 Nomenclature AutoWDA Automatic Welding Defect Assessment AutoWDI Automatic Welding Defect Inspection stage has been recovered in a previous paper related to AutoWDA software [13]. This paper aims to extend and develop the previous software (AutoWDA) to recover the quality control stage. This could be done by building an expert vision system to identify the most common welding defects and to make acceptance decisions according to international standards of welds. 3. Proposed system Fig. 1 shows a photograph for the proposed vision system. It consists of two parts: hardware and software. The hardware includes an IBM compatible personal computer (5) with Windows operating system, frame grabber (4) with resolution up to 760 £ 570 pixels and a CCD (Charged Couple Device) camera (3). The software is especially written to identify the most common welding defects (11 defects) of gas pipelines radiographic films and to make an acceptance decision for each defect according to international standards of welds. It was totally developed in-lab using Visual Cþ þ 6.0 and it is ready to run under Windows operating systems. The proposed software is named AutoWDI (Automatic Welding Defects Inspection) and it was developed such that it can be used independently without referring to any other software. In addition, it supports many different image file formats such as BMP, TIFF, GIF, JPG, PCX and TGA. DIA ADA Defect Identification Algorithm Acceptance Decision Algorithm 4. Procedures of working Referring to Fig. 1, the procedures of working could be summarized as follows: 1. Setting the radiographic film (1) on the backlighting table (2) under the CCD camera (3). 2. Capturing an image for the radiographic film and saving it to a BMP file using the capturing software (6) provided with the frame grabber (4). 3. Opening the captured image by the AutoWDI software and then specifying a window around the whole welding area. 4. Applying the AutoWDI algorithms to detect, identify and inspect the defects. 5. Image processing and computer vision algorithms Fig. 2 shows the main algorithms used by the AutoWDI software to detect, identify and inspect the welding defects from the radiographic captured images. The proposed system is capable of identifying 11 welding defects, which are hollow bead, porosity, scattered porosity, burn through, incomplete fusion of root pass, external undercut, slag line, slag inclusions, longitudinal cracks, transverse cracks and base metal cracks. Fig. 1. A photograph of the proposed vision system. H.I. Shafeek et al. / NDT&E International 37 (2004) 301–307 303 in the filed of weld defects inspection. An identification tree was build from these expertises as shown in Fig. 3. The identification process is based on estimating three main factors for the defects, which are shape, orientation and location. In addition, some secondary factors were used to finalize the identification process such as number of defects, defect width, defect size and defect straightness. 5.2.1. Estimating the defects shape The DIA classifies the shape of the defects into three categorizes, which are circular, rectangular and irregular. Two factors were introduced to identify the shape of regions [17]. The first factor called form factor ðFf Þ and is used to measure the circularity of regions based on its area and perimeter. The form factor Ff is calculated using Eq. (1). Ff ¼ ðPerimeterÞ2 4pArea ð1Þ For circular regions, the form factor Ff is equal to 1.0. For regions extracted by image processing algorithms, it is difficult to obtain a value of 1.0 for the form factor. Therefore, a tolerance value of ^ 10% is used to identify the circular defects. The tolerance values could be changed by the user through a settings dialog box. The second factor used to identify the shape of defects called rectangularity factor ðRf Þ. It is used to measure the rectangularity of regions based on the area of the region and the area of the minimum rectangle enclosing it. The rectangularity factor Rf is calculated by Eq. (2). Rf ¼ Fig. 2. Block diagram of the main algorithms of the AutoWDI software. 5.1. The AutoWDA algorithms The AutoWDA algorithms were described in details in a previous paper for the same authors [13]. These algorithms include converting color images to gray images, extracting the gray level histogram, calculating a suitable Threshold and applying image enhancement algorithms to obtain the optimum image. In addition, it includes the segmentation process, edge detection, and feature extraction algorithms. The main objective of these algorithms was to extract the welding defects from captured images and to calculate necessary information for each defect. The extracted information includes width, height, area, perimeter and dimension of the minimum box enclosing each defect. Once the defects are extracted and its information is calculated, the Defect Identification Algorithm is used to classify these defects. 5.2. The defect identification algorithm The Defect Identification Algorithm (DIA) is used to identify the extracted defects based on the human expertise Ar Amin ð2Þ where Ar is the calculated area of the defect and Amin is the area of the minimum rectangle that encloses the defect. The rectangularity factor Rf is equal to 1.0 for actual rectangular regions. To identify the shape of the defect, the form factor ðFf Þ is calculated first. If Ff lies between 0.90 and 1.10, the defect shape is considered circular. Otherwise, the rectangularity factor ðRf Þ is determined. If Rf lies between 0.90 and 1.10, the defect shape is considered rectangular, else, it is considered irregular. 5.2.2. Estimating the defects orientation The defect orientation is required for elongated defects only. The orientation of each defect is calculated based on its length and width. If the length (size in X direction) is greater than the width (size in Y direction), the orientation is considered horizontal; otherwise it is considered vertical. 5.2.3. Estimating the defects location The location of defects is needed to identify both irregular and elongated defects. It is calculated according to the position of the defects in the captured image as shown in Fig. 4. Defects location could be classified into four regions, which are Inside Weld (IW), Center of 304 H.I. Shafeek et al. / NDT&E International 37 (2004) 301–307 Fig. 3. Classifying the defects using the identification tree. Weld (CW), Edge of Weld (EW) and Base Metal (BM). For defects, which lie at the EW and the CW regions, a tolerance zone equal to 5% of the weld height (size in Y direction) is taken above and below both the edge of weld and the center of weld, respectively. The width of weld is calculated from the window specified by the user. The location of each defect could be estimated by comparing the coordinates of the minimum rectangle enclosing the defect with the coordinates of the four mentioned regions. 5.3. The acceptance decision algorithm The Acceptance Decision Algorithm (ADA) is used to make an acceptance decision about the identified defects. After the defect type is identified, its dimensions are compared with international standards to make the acceptance decision. The proposed system supports the most international standards codes (API 1104, ASME, DIN, BS, ABS, AWS, and JIS) for the acceptance criteria of weld defects. In addition, any new code can be added easily to the system through a user-friendly dialog box. The default code is the American Petroleum Institute (API). 6. Experimental study Fig. 4. Classification of welding defects location. To verify the proposed system, five clear radiographic films for each type of the defects mentioned in Section 5 (11 defects) were obtained from the PETROJET Company and inspected by both the system and the specialists of the company. The specialists’ identification and decision are the same as the results obtained from the system. Figs. 5– 8 show four samples from the tested radiographs, which have different shapes according to the identification tree (circular, irregular, elongated horizontal and elongated vertical). Each figure shows: (a) part of the original radiographic film, (b) the defects after applying the enhancement and segmentation algorithms, (c) the detected defects, and (d) the results obtained from the AutoWDI software. The obtained results include the defects measurements, information, identification and decision. The estimated information includes H.I. Shafeek et al. / NDT&E International 37 (2004) 301–307 305 Fig. 5. Example for detecting and identifying circular defects (Prosity). the form factor ðFf Þ; the rectangularity factor ðRf Þ; shape, orientation and the location. 7. Discussions The results obtained by both the proposed system and the specialists proved that the identification tree of the defects has been successfully defined and the proposed algorithms (DIA and ADA) are capable of identifying and inspecting all defects, which are predefined by the identification tree. Using such expert system could decrease the cost of the inspection process by using human inspectors with reasonable knowledge instead of specialists for the general inspection processes. In addition, the enhancement algorithms provided with the proposed system could reduce Fig. 6. Example for detecting and identifying irregular defects (Burn Through). 306 H.I. Shafeek et al. / NDT&E International 37 (2004) 301–307 Fig. 7. Example for detecting and identifying elongated (horizontal) defects (Incomplete Fusion). Fig. 8. Example for detecting and identifying elongated (vertical) defects (Transverse Crack). the inspection time, especially for defects, which are not clear in the radiographic films. 8. Conclusions An expert vision system for the automatic identification and inspection of gas pipeline welding defects has been introduced. The system is capable of identifying and inspecting the most common welding defects (11 defects) in radiographic films. Two algorithms were introduced for the identification and inspection process. The first algorithm (DIA) is used to identify the type of defects based on a predefined identification tree, which was gathered from specialists, textbooks and international standards. The second algorithm (ADA) is used to make an acceptance decision for the identified defects according to international standards. In addition, any new standards or customized codes could be added to the system. The inspected defects were identified and inspected correctly as reported by H.I. Shafeek et al. / NDT&E International 37 (2004) 301–307 the specialists of weld inspection. The proposed system is considered quite cheap compared with the commercial automatic inspection systems and eliminates the need for image interoperation by a skilled inspectors. 9. Future work Currently, we are working in a project to apply the proposed system in the interpretation and inspection of radiographic films in the field. The aim of this work is to test and develop the proposed system so that it can be used to store the inspection results of radiographic films to a database system. In addition, other information about the inspected welds and the welders will be stored to the database for further analysis in the company such as evaluating the welders’ performance and the common defects produced by each welder. References [1] Foulds JR. Concerns about seam-welded piping at elevated temperatures. Proc SPIE 1996;2947:67–77. [2] Rao BPC. Advances in non-destructive inspection and evaluation of welds. Proceedings of the Workshop on Welding Technology for Engineers Organized by Indian Institute of Welding, Chennai, India; 2002. p. 71–90. [3] Chan C, Grantham KH. Fabric defect detection by Fourier analysis. IEEE Trans Ind Appl 2000;36(5):1267–75. [4] Yoneyama H, Aono K, Nakada S, Igeta M. A study of capability of flaw detection and accuracy of flaw sizing using ultrasonic testing. First International Conference on NDE in Relation to [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] 307 Structural Integrity for Nuclear and Pressurized Components; 1998. p. 20 –22. Litsikas K. Computer power changes the face of NDT. J Quality [QUA] 1996;35:36 –8. Williams H, Barbian OA. Operational experience with inline ultrasonic crack inspection of German crude oil pipelines. In: Proceedings of Seventh European conference on Non-Destructive Testing; 1998, 3(8). Knell M. Improving actual film quality using image quality parameters from new national and international standards, vol. 3. In: Proceedings of 14th World conference on Non-Destructive Testing, New Delhi; 1996. p. 1351–6. Rao BPC. Visual techniques in non-destructive testing, encyclopedia of materials: science and technology. Amsterdam: Elsevier; 2001. p. 6043– 6. Fletcher MJ. Fully automatic inspection of welds now a reality. NDT E Int 1996;29(3):191. Awcock GW, Thomas R. Applied image processing. New York: McGraw-Hill; 1996. p. 228– 30. Ho SK, White RM, Lucas J. A vision system for automated crack detection in welds. NDT E Int 1996;29(2):129. Montini G, Bordini MG, Boschetti F, Ripamonti S. EXACT: an expert system for real time X-ray image analysis and classification of weldings. NDT E Int 1996;29(3):184. Elewa IM, Abdel-Shafy AA, Gadelmawla ES and Shafeek HI. Assessment of welding defects for gas pipeline radiographs using computer vision. Proceedings of Third Assuit International Conference on Mechanical Engineering Advanced Technology for Industrial Production, Assiut, Egypt; 2002. p. 216–23. Perner P, Zscherpel U, Jacobsen C. A comparison between neural networks and decision trees based on data from industrial radiographic testing. Pattern Recognition Lett 2002;48(1):47 –54. Wang G, Warren LT. Automatic identification of different types of welding defects in radiographic images. NDT E Int 2002;35(8): 519–28. Lashkia V. Defect detection in X-ray images using fuzzy reasoning. Image Vision Comput 2001;19(5):261–9. Parker JR. Practical computer vision using C. Printic Welley; 1995.