Quality Detection System of Transparent Nonel Tubes Based on Image Processing

The traditional quality detection method for transparent Nonel tubes relies on human vision, which is inefficient and susceptible to subjective factors. Especially for Nonel tubes filled with the explosive, missed defects would lead to potential danger in blasting engineering. The factors affecting the quality of Nonel tubes mainly include the uniformity of explosive filling and the external diameter of Nonel tubes. The existing detection methods, such as Scalar method, Analysis method and infrared detection technology, suffer from the following drawbacks: low detection accuracy, low efficiency and limited detection items. A new quality detection system of Nonel tubes has been developed based on machine vision in order to overcome these drawbacks. Firstly the system architecture for quality detection is presented. Then the detection method of explosive dosage and the relevant criteria are proposed based on mapping relationship between the explosive dosage and the gray value in order to detect the excessive explosive faults, insufficient explosive faults and black spots. Finally an algorithm based on image processing is designed to measure the external diameter of Nonel tubes. The experiments and practical operations in several Nonel tube manufacturers have proved the defect recognition rate of proposed system can surpass 95% at the detection speed of 100m/min, and system performance can meet the quality detection requirements of Nonel tubes. Therefore this quality detection method can save human resources and ensure the quality of Nonel tubes.


INTRODUCTION
The Nonel tube named as "plastic detonating tube" is referred to as the non-electric detonator initiation system.With PVC (PolyVinyl Chloride) material and RDX (cyclotrimethylenetrinitramine) high explosive along with the aluminum powder filler, the Nonel tube rapidly transfers explosion energy into the non-electric detonators with the shock wave, but it doesn't change.With the improvement of blasting equipment, Nonel tubes play an extraordinary role in tunnel blasting, demolition blasting of the cofferdam and urban demolition blasting, etc.Therefore, the quality of Nonel tubes is closely related to the safety of people's lives and property.
The factors which may influence the quality of Nonel tubes mainly comprise the filler uniformity and external diameter.Firstly, the common defects about explosive filler uniformity can divide into three categories: excessive explosive faults, insufficient explosive faults, and black spots.The Nonel tube will be ruptured and even burn through the tube wall, when the explosive dosage in the certain segment is excessive.Especially if the excessive explosive accumulates in a very small area, the so-called black spot will form.On the contrary, if the explosive is inadequate or disappearing, it will result in the detonation wave extinguishing and explosion failure.Secondly, when the tension of production equipment is excessive, plastic Nonel tube will be thinned, and its intensity will be *Address correspondence to this author at the Mechanical Engineering, Hubei University of Technology, Wuhan, Hubei, 430068, China; Tel: 13385287953; Fax: 0086-027-59750418; E-mail: sgdeagle@163.comweakened.Thus the detonation wave may easily burn through the tube.In order to avoid the failures above, it is essential to measure the external diameter of Nonel tubes simultaneously.
Traditionally, the filler of Nonel tubes is detected with Scalar method and Analysis method.Scalar method is an online testing method, and there is no damage to the product.But Scalar method can not detect the explosive dosage of short segment, and its detection accuracy is low.Analysis method is an off-line testing method with high accuracy, while the product will be destroyed.In addition, the human vision method is commonly used for the filler detection of Nonel tubes in the enterprises, but it is off-line detection with high undetected rate and low detection efficiency.Hence, the infrared nondestructive detection technology was adopted to detect the explosive filler of Nonel tubes in the nineties, in order to overcome the shortcomings of the above manual inspection methods.However, for the infrared detection method, the detection accuracy of explosive dosage wasn't enough high, and the real-time measurement of tube diameter hadn't been realized [1].Thus the diameter of Nonel tubes is generally measured with the vernier caliper.
In recent years, with the rapid development of image processing technology, machine vision detection technology is widely applied to many fields due to the advantages of non-contact and nondestructive detection [2].And various vision detection systems have been developed [3], for example, defect detection of weld bead [4], circuit board inspection system, quality inspection system for fruits and vegetables [5].Although Nonel tubes are paid more and more attentions and the production is very large, existing quality detection means for Nonel tubes, such as human vision, Scalar method, Analysis method, and infrared nondestructive detection technology, are not very satisfactory because of low detection accuracy, low efficiency and limited detection items.It is innovative to adopt image processing techniques to automatically detect the filler and diameter of transparent Nonel tubes and improve the inspection productivity and accuracy.
In this paper, a quality detection method for Nonel tubes is proposed based on machine vision, and an automatic nondestructive detection system for Nonel tubes has been achieved to reduce labor costs and save social resources.

System Principle
The schematic diagram of the whole detection system is shown in Fig. (1).The rotary encoder triggers the line scan camera, and the camera grabs the images of Nonel tubes.Industrial PC processes these real-time images, and records the detection results of these products into the database.At the same time, the different signs, which represent different types of defects, will be marked on the corresponding segments of the Nonel tube with defects by the marking machine controlled by the I/O control card in industrial PC.

Hardware Selection
In general, the cameras are classified into the area and line scan cameras, but the capturing speed of line scan cameras is far higher than that of area scan cameras.Meanwhile, line scan imaging principle and high line frequency ensure the clear imaging of high-speed moving Nonel tubes.Since the external diameter of Nonel tubes is relatively small and small field of view is suitable, the Spyder 2 series line scan camera with resolution of 2048 and the line frequency of 18k produced by DALSA Corporation is adopted to construct the online inspection system for Nonel tubes [6].
The light source is critical for the application of line scan cameras.The lighting methods are coarsely differentiated into front light and back light.Front light is used for all objects whose surface structure or any components on the surface are of interest, such the opaque products as textile and circuit board [7].While back light is used if the outer contour of the object gives the relevant information.Since Nonel tube is transparent and hollow, it is difficult for front light to image because of more transmission and less reflection by the round surface of Nonel tube.And the LED light source with low cost and long life can be customized according to the specific needs, it is more suitable for this vision system than fluorescent lamp.Therefore a white LED light source is laid on the back of Nonel tube as back light.
It is very important of the pulse signals of encoder to synchronize always the image acquisition of each line with the speed of Nonel tubes.Therefore imaging blurring can avoid even if in the condition of high speed or speed fluctuation of Nonel tubes.In order to trigger the line scan camera to capture the clear images, the EB58A8 -H4TR -1000 encoder produced by ELCO Corporation is selected.The AC6652 industrial control card produced by WWLAB Corporation is adopted to control marking machine called LEADJET.The movement of Nonel tube is controlled by the EV2000 inverter series produced by Emerson Corporation.And the Advantech industrial computer with quad-core CPU is chosen to run the detection software.
Additionally, when the diameter of measured tube approaches the wavelength, it is necessary to design a series of optical auxiliary instruments to eliminate the diffraction phenomenon.However, the detection system with auxiliary instruments might be complex in design, poor in stability, and tedious in debugging.Since the diameter of Nonel tubes is about 3mm, there is no need to make use of the extra optical instruments.The equipment appearance of automatic detection system for Nonel tubes is shown in Fig. (2).

IMAGE PROCESSING AND FAULTS DETECTION
The gray value of Nonel tube is extracted by image processing including image pre-processing and edge detection.According to the relationship of explosive dosage and gray value, the dosage is got and the faults can be judged by the dosage.

Image Pre-Processing
The noise will appear inevitably in image acquisition process, thus it becomes very important for future image processing to eliminate the noise firstly [8,9].Since the gray values of the pixels in the image are characterized by an underlying continuum, the gray values of the surrounding pixels should be very close.If the pixel is a noise point, and its gray value is largely different from the neighborhood pixels, the noise pixel can be effectively eliminated by various filters, such as median filter, mean filter, Gaussian filter, maximum filter.
The explosive dosage is defined as an average weight of explosive filled within the specified length, and related to the mean gray value in the related region, so the mean filter is ideal to remove high-frequency components and achieve linear smoothing for further dosage detection.Moreover, as one of the simplest linear filters, the complexity and timeconsuming of mean filter is much less than those of nonlinear filters [10], which lays the foundation for this realtime detection system.
Mean filter is implemented by a neighborhood operation where the value of each pixel is replaced by the average value of the entire local neighborhood.With a noisy image f(x, y) and the processed image g(x, y) by the neighborhood operation, the mathematical expression of mean filter is shown as where M is the pixel set around the center with the coordinate (x, y), N called as the template size is the number of the pixels contained in the neighborhood.Whereas the pixels held by Nonel tube are few, a 3×3 template is enough.
As shown in Fig. (3), the noise has been significantly reduced by mean filter.

Edge Detection
In order to identify the target tubes, the specific Region Of Interest (ROI) should be separated and extracted from the images.In this region, Nonel tube can be measured and defects can be extracted.
The operators used usually in the edge detection include Sobel operator, Marr operator, Laplacian operator, Gradient operator, Krish operator, etc. [11].The Sobel operator performs a 2D spatial gradient measurement on an image and emphasizes the regions of high spatial frequency correspond to the edges.As shown in Fig. (3), there is a large difference in gray levels between the background, tube wall and the inner, which is very suitable for Sobel operator.Therefore, the Sobel operator is adopted for edge detection in this system.
The procedure of the Sobel operator is as follows: taking each pixel as the center in turn, the image is convolved with two 3×3 templates in the horizontal and vertical directions to calculate the respective gradient approximations.Then the approximate gradient magnitude at each pixel is computed by summing the absolute values of two gradient approximations.The Sobel templates in x direction and y direction are shown in Equation ( 2), Fig. (4) shows that the Sobel edge is the clearest and most likely to be extracted, while the noises generated by these operators are roughly equivalent.

Filler Detection
The filler of Nonel tubes is the explosive.According to the different explosive dosage, the explosive filler defects are divided into three categories: excessive explosive, insufficient explosive and black spots.

Dosage Detection of Explosive
In the production process of Nonel tubes, the dosage of the explosive injected into plastic tubes is fixed during a certain time period, so the filler uniformity of Nonel tubes depends on the production speed of plastic tubes.Hence the speed fluctuations in the plastic tubes' production will lead to the dosage defects in the certain segments of Nonel tubes.A dosage detection method for Nonel tubes has been proposed based on machine vision.Firstly, it is the most important to establish the mapping relationship between the explosive dosage and the gray values of Nonel tubes' images.Since the gray value is not a linear function of dosage, it is certainly best to obtain precise function of both by using the curve fitting method [12].But complex calculations caused by precise function would affect the real-time performance.So a segmented calibration method is proposed.Some defective and normal samples are collected, on one hand their dosages are measured by the manual method, on the other hand their images are acquired and their mean gray values in ROI are calculated separately.According to the dosages measured by manual method, these mean gray values fall into three categories related to the insufficient, normal and excessive dosage.The average g in of mean gray values of the samples with the insufficient explosive defects is calculated, and g in is revised as the minimum gray value of the insufficient explosive defects according to the actual production [13].The average g ex is revised as the maximum gray value of the excessive explosive defects by the similar means of g in .
After above dosage calibration, the insufficient explosive defect will be detected when the mean gray value of product falls in [g in +δ, 255]; the product is normal when the mean gray value of product is in (g ex -ε, g in +δ); the excessive explosive defect will be detected if the mean gray value of product is in [0, g ex -ε].Whereδ is the correction factor for the gray values of insufficient explosive defects, and ε is the correction factor for the gray values of excessive explosive defects.The two factors are used to correct the dosage errors under different imaging conditions [14], and their default value is zero.
In order to facilitate the calculation and maintain the detection accuracy, the mean gray value of each segment with the certain length is calculated and compared simultaneously.Taking the insufficient explosive defect as an example, the judgment criteria are as follows: (1) In a longer distance which can be set, such as one meter, if the average gray value (the so-called mean dosage) of the Nonel tube segment is greater than the pre-set minimum gray value of insufficient explosive defects, it is supposed to be the insufficient explosive defect. (2) In a short distance which can be set, such as 0.2 meter, the average gray value of the Nonel tube segment is defined as the so-called transient dosage in order to detect the local insufficient explosive defects.
If the times that the transient dosage is greater than the pre-set minimum gray value of insufficient explosive defects exceed two which can be set, it is supposed to be the insufficient explosive defect.
As long as criterion (1) or ( 2) is met, the barcode signal of the insufficient explosive will be sent out to the marking machine and the number of the insufficient explosive defects will increase one at the same time.The criteria for the excessive explosive defects are similar to the above.

Black Spots Extraction
After determining the edge of Nonel tube, the defects of black spots can be identified and extracted from the ROI of Nonel images [15].Firstly, the ROI is divided into a number of small cells with the same size, the radial and axial intervals of these cells can be set.Secondly, in order to reduce the influence of uneven illumination, mean gray value of every cell is calculated as its feature.And the gray range of normal dosage can be obtained from all the features which would be considered as the parameters for the adaptive defect identification.Meanwhile, when light source attenuation or interference happen, the gray range may properly reduce the sensitivity of image processing algorithms and ensure the robustness of the detection system.Finally, the cells whose features fall below the lower limit will be marked as the black spots, and region growing method is used to join the isolated black spots [16].
According to above method, all the black spots would be partitioned by the respective rectangles containing the whole region of the coherent black spots (see Fig. 5).Additionally, the locations of the black spots regions would be saved in the product database and the marking machine would be triggered to mark these black spots.

DIAMETER MEASUREMENT
Since the edges of Nonel tubes are achieved above, the measurement method based on image processing is proposed to measure the diameter of Nonel tubes.After edge segmentation, a column of the segmented image is selected along the radial direction.And every pixel in the column is scanned continuously from the opposite ends to the middle simultaneously until the gray values of pixels are equal to zero along the two respective directions.
The locations of the two pixels with the gray value zero in the column i are expressed as C ti (x i , y i1 ) and C bi (x i , y i2 ), then the vertical distance of two pixels P i calculated by Equation ( 3) is the so-called logic diameter which represents the number of the pixels possessed by the external diameter of Nonel tube in the column i.Therefore, taking a Nonel tube with the standard diameter D, capture and process its image, get its logical diameters in the different columns, and calculate the scale factor according to the following equations: (3) In Equation ( 4), λ i is the scale factor corresponding to each Pi.In Equation ( 5), N is the total measurement times for standard Nonel tube, and λ _ is the average scale factor calculated through λ i .Once the logic diameter of the certain segment P r is obtained, the diameter of this Nonel tube segment D r is calculated according to the scale factor λ _ and logic diameter P r by Equation ( 6).
Since the standard external diameter of Nonel tubes is 3 ±0.1mm, the Nonel tube whose diameter isn't within the range is judged as the diameter defect, and the minimum resolution is 0.05mm per pixel.When a 2K line scan camera is used to grab Nonel tube images, and the number of the pixels possessed by tube diameter is about 120, then its measure resolution is about 0.025mm per pixel, which can meet the precision requirements.

EXPERIMENTAL ANALYSIS
The software developed with Visual C++ runs to process grabbed images, and analysis results are recorded into SQL Server database.The detection interface is dumped in Fig. (6).In order to test the accuracy of black spots extraction, two Nonel tubes about 50 meters were taken to carry on the defect identification experiments.35 defects and 32 defects were marked beforehand in the Nonel tube A and B respectively, and every experiment on each Nonel tube was repeated for five times.The results are shown in Table 1.The defect recognition rates of two groups are as follows: R a = 96%, R b = 96.9%.
In order to verify the efficiency of external diameter measurement method, a segment of qualified Nonel tube was selected randomly and its diameters at the different locations were measured at intervals of 20mm, the experiment results are shown in Fig. (8).
The curve in Fig. (8) shows that all the external diameters measured by proposed method are between 2.9mm and 3.1mm, which are basically consistent with the actual size.Therefore, this diameter measurement method has high accuracy and stability, and can satisfy online measurement requirements instead of the traditional vernier caliper measurement.Therefore, there are several major breakthroughs in the following aspects: (1) The quality detection system of Nonel tubes based on machine vision has been developed and applied to several Nonel tube manufacturers.The practical operations have proved the defect recognition rate of proposed system can surpass 95% at the detection speed of 100m/min, and system performance can meet quality detection requirements of Nonel tubes.
(2) A method has been proposed to detect the filler uniformity of transparent Nonel tubes based on image processing.The length/mm The diameter/mm

Fig. ( 6 ).
Fig. (6).Screen dump of detection interface.In actual detection process, the mean dosage in the long segment of Nonel tube and the transient dosage in the short stretch of Nonel tube are calculated simultaneously in order to verify the criteria (1) and (2).In Fig.(7a) is an insufficient explosive segment, (c) is a excessive explosive segment, and (b) is a normal segment whose mean gray value is between those of both defects.