# Automatic Extraction of Material Defect Size by Infrared Image Sequence
## 4 Data Post-Processing  
### Image Composition and Its Image Processing  
It can be seen from Figure 8 that not all frames from the obtained image sequence are suitable to carry out image processing for defect detection. The shallower defect appears earlier and brighter than the deeper one and has an advantage in the picture. To detect the deeper defect, a stratagem of image composition is proposed. Suppose that an infrared image sequence includes \(n\) images marked as \(I[i]\), where \(i=1\), \(2\), \(3\)\(\dots\)\(n\), and each image has a size of \(w\times h\). Select \(m\) images randomly from an interval \((a,b)\) of the sequence, where \(1<a<b<n\) is marked as \(Ic[j]\) and \(j=1\), \(2\), \(3\)\(\dots\)\(m\). The composition is based on the maximum gray value of the m images for each pixel. The composition image enhances the gray value of defects, especially the deeper one, and it can guarantee to detect all defects by image processing, as whole or partial. The values of \(a\) can be determined by the frame rate (\(f=30\) Hz) and impulse duration (\(t=3\) s); then, \(a=t*f=90\). The surface temperature of the shallower defect with time could be monitored by the infrared image sequence. There is a curve of temperature with time or frame in Figure 9. We can select the peak frame as the value of \(b\). In this experiment, the value of b is \(224\). Therefore, the suitable frame range is \((90,\,224)\). We randomly select \(m\) frames from the interval \((90,\,224)\). If the deeper defect cannot be detected or the partially detected is too small, the value of \(m\) should be increased to be sure that a defect corresponds to a blob. We find that \(m=10\) provides enough feature information, and the composition result is shown in Figure 10.  
Figure 8: Distribution of temperature field on the surface of the PVC test object in the sequence.  
There are some factors, such as the non-uniformity of excitation and fringe effect of specimen, which may influence images detected by an infrared camera. The noise will affect the image composition. To reduce noise, a filter should be applied to the image composition. A 3-by-3 median filter is carried out to the image composition shown in Figure 10 and the result can be seen in Figure 11a. Then, the image is segmented by [PERSON]'s method as represented as Figure 11b.  
The extracted defect shape indicates that the obtained defect #1 is similar to the artificial defect, while the segmentation of defect #2 is obviously smaller than the real one and the root portion of the wedge groove has not been extracted, because defects #1 and #2 have different burial depths and their temperatures of heating to cooling process are out of sync. Under the excitation of 3 s optical pulses, defect #1 with shallow burial depth transferred heat more quickly to the surface of the specimen than defect #2 (with deeper burial depth), thus accumulating more heat on the surface. The higher  
Figure 11: Image processing of image composition: (**a**) Median filter; (**b**) Segmentation by [PERSON]’s method.  
Figure 9: The surface temperature of the shallower defect with frame.  
temperature is reflected by the greater gray value in the corresponding area of the thermogram. The gray value of defect #1 plays a dominant role in the binary image segmentation of the entire image, leading to an incomplete extraction of defect #2. Even though defect #1 can be extracted completely with its shape similar to the real one, the relative error in area of the resulting defect is as high as 27.08% (see Table 1). This suggests that the value of binary threshold (0.47) of the full image by the Otsu method is not optimal for both defects. It is important to seek a ROI for every defect. We will discuss ROI determination in a later section.