Development of MATLAB GUI based on blob analysis for automatic extraction of defects

This study introduces a graphical user interface (GUI) based on MATLAB to realize the automatic extraction of sizes of defects from the infrared sequence. To obtain the edge of the defect at deeper layer, a fusion stratagem of the maximum of gray values is adopted for an image subset in the sequence. Blob analysis to the fusion image is used to obtain the general information of defects of a specimen including the distributions and numbers of defects. The frame image is determined for a certain defect according to the peak of the time history curve of sensitive region variance. It can yield a region of interest (ROI) to expand the blob in the selected frame and the defect can be acquired by image segmentation. The results show that through this GUI, a better thermal image can be selected from a set of infrared sequence diagrams for quantitative extraction of different buried depth defect areas, which realizes automatic defect extraction, and its relative error is within 5%. The research on infrared automatic detection technology has certain significance.


INTRODUCTION
Pulse thermography is an effective non-destructive testing (NDT) technology that can monitor the development of material defects through a series of infrared images [1,2]. At this stage, the pulse thermography detection technology has changed from the qualitative diagnosis and evaluation of defects to the quantitative detection of defects. However, due to the poor contrast of thermal images and other reasons, the quantitative detection of defects is difficult. Quantitative detection of defect size is one of the difficult points [3,4], and how to select a thermal image from the thermal image sequence that can better reflect the defect characteristics is a primary problem that needs to be solved urgently for defect feature extraction. Tashan et al. [5] pointed out that the quantitative detection of defect size depends critically on selecting a suitable temperature map time frame for defect evaluation. Sreeshan [6] used watershed technology and Gabor filtering to extract features of infrared images, and achieved good results. Yuan et al. [7] obtained the defect information by determining the ROI of the defect to realize the quantitative extraction of the defect. In addition, defect detection is developing in the direction of automation [8,9], and the future pulse thermal imaging detection technology will surely become an intelligent technology to realize automatic identification and extraction of defect size.
Quantitative extraction of defect size includes a large number of image processing procedures. MATLAB is often used in these processes due to its friendly matrix computing capabilities and powerful image processing toolbox [10]. The GUI is the graphical user interface, which is the user interface for displaying and operating the computer in a graphical style [11,12]. Blob analysis algorithm is a feasibility analysis of pixels in the same connected domain [13], which is usually used to extract defect features from a target image. In order to realize the automation of defect extraction, this paper uses MATLAB as the development tool to develop a set of GUI for automatic defect size extraction based on Blob analysis. This GUI covers sequence diagram browsing, image fusion, Blob analysis, ROI determination, defect extraction and other functions. In addition, the GUI parameter adjustment is flexible, the expansion is convenient, and it is easily converted into an .exe executable file, which can be executed out of the MATLAB environment.
This article will first describe the general functions and algorithm principles of GUI, and then in order to evaluate its performance, use the system to automatically extract the defect size from a set of infrared sequence diagrams and perform error analysis. The detected sequence is a set of image sequences collected by pulse thermal imaging detection technology, which contains two different buried depth defects.

ALGORITHM FOR THE AUTOMATIC EXTRACTION OF DEFECTS
The framework of the algorithm for the automatic extraction of defects is shown in Figure 1. It includes five functions, that is, fusion image, blob analysis, frame selection, ROI determination and defect segmentation. The aim of the algorithm is automatic to determine a better frame from the thermal image sequence and to select a suitable ROI for each defect. Figure 2 is the flow chart of the automatic defect extraction algorithm, which shows the specific processing procedures of the five functions.

RESULTS AND DISCUSSION
According to the framework of automatic defect extraction, MATLAB is the software development platform, and its graphical user interface GUI is used, which has the advantages of visualization and programming. Use the guide method to create a new GUI. This GUI takes pushbutton, axes, and panels as the main controls, and has a few editable text boxes and static text boxes as secondary controls. Its purpose is to make the system operation easier and more accessible, and to make the GUI interface simple and practical.
This GUI writes the callback function in MATLAB and requires two inputs: the actual size and defect area of the test block and the infrared image sequence. The actual size and defect area of the first input test block are written in the callback function compilation process in order to calculate the relative error automatically extracted by the GUI. The second input infrared image sequence is input at the beginning of the GUI operation. Figure 3 shows the main window of the GUI. There is an image sequence information panel on the left side, which displays the input infrared image sequence information. The sub-window display panel shows the switching of several sub-windows. The image fusion panel is to process the input sequence image to get a fusion image.

Image fusion
The active infrared sequence diagram records the whole process of heating and cooling of the surface of the test block under external excitation, deduces the appearance of sinks and the disappearance of thermal diffusion, and not all images can clearly record defects. Therefore, it is necessary to establish a subset of sequence images according to the appropriate time period. For defects at different depths, the corresponding surface temperature of the shallow buried depth is high, and the image gray value should be large, which dominates the image segmentation. In order to ensure that the deep buried defects can be effectively segmented, image fusion is adopted. The specific method of image fusion is to randomly select 10 frames of images from the subset, and use the fusion strategy of taking the maximum gray value of the same pixel to synthesize a fusion image.
The first step to run the GUI is to input the infrared image sequence. Click the start button to open the file selection dialog box on the computer to select the sequence you want to input. The corresponding information of the sequence as shown in Figure 3 will be dis-played in the Image sequence information panel, which is equivalent to a sequence image player and can browse the entire sequence image. After the sequence is input, click the corresponding button on the Image fusion panel to merge the images, and finally get a fused image.

Blob analysis
A fundamental image processing function is called blob analysis, which is used in machine vision. A blob is a region of an image in which some properties are constant or approximately constant; all the points in a blob can be considered in some sense to be similar to each other. The most common method for blob detection is convolution. It is the extraction of features from connected pixels that share the same logical state (blobs). There are three steps of blob analysis in Figure 4. Blob analysis can offer the base information of NDT, such as defects distribution and the total number of defects. The result of blob analysis is affected by binarization, which is related to the contrast of the image. Blob analysis is performed on the obtained fusion image, and the red framed area of the binarized image shown on the left side of Figure 5 blobs and defects have a one-to-one correspondence, so the distribution and quantity of defects can be obtained ac-cording to the Blob. Then use the canny algorithm to extract the edge to prepare for the random sampling of the sensitive area.

Frame selection
To determine the ROI, you first need to find the number of frames with the most obvious defects, and the appearance and disappearance of defects with different depths are not synchronized, and there is a time difference. Therefore, it is necessary to select different frame images for defects with different depths. In order to find the number of frames when the defect is most obvious, the first step is to randomly sample the sensitive area of the edge-extracted image as shown in Figure 6 to obtain the average variance of the image defect in each frame, and then draw the average variance history curve. The highest point of the two curves is the number of ROI extraction frames corresponding to the defect.

ROI determination
In order to accurately extract defects, it is necessary to determine a suitable ROI for each defect, so that an appropriate threshold can be selected to achieve accurate defect segmentation. Combining the frame image selected in Section 3.3 and the Blob analysis, the corresponding ROIs of the two defects as shown in Figure 7 are obtained. The green area is the ROI we determined, and they are expanded from the Blob area up, down, left, and right. Figure 7. Sub-window of ROI determination.

Defect extraction
The obtained ROI is intercepted and binarized as shown in Figure 8, the relative error of the two defects is calculated according to the actual size of the test block and the defect area, and finally the binarized images of the two defects are synthesized into a complete image. It can be seen that the relative errors of defects are 1.06% and 3.47%. In order to verify the stability of the GUI, the infrared sequence images of the same line were processed many times, and the running results are shown in Table 1. The relative error of extracting defects is less than 5%.

Number of run
The frame of defect #1 The frame of defect #1 The relative error of defect #1 The relative error of defect #2

CONCLUSION
This paper develops a set of graphical user inter-face for automatic extraction of defect size based on MATLAB. The GUI includes algorithms for Blob analysis and ROI determination. It can select a better thermal image from a set of infrared sequence images for quantitative extraction of defect areas with different buried depths. This method can not only extract artificial defects, but also natural defects. It is not affected by the type, shape, or size of the defect, but only by the contrast of the image. When the image contrast can support the binarization and segmentation of local defects, the GUI can extract the defects. Users can browse sequence images, image fusion, Blob analysis and ROI determination through this GUI, and finally realize automatic extraction of defects. In order to evaluate the performance of the GUI, it is used to automatically extract the defect size from a set of infrared sequence diagrams obtained by pulse thermal imaging. The operating results show that the GUI is suitable for quantitative extraction of defect areas with different buried depths, and the relative errors of defects are controlled within 5%. We can conclude that this GUI has good stability and operability, and it has a certain significance for the research on automatic defect detection of pulse thermography.