Study on steel plate scratch detection based on improved MSR and phase consistency

In the casting process of the steel plate, due to the influence of rolling equipment and technology, the defects such as cracks and scratches appear on the surface of steel plate, which affect the performance of steel plate and even cause production accidents. In this paper, an automatic detection method for steel plate scratch is proposed. Firstly, the steel plate image is decomposed by channel and the enhanced image is obtained by the improved MSR (Multi-Scale Retinex) enhancement algorithm. Then, the phase consistency is detected after the Log Gabor wavelet transform and the scratch areas are obtained by the threshold segmentation and intersection of three channels. Finally, the scratch position is identified and the scratch characteristics such as width and length can be calculated. The results show that the minimum error of the characteristics measurement is only 2.28% in the experimental environment and 4.15% in the field environment, and the mean running time is 0.2826 s in the experimental environment and 0.3193 s in the field environment. It verifies that the proposed method is effective and practical.


Introduction
Steel is an indispensable raw material in the industrial production, With the rapid development of national economy and the continuous intensification of market competition, we put forward higher requirements for the surface quality of steel plate [1]. The surface defect detection methods of steel plate mainly include manual detection, eddy current detection [2], and magnetic flux leakage detection [3]. These methods have problems such as low efficiency, low precision, and unable to describe quantitatively. In recent years, machine vision has the advantages of non-contact, fast speed, high precision and strong anti-interference ability.
Meng Zhang [4] proposed the image enhancement algorithm based on adaptive threshold gray transformation to enhance the quality of steel surface defect image, and then the B Xinbo Huang huangxb1975@163.com 1 image was processed by Gabor filter and image segmentation. Kun Liu [5] established a specific template for each defect image, and the test image was decomposed into structural component and texture component. By calculating the index gradient similarity between template and texture component, various defects on the steel plate surface can be detected. Yue Wu [6] introduced the advantages of residual structure and feature fusion of YOLOv3 model into the Faster R-CNN model and realized the classification of different defects of steel plate. However, these methods were qualitative analysis, and they all processed the ideal images without considering the image samples under non-ideal conditions such as uneven illumination and blurred target. With the development of the scale and technology of steel industry, there is an increasing demand for quantitative analysis of steel plate surface defects.
Therefore, this paper proposes a steel plate scratch detection method. (1) The image is preprocessed by the improved MSR algorithm to reduce the influence of illumination to a certain extent. (2) Scratch is a kind of mechanical damage on the surface of rolled piece. It mainly appears along the rolling direction or perpendicular to the rolling direction [7,8]. And the length are generally greater than 20 mm. After the scratch area is extracted by the improved segmentation algorithm, the scratch location can be marked and the length

Steel plate scratch detection system
The steel plate scratch defect detection system built in this paper is shown in Fig. 1, which mainly includes visual monitoring device, communication network and monitoring center. The visual monitoring device includes CCD (charge coupled device) cameras, light source and power supply. The cameras are set up above the steel plate and are perpendicular to the steel plate plane, and the light source is installed directly above the steel plate. The communication network transmits the image data to the monitoring center. The received images are processed and analyzed by PC (person computer) through intelligent analysis software and various embedded image processing algorithms [9]. Detection results are recorded and stored for qualitative and quantitative analysis of entire steel plate.

Mathematical model of scratch
The mathematical model of steel plate scratch established in this paper is shown in Fig. 2.
(2) The angle α between AB and horizontal direction (0°≤ α ≤ 90°): α is defined as transverse scratch (0°≤ α ≤ 45°) and longitudinal scratch (45°< α ≤ 90°): α arctan (3) The scratch length is represented by the line length between start point A and end point B: [10]. The calculation formula (4) Calculate the maximum width W of the scratch. The image size is m*n, the maximum width of the transverse scratch W t and the maximum width of the longitudinal scratch W l are as follows: where N j is the number of pixels in the scratch area of the j column, N i is the number of pixels in the scratch area of the i row.

Improved MSR steel plate scratch image enhancement algorithm
Due to factors such as equipment and external conditions, it is necessary to enhance the scratch image. The principle of the MSR algorithm [11] is that any image S(x, y) can be extracted into the reflection image R(x, y) and incident image L(x, y) two parts. By combining the filtering results of multiple scales, the reflection component R(x, y) is calculated as the enhanced image. The reflection image is: where W k represents the weight of k scale, K generally takes a value of 3. F k (x, y) represents the Gaussian convolution function of k scale. * represents the convolution operation. Therefore, the image enhanced by MSR algorithm is: However, the W k in Eq. (5) are set manually and the parameters need to be continuously adjusted to obtain the best results. Therefore, an adaptive weight calculation method is proposed in this paper to improve the MSR algorithm. It determines the weights of each scale automatically by calculating the proportion of information entropy of different scale images.
Image information entropy [12] reflects the average amount of information in the image. For the two-dimensional entropy, the neighborhood average gray value of image is selected, which forms a binary feature with the image gray value. The binary feature is denoted as (i, j), where i represents the image gray value (0 < i < 255), j represents the average gray value of neighborhood (0 < j < 255), and P ij represents the proportion of binary feature (i, j): where N(i, j) represents the frequency of binary feature (i, j), M represents the total number of pixels contained in image.The discrete two-dimensional entropy of image is defined as: Therefore, the W k in Eq. (5) can be calculated as: where H k represents the two-dimensional information entropy of k scale, and K represents the number of scales.
After the RGB image is decomposed into R, G and B channels [13], the improved MSR algorithm is used to enhance the three channels respectively. And the final enhanced image is composed of three enhanced channels. The result is shown in Fig. 3.
Calculating the gray standard deviation and information entropy of images in Fig. 3. As shown in Table 1, the MSR and improved MSR both improve the gray standard deviation and information entropy of the original image. Compared with the MSR enhanced image, the gray standard deviation and information entropy of improved MSR enhanced image are larger. The proposed improved algorithm can improve the performance of original algorithm.
The improved MSR enhancement algorithm is performed on the steel plate defect images collected in the experimental environment under different conditions, and compared with HE (Histogram Equalization) [14], SSR (Single Scale Retinex) [15] and MSR. The results are shown in Table 2. In summary, the improved MSR algorithm has higher target definition and contrast, and less background interference, which can effectively improve image quality and lay a favorable foundation for subsequent target segmentation and extraction.

Improved segmentation algorithm based on log gabor phase consistency
The phase consistency method locates the edge in image according to the phase information. After the Fourier transform, the position with the largest phase consistency corresponds to the feature point of the object edge in image [16]. An improved segmentation algorithm based on Log Gabor phase consistency is proposed in this paper.

Phase consistency based on log gabor wavelet transform
Field proposed the Log Gabor wavelet filter in 1987, which can not only construct a filter of any bandwidth, but also be optimized into a filter that takes up a very small space range [17]. The Log Gabor function is [18]: where ω 0 is the center frequency of filter. k/ω 0 represents the shape ratio of filter. The convolution of the signal and Log Gabor wavelet is used to analysis the signal [19]. Assuming that I(x) represents the signal, M e n represents the even wavelet, and M o n represents the odd wavelet, then the amplitude of the wavelet transform of signal I(x) is: The phase is: The phase consistency expression is: where n is the scale of wavelet transform, T is the estimated noise coefficient, and ε is a constant coefficient. ω(x) is the control frequency broadening function and ϕ n (x) is the phase offset. The expressions of them are as follows: where c is the frequency response cut-off value. γ is the coefficient that controls c. q(x) is the frequency broadening function, whose expression is: where A max (x) is the maximum value of A n (x) at x. The Log Gabor PC (phase consistency) detection is performed on the enhanced image in Fig. 3 to obtain the edge feature image, and compared with the canny operator [20], log operator [21] and Gabor PC algorithm. As shown in Fig. 4, the target extracted by the canny operator and log operator is not clear, and the Gabor phase consistency algorithm has many noise points. The Log Gabor phase consistency algorithm can obtain complete scratches without other interference.

Improved segmentation algorithm based on log gabor phase consistency
The two-dimensional Otsu threshold segmentation method can well reflect the spatial distribution relationship of each pixel in image. Assuming that there are Q gray values in an image, [22]:  Table 3. b Mark result. c N i statistical chart The probabilities of the target and background areas in image are: where P ij represents the probability of a certain gray pixel.  Original image

Region growing method
Otsu threshold method

Method in this paper
The two-dimensional average gray levels of the two categories are: The two-dimensional average gray level after the combination of μ 0 and μ 1 is: The formula for the inter-class variance is: When the variance tr(μ B (s, t)) is maximum, there is the following formula: The calculated optimal threshold (s * , t * ) is the required two-dimensional segmentation threshold. The twodimensional Otsu threshold segmentation method is used to segment the edge feature images of R, G, and B channels, and the intersection of three channels are taken as the final defect area. The segmentation result is shown in Fig. 5.
The single scratch and multiple scratch images collected in the experimental environment are selected as samples, and the segmentation comparison results are shown in Table 3. The region growing [23] and Otsu threshold method [24] are used to segment the original image, and the improved segmentation method in this paper is used to segment the improved MSR enhanced image. Whether it is single scratch or multiple scratch image, neither region growing method nor Otsu threshold method can extract a complete defect area, and there are other interference areas. The segmentation method in this paper can accurately extract the defect areas, and the segmentation effect is better.

Scratch defect recognition and characteristic extraction
After adjusting the position and angle of cameras, the actual distance represented by a pixel can be calculated according to the ratio of the actual size and pixel size of vision, and the measured pixel value can be converted into the actual distance. The scratch characteristics can be obtained from the model calculation equations in Sect. 2.2. Take image 1 in Table 3 as examples for analysis.
(3) Scratch length L 30.72 mm. (4) The scratch area in the image is white pixels, counting the number of white pixels N i by row. When N i is maximum, it is the maximum width. As shown in Fig. 6(c), the maximum value of N i is 8 pixels, and the maximum width of the scratch W l 1.64 mm.
As shown in Table 4, 4 images under different conditions are selected as examples. The relative errors between this paper, reference [4,5,25] and manual measurement are calculated respectively (for multiple scratch images, only calculate the characteristic value of the longest scratch), the width errors and length errors in this paper are smaller than those in references [4,5] and [25].
What's more, 200 images in the experimental environment (100 normal images and 100 defect images) are carried out with the series of algorithms proposed above and compared with references [4,5] and [25]. As shown in Table 5, the maximum and minimum errors of length measurement in this paper are 8.76% and 2.28%, and the width measurement are 13.62% and 3.54%. The mean running time of 200 images in this paper is 0.2826 s. Compared with other methods, the proposed method has smaller error and shorter running time.

Field operation test
The steel plate scratch defect intelligent analysis software has installed in the monitoring center, as shown in Fig. 7. Its functions include image reading, image enhancement, image segmentation, defect identification and image save. The processing result of the field image is shown on the right of interface, and the characteristic extraction results are shown at the bottom of interface.
This paper selects 100 field images (50 normal images and 50 defect images) for detection and comparison with actual results. The maximum error and minimum error of the width measurement are 15.43% and 6.37%, and the length measurement are 9.53% and 4.15%. The mean running time of

Conclusions
An automatic detection technology for steel plate scratch is proposed. This paper judges whether there is scratch defect in the image and extracts the characteristics of scratches to realize the qualitative and quantitative analysis. There are many types of defects on the steel plate surface, such as pits, inclusions and cracks. We will collect more different types of defect images for research in our future works, and continue to optimize the system structure and algorithms.

Conflict of interest
The authors have no relevant financial or nonfinancial interests to disclose. And have no competing interests to declare that are relevant to the content of this article.
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecomm ons.org/licenses/by/4.0/.