Uneven Illumination Surface Defects Inspection Based on Saliency Detection and Intrinsic Image Decomposition

Surface defect detection based on computer vision remains a challenging task due to the uneven illumination, low contrast and miscellaneous patterns of defects. Current methods usually present undesirable detection accuracy and lack adaptability for the various scenes. In the paper, the novel uneven illumination surface defects inspection (UISDI) method is proposed to address these issues. First, the multi-scale saliency detection (MSSD) method is proposed to construct a coarse defect map and obtain the corresponding background regions. Second, a novel background similarity prior-based intrinsic image decomposition model (BSIID) is applied to divide the defect image into a non-defective shading layer and a defective reflectance layer. An accelerated optimization solution is proposed to solve the minimization problem of the intrinsic image decomposition model. Last, the enhanced defect image is obtained by filtering the reflectance image and is then utilized to accurately segment the defect region from the coarse defect map. The experiments conducted using four real-world defect datasets demonstrate that the proposed method outperforms state-of-the-art methods.


I. INTRODUCTION
Surface quality has an important role in ensuring industrial product performance. Traditional defect detection is performed by human eyes, which yields low efficiency and a high missing rate. Conversely, surface defect detection based on computer vision satisfies the rapid and accuracy requirements of a production line and has been extensively applied in industrial fields.
However, due to the inherent characteristics of surface defects, three main challenges for the surface defect detection method exist: 1) uneven illumination: due to the change in light intensity or non-uniform distribution of the surface material, the captured defect images from actual production often exhibit uneven illumination in varying degrees; 2) low contrast: the difference between defect and background is very small, especially for the defect image with serious uneven illumination; 3) miscellaneous patterns: the size of the The associate editor coordinating the review of this manuscript and approving it for publication was Ziyan Wu . defect region shows diversity, even for the same category of defect, which proposes high requirements for generalization of the detection method. Typical examples of surface defect images are shown in Figure 1.
In response to these problems, scholars have proposed many effective solutions in the past two decades. The uneven illumination surface defect inspection methods can be classified into three categories: statistical-based approaches, filterbased approaches and model-based approaches.
The statistical-based approaches are usually applied to detect defects in images with uneven illumination by VOLUME 8, 2020 This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/ utilizing the histogram and texture statistics information. Nand et al. [1] compare the entropy difference between defective images and defect-free images to identify the defective regions of steel images. Choi et al. [2] adopt morphological features to detect pinhole defects of steel slab images. Further, Chu and Gong [3] combine the texture descriptors (i.e., local binary pattern and co-occurrence matrix feature) to realize the illumination invariance of the defect detection method. Liu et al. [4] first applied the mathematical morphology to remove the uneven background and then utilized the genetic algorithm to determine the threshold for defect segmentation. However, these methods have a high sensitivity to defect constrast and fail to obtain exact detection results. The filter-based approaches adopt an effective filter to obtain better solutions in the transform domain. Uneven illumination components of the defect image correspond to a low frequency in the frequency domain. Hence, some scholars adopted discrete cosine transfer (DCT) methods to reconstruct the illumination background of the defect image. The differences between the inspected image and the reconstructed background can be employed to obtain the defect region by gray segmentation [5], [6]. Luo and He [7] proposed a dynamic background compensation method to defect hotrolled flat steel images that suffer from uneven illumination. Jeon et al. [8] proposed a novel sub-optimal finite impulse response (FIR) filtering scheme to detect various shapes of defects on non-uniform surfaces. The shortcomings of these methods are that the operating results may lose the defect contrast after image filtering, which will lead to incomplete defect regions.
Model-based methods use certain models with specific constraints to segment defects. For instance, by utilizing the sparsity of defective images, Zhou et al. [9] proposed a double low rank and sparse decomposition model to detect a steel surface image and simultaneously improved the robustness to noise and uneven illumination. Yan et al. [10] developed a smooth sparse decomposition (SSD) model for anomaly detection, which is based on the smooth constraint of the image background and can be applied for other industrial products. Gan and Zhao [11] applied an active contour model to segment the liquid crystal display defect image when the background usually exhibits intensity inhomogeneity. Song et al. [12] proposed a saliency detection model by using multiple constraints and improved texture features (MCITF) to detect a strip steel surface. These methods achieve satisfactory performance in defect detection for uneven illumination defect images. However, for the defect image that has a complicated background, these methods still lack accuracy and suffer from limited adaptability and robustness in industrial practice. Additionally, the low computational speed of these methods is a limitation for real-time inspection.
To sum up, in order to meet the requirements of high precision and high efficiency in industrial production, existing defect detection methods still have the following challenges: 1) Affected by the uneven illumination, existing defect detection methods cannot effectively segment the accurate defect region from the defect images. 2) The existing algorithms have poor adaptability to defects with miscellaneous patterns or low contrast, and fails to detect the whole defect regions. 3) In order to realize the online detection of product quality, the defect detection algorithm needs to meet the real-time requirements.
To solve these challenges, we proposed an accurate surface defect detection method. The method mainly consists of three parts: a multi-scale saliency detection method is proposed to predict the coarse defect map. Second, a background similarity prior-based intrinsic image decomposition method is proposed to separate the defect image into a nondefective shading layer and defective reflectance layer. Last, the reflectance layer image is utilized to accurately segment the defects from the coarse defect map.
Briefly, the contributions of our detection algorithm can be displayed as follows: 1) An uneven illumination surface defects inspection method that is based on saliency detection and intrinsic image decomposition is proposed, which can realize defect detection pixel-wise in an unsupervised manner. 2) A novel saliency detection method for coarse defect detection, which fuses multi-scale Difference of Gaussian (DoG) features to locate the coarse defect regions, which can improve the robustness to miscellaneous patterns of the defects.

3) A novel background similarity prior-based intrinsic
image decomposition is proposed to decompose the defect image into non-defective shading layer and defective reflectance layer, which eliminates uneven illumination, enhances the defect contrast, and benefits accurate defect inspection. 4) An alternating direction minimization method is given to exactly solve the decomposition problem, while another speed-up solver is designed to intensively reduce the computational load, which is very effective in real-time defect detection. 5) Extensive experiments are conducted using four defect datasets to demonstrate the superiority of our method against other state-of-the-art methods.
The remainder of this paper is organized as follows: In Section II, related works about saliency detection and intrinsic image decomposition are introduced briefly. In Section III, the proposed surface defect detection method is described. Section IV describes the evaluation of four defect datasets and corresponding discussions. Section V analyzes the superiority of the proposed algorithm. The paper is summarized in Section VI.

II. RELATED WORK
In this section, the related works on saliency detection methods for defect detection are introduced. The intrinsic image decomposition methods are presented and discussed.

A. SALIENCY DETECTION
Saliency detection aims to simulate the human visual system for detecting the most attractive regions [13]. It has been widely used in the field of object detection [14]- [18]. The surface defects are usually salient compared to the background, the task of defect detection can also be regarded as a saliency detection process.
In recent years, many saliency detection methods for surface defect detection have been proposed and developed. Bai et al. utilized the phase-only Fourier transform method for detecting defects in electronic chips [19]. Liu et al. developed a context-based local texture saliency detection model, which shows promising performance for fabric defect detection [20]. Li et al. employed a learned dictionary to generate saliency maps for fabric defect images, and then an improved valley-emphasis method is applied to segment the defect region based on the saliency maps [21]. Guan et al. proposed the integrated model of top-down and bottom-up visual attention, and the adapted threshold method is employed to detect the defect region [22]. In addition, Guan et al. developed a Gaussian pyramid decomposition-based saliency detection method that constructed a saliency map by the centralsurround differences operation. This method is valid for inhibition of the image background [23]. Recently, Li et al. utilized a context-aware method to obtain the saliency maps. The histogram features of the saliency maps are extracted to discriminate between defective images and defect-free fabric images [24]. Huang et al. designed a customized saliency detection method by fusing a set of dominant cues. This method can achieve a significant saliency performance and satisfy the demand for a real-time inspection process [25]. Zhou et al. proposed a region growing-based saliency detection method for glass defect detection, which divides the glass image into super-pixels and selects the defect regions according to their saliency values [26].
Although previous saliency detection algorithms have produced promising results, several shortcomings still exist. First,for some complex defect images that contain uneven illumination, previous methods are unable to fully inspect whole defect regions, especially when the defect objects locate in the image shadow region. Second, previous methods cannot simultaneously detect all types of surface defects, such as allowing the detection of both large defect objects and small defect objects.
To address these issues, we propose a MSSD method that is based on the illumination-invariant filter (i.e., DoG), it can locate the defect region without the effect of the uneven illumination. This method is suitable for multiple types of defects and generates satisfying coarse detection results.

B. INTRINSIC IMAGE DECOMPOSITION
Intrinsic image decomposition aims to separate an image I into its reflectance layer R and shading layer S as follow: where · denotes pixel-wise multiplication. The reflectance layer is illumination-invariant and represents the structure information, while the shading layer represents the smooth illumination effects. such as shadows [27]. Intrinsic image decomposition is ill-posed because an infinite number of reflectance-shading combinations could be produced. Recent methods have successfully addressed this problem by incorporating constrains on the decomposition model, which is depicted as follows: The Retinex-based algorithm assumed that the shading layer varies slowly, and the reflectance layer is sparse and piecewise-constant. Ng and Wang [28] proposed the first variational framework by considering the spatial smoothness of the shading and piecewise continuity of the reflectance and employed a fast computation method to solve the minimization problem. Many variational models were proposed. Fu et al. [29] propose a probabilistic method for simultaneous reflectance and shading estimation in the linear domain; the enhancement results can prevent overexposure. Furthermore, Fu et al. [30] proposed a weighted variational model for simultaneous reflectance and shading estimation, which can better preserve the details. These models employ the logtransform as pretreatment, which will cause a loss of details in reflectance. Recently, Gu et al. [31] demonstrated that the linear domain model has advantages in protecting edge information than the logarithmic domain model. The author proposed a fractional-order variational model, which has a promising performance for severely low-light images. However, these methods are usually designed to restore and enhance images; the reflectance layer remains uneven to some extent and cannot be employed for defect detection.
To improve the decomposition performance, many priors for intrinsic image decomposition have been explored. Li et al. [32] proposed an intrinsic image decomposition method by adding non-local texture constraints to conventional techniques. Shen and Yeo [33] takes full advantage of the chromatic information and assumed that neighboring pixels have the same reflectance if their chromaticities are very similar. Li and Brown [34] assumed that the gradients of the reflectance layer and the gradient of the shading layers satisfy long-tail distributions and short-tail distributions, respectively. Jeon et al. [35] propose an image model for handling textures in intrinsic image decomposition, which enables high-quality results even with simple constraints. Recently, Ahn et al. [36] proposed a method for estimating high-quality intrinsic images for real-world scenes; the L0 norm was applied to constrain the reflectance sparseness.
These methods have achieved excellent performance for uneven illumination removal in the nature scene, but thery are still not appropriate for surface defect images. Because VOLUME 8, 2020 of the difficulty of distinguishing a defect from shading, the defect information will remain in the shading image, which will generate boundary halo artifacts and low defect contrast in the reflectance image. Therefore, a new intrinsic image decomposition method, which is suitable for surface defect inspection, is needed.
To solve this problem, we propose a BSIID method, which can ensure the non-defective shading image and preserve all the defect information in the reflectance image. In this way, the reflectance image will have a uniform background and enhanced defect contrast. Afterwards, the reflectance image can be employed for accurate defect inspection.

III. PROPOSED METHOD
The proposed defect detection scheme includes four steps: 1) image preprocessing, 2) multi-scale saliency detection, 3) building the intrinsic image decomposition model based on the background similarity constrain, and then optimizing the decomposition model, 4) locating defects by image postprocessing. The whole method is shown in Fig. 2. The details of these proposed methods are described as follows.

A. IMAGE PREPROCESSING
The aim of the image preprocessing is to enhance the contrast between the defect regions and background regions. We first apply the histogram equalization method to normalize the defect image to [0,255], and then adopt the adaptive gamma correction operation (AGC) to enhance the defect images [37]. In this way, the contrast of the original defect images can be improved after image preprocessing, and one sample image can be found in Fig. 2.

B. SALIENCY DETECTION BY MSSG
This section details the saliency detection of a surface defect. By investigating sample images from defect datasets, we determine that all the defect images generally consist of two parts: background and defect. The background region contains no strong structure information. Meanwhile, the defect region can be regarded as the saliency region, which corresponds to the background; so we utilized the saliency detection method to approximately locate defects.
As discussed in [38], the DoG response can reflect the local image structure at the current scale and is hardly affected by the uneven illumination. By taking full advantage of the characteristics of the defect image, we apply the DoG to locate the defect region. Among the DoG image, the defect intensity is larger than the background; so we utilize it to extract the defect region. The DoG operator is defined as the difference between the two Gaussian responses with different standard deviations as follows: where G σ (x, y) = (1 2π σ 2 )e −(x 2 +y 2 ) 2σ 2 is the Gaussian function, and σ denotes the standard deviation. The DoG image can be formulated as: which is equivalent to a bandpass filter of the defect image. In this way, the DoG method has the excellent property of suppressing uneven illumination and defects in the salient defect region. However, the defect information obtained from each scale alone is limited. As shown in Fig. 3(a-d), Fig. 3(a) shows the defect image, which contains the defect with different sizes. Fig. 3 (b-d) show DoG images using different scales, which increase from left to right. We observe that when the defect area is large and the scale is relatively small, only the boundaries of the defect region are salient in the DoG image. Conversely, the defect region will be broadened.
To completely extract the salient defect regions, a multiscale DoG method is proposed to fuse all the DoG features, and to improve the adaptability for different size defects. First, we define the standard deviation as follows: The ith scale DOG image is represented by: In this work, we let σ 0 → 0 + to eliminate the effects of uneven illumination, σ n is determined by the image size as σ n = [min(W /3, H /3)], and W and H denote the height of the image and width of the image, respectively. The number n is set to 3, and the multi-scale DoG consists of three scales. To take full advantage of the DoG information on each scale, all the DoG images should be fused into a saliency map. We consider that each of the DoG images is equally important for the saliency detection; so each DoG map is normalized as follows: We search the maximum saliency metric across all the scales by In this way, the multi-scale DoG features are fused together. The coarse defect map is defined in the following equation: where T is a threshold parameter. The defective points are labeled ''1.''. Note that distribution of the DoG image will be close to the Gaussian distribution. Therefore, the segmentation threshold can be defined as T = µ2δ, where µ and δ are the mean and standard deviation, respectively, of the candidate defect map. Fig.3 (e) shows the coarse defect map results. We discover that the MSSG can adapt to different sizes of defect images. Nevertheless, the defect regions contain not only the true defects but also noise points, which requires the next accurate defect detection process.

C. INTRINSIC IMAGE DECOMPOSITION BY BSIID
This section aims to decompose the enhanced defect image into shading and reflectance layers. The reflectance layer is employed for the next accurate defect detection. This decomposition process can not only remove the effect of the uneven illumination but also enhance the defect contrast.
The shading layer calculation is key to the decomposition process. Different from the traditional methods that simultaneously calculate the shading and reflectance layer, we propose the BSIID method that only estimates the shading with some constrains. The reflectance can be functioned as R = I /S, where the division is element-wise. This method can not only shrink the solution space but also reduce the computational cost to reach the desired result. Because it is highly ill-posed, we introduce the decomposition priors as our constraint, including: 1) The shading layer image is similar to the defect image in the background region.
2) The shading layer image is spatially smooth. To simultaneously preserve the background similarity and smoothness constraint. We propose solving the following optimization problem: The first term is an L2-norm fidelity term that ensures the similarity between the shading layer and the original image in the background region. The second term is an L1-norm regularization term that guarantees the smoothness constrain of the shading image. B represents the background map weight, which can be obtained through the saliency map as B = 1 − D, The traditional fidelity term 1 2 (S − I ) 2 2 , which constrains the similarity of the whole image region. We introduce background similarity prior into fidelity terms. Fig. 4 shows the decomposition results.It is obvious to see that the defect information will remain in the shading layer by the traditional methods, which will generate boundary halo artifacts and low defect contrast in the reflectance layer. On the contrast, the proposed method with background similarity prior can prevent the defect information from existing in the shading layer and avoid halo artifacts around the defect region. The defect contrast will be enhanced after the image decomposition.
λ is the balancing parameter. Hence, increasing λ will smooth the shading image but affect the background similarity, and decreasing λ produces a better background similarity result but poor smoothing on the shading image. To achieve satisfactory trade-off between the background similarity constrain and the smoothness constrain, we adopt the local smoothness weight M as follows [39]: where ∇ is the gradient operator, and is a local patch with the size r × r (r is set to 3 in this paper). ξ is a small number that avoids division by zero, which is empirically set as 0.001.

D. OPTIMIZATION OF THE DECOMPOSITION MODEL 1) EXACT SOLUTION
Problem (9) is difficult to solve directly because of its nonconvex properties. Therefore, we utilize the alternating direction minimization (ADM) technique to transforms the energy function into a series of convex optimization problems. First, the two auxiliary variables T 1 and T 2 are introduced as follows: where X = {T 1 , S, T 2 }, The augmented Lagrangian function of Eq. (11) can be naturally written in the following equivalent model: where V 1 and V 2 are the Lagrangian multipliers, θ 1 and θ 2 are positive penalty constants. The optimal solution can be obtained by iteratively updating one variable at a time, while fixing the other variables. The problem in Eq. (12) is split into the following three sub-problems.
Step 1. Updating T 1 : Collecting the terms related to T 1 , T k+1 can be solved by the following minimization problem: This problem is a classic least squares problem, which has a closed form solution, is denoted as Step 2. Updating S: In the same way, the problem S k+1 ← min S L A T 1 k+1 , S, T k 2 , V k 1 , V k 2 can be solved by minimizing the following problem: whose closed-form can be obtained using two-dimensional (2D) fast Fourier transform (FFT) techniques with the assumption of the circular boundary condition.
where F and F −1 denote the discrete Fourier transform and inverse Fourier transform, respectively, and ∇ are the Toeplitz matrices from the discrete gradient operators with forward difference. Directly calculating the matrices F ∇ T ∇ is computationally expensive. According to [1], the matrix F ∇ T ∇ is equivalent to 2 cos(2πu/p) + 2cos(2πv/q) − 4, where m and n represent the image width and height, respectively, and u ∈ [0, p) and v ∈ [0, q) are the frequencies in the frequency domain.
Step 3. Updating T 2 : The problem T k+1 can be solved by minimising the following problem: This problem is a typical L1 norm minimization problem. The solution can be easily obtained by performing the shrinkage operation as: where Soft (x, τ ) = sign (x) max (|x| − τ, 0), in which the calculations are performed element-wise.
Step 4. Updating V 1 and V 2 : The updating of V 1 and V 2 can be performed via: At this point, all the variables have been updated, and they are fed back to the next iteration. The iterative refinement of S stops until the condition satisfies: S k+1 −S k S k+1 ≤ ϕ, where ϕ is the small threshold that controls the iterations. The whole exact solution is summarized in Algorithm 1. Fix the others and update T 1 by T k+1 Fix the others and update S by Fix the others and update T 2 by T k+1 Update two Lagrange multipliers by Check the convergence conditions: update the iterations k by k = k + 1 9: end while

2) SPEED-UP SOLUTION
To satisfy the real-time requirement of defect detection, we proposed two speed-up strategies to reduce the time cost. The details are presented as follows: Strategy I: Approximate Solver Since the L1-norm in the regularization term is nonconvex, solving Problem (9) is difficult. To mitigate this problem, we obtain the approximation of L1-norms as where ζ is a small positive constant to avoid a zero denominator, which is empirically set to 0.001. After the approximate transformation, the problem (9) only involves quadratic terms. We reformulate it into matrix form: where S, I, and M are the matrix forms of S, I , and M , D is the Toeplitz matrix from the discrete gradient operators with forward difference. M is the diagonal matrix that contains the weight M as follows: The solution for Eq. (23) can be directly obtained by solving the following linear function: To efficiently solve Eq. (24), we compute the inverse using the preconditioned conjugate gradient (PCG) [40] technique, where the complexity is reduced to. Strategy II: Downsampling A Gaussian pyramid is employed to reduce the input image size and further improve the computational efficiency. In the Gaussian pyramid, the original image I is decomposed into a sequence of images I i , i ∈ {0, 1, 2, 3 . . . , N }, The ith layer image is selected as the input image of the decomposition model. After the optimization, the resulting map is resized to exactly the size of the original image. Here, the layer number N is permanently set to 2 since it can not only improve the speed but also hardly changes the illumination information.The whole speed-up solution is summarized in Algorithm 2.

E. IMAGE POSTPROCESSING
After the defect image decomposition, the reflectance image still contains noise or other background texture information, which will cause many inspection errors. Thus, we need to process the reflectance image to reduce the influence of noise and background texture and then improve the robustness to localization error. To effectively solve this issue, we applied the guided filter in the paper [41]. According to the experimental results, we set the local radius γ = 3 and ε = 0.1, which can achieve the best result. The defect result is segmented via the adaptive threshold method Otsu to locate the defective regions. However, this method does not perform well when the defect is much smaller than the background. Considering this factor, we slightly adjust Otsu by removing all background pixels from the coarse defect map before applying Otsu. The final segmentation result can achieve accurate defect detection.

IV. EXPERIMENTAL
In this section, we first introduce four defect datasets, which are typical defect datasets with uneven illumination. Then we adopt three metrics to evaluate the performance of the surface defect inspection methods. Last, we compare our proposed method with some state-of-the-art methods and illustrate in detail how these methods perform. We implement all the algorithms using Matlab on a laptop with an Intel i7-6700 3.40GHZ CPU and 8GB of RAM.

A. DATASETS
To prove the applicability and generality of the proposed method, three public defect datasets and one actual surface defect dataset are adopted. The details are presented as follows: NEU Dataset: The Northeastern University (NEU) surface defect dataset [42] is a steel strip dataset that contains six types of defects. Each class includes 300 images with bounding box annotations; the size of each surface defect image is 200 × 200. In the work, two typical defects (inclusion, patch) are selected to demonstrate the effectiveness of the propose method on a surface defect image with uneven illumination. Then we utilize the open annotation tool LabelMe to make corresponding ground truth images. Due to the influence of the illumination and material changes, most of these defect images contain low contrast defects and non-uniform backgrounds. Moreover, there are large differences in the size of the defect regions. These characteristics contribute great challenges in defect detection.
MT dataset: The magnetic-tile (MT) dataset includes five types of defects [43], and all the defect images are captured with arbitrary resolution. Every defect image corresponds to a pixel-level ground truth image. However, some defect images in this dataset contain a severe vignette effect in the corner, which is beyond the scope of this paper. This paper detect surface defect images in an unsupervised manner. Therefore, we crop the corresponding interference region in this dataset to ensure that they only contain the most relevant defective regions. For the effectiveness of evaluation, the blowhole dataset is selected for the experiment. According to our observations, we determine that the defect sizes are very small compared to the background. In addition, the backgrounds of these dataset images are uneven and not conducive to defect detection.
RSDD Dataset: The rail surface discrete defect (RSDD) dataset contains two types of datasets [44], in which each defect image corresponds to a pixel-level ground truth. The Type-I RSDD dataset, which is captured from express rails, contains 67 defect images. The Type-II RSDD dataset, which is captured from heavy haul rails, has 128 defect images. Specifically, each image from these two datasets contains at least one defect. The backgrounds of the defect images have a complex intensity distribution and noise, which creates a challenge for detection.
MCSD Dataset: The motor commutator surface defect dataset (MCSD) was captured from actual optical detection equipment. This defect dataset includes 200 motor commutator defect sample images. The resolution of the defect sample images is 500 × 250. To verify the segmentation accuracy, the corresponding ground truth images are generated by the open annotation tool LabelMe. Due to the curvature of the motor commutator surface, the gray level distribution in the whole image is changed gradually. The defect images are affected by severe uneven illumination. In particular, when the defect locates in the shadow region, the contrast between the defect and the background should be very low, which will greatly affect the defect detection.

B. EVALUATION METRICS
To statistically evaluate the performance of the method, three indicators, including Precision, Recall, and F-measure, are employed in this paper. These indicators are defined as where TP denotes the number of successfully detected defect pixels, FP is the number of pixels that is mistakenly detected as defects, and FN indicates the number of undetected defect pixels. The F-measure, which is based on precision and recall, is calculated to evaluate the overall performance. The test method is more effective with a higher F-measure.

C. COMPARISON WITH STATE-OF-THE-ART METHODS
To evaluate the effectiveness of the proposed algorithm, we compare it with other three state-of-art methods that are employed to detect defect images under uneven illumination. The compared methods include DCT [5], SSD [10], and MCITF [12]. The DCT method is based on the discrete cosine transform and can remove the influence of uneven illumination for defect inspection. The SSD method detects abnormal regions in test images by sparse and smooth decomposition. The MCITF method is a saliency detection model that is based on multiple constraints and improved texture features. To maintain the fairness of the comparison, all of these methods use default parameters. The corresponding detection results obtained by different methods are shown as follows:

1) DETECTION RESULTS
Detection Results on NEU Dataset: Fig. 5 shows some typical defect images selected from the NEU dataset and the corresponding inspection results. It is observed that the DCT and SSD can achieve satisfactory results for mediumsized or small defects (the 1-3 columns). However, they easily miss the defects with a large size (the 4-6 columns). The MCITF method can locate and detect defects but may magnify some low-contrast defect areas (the 2-3 columns). However, the proposed method achieves the best performance in challenging cases of defect detection, e.g., low-contrast and diversity of the defect size, and the results are very similar to the ground truth. Detection Results on MT Dataset: Fig. 6 shows some typical defect images selected from the MT dataset and the corresponding inspection results.The uneven texture background of defect images may affect the final defect detection results. It can be determined that although both DCT and SSD can accurately locate defects, they can easily falsely consider parts of the texture background as defects. The MCITF method is easy to produce false positives, especially for those defect images with low contrast between the backgrounds and the defects (the 3 and 5 columns). Meanwhile, the proposed  method can restrain the influence of the texture background and obtain satisfactory detection results.
Detection Results on RSDD Dataset: Fig. 7 shows some typical defect images selected from the RSDD dataset and the corresponding inspection results.The complex background VOLUME 8, 2020 with uneven illumination is a big challenge for defect detection. MCITF-based on saliency detection fails to detect defects, which may treated a large amount of background regions as defect regions. The DCT method can approximately locate defects but the defect results are incomplete for large-area defects. The SSD method can obtain better detection results than the DCT method. However, due to the low accuracy of fitting in the background, the SSD method tends to mistake parts of the background as defects. The results of the proposed method are very similar to the ground truth.
Detection Results on MCSD Dataset: Fig. 8 shows some typical defect images selected from the MCSD dataset and the corresponding inspection results. The main challenge of this dataset is the uneven illumination, which may lead to low contrast when the defect is in the shading region. The DCT method lacks integrity in detecting the defect area; only part of the defect is retained. The MCITF incorrectly determines a large amount of background areas as defects, especially when a part of the defect is in the shading area. SSD and the proposed method can effectively locate defects from the uneven illumination background. However, the result of SSD may affect the random texture of the commutator surface. Conversely, the performance of the proposed method is closer to the ground truth.

2) QUANTITATIVE EVALUATION
The quantitative segmentation results of the four defect datasets with the compared methods and our proposed method are exhibited in Table 1. The precision, recall, and F-Measure of the proposed UISDI method have achieved the highest level among the compared methods. For the RSDD dataset, the recall of the proposed UISDI method is slightly lower than that of SSD but the precision and F-measure of the proposed UISDI method are obviously better than the SSD. These experimental results further confirm that the effectiveness of the proposed UISDI method is better than that of the other compared methods. Our method has three merits over the comparative approaches: • First, the proposed method can detect various size defects since we have applied the multi-scale saliency detection algorithm to adapt to the miscellaneous patterns of the defects.
• Second, the proposed method can obtain accurate boundaries of the defective regions, especially for regions with uneven illumination and low contrast defects, because we proposed the intrinsic image decomposition method, which completely removes the influence of uneven illumination and enhances the defect contrast.
• Third, the proposed method can obtain the accurate defect regions without interfaces, owing to the postprocessing, which eliminates the noise and background texture information of the reflectance image.

3) COMPUTATIONAL COMPLEXITY ANALYSIS
Computational complexity is a significant aspect of real-time defect inspection. We analyze our method with the other compared methods, the average running time to process the defect images of different methods is shown in Table 2. It can be determined that the cost time of our method is not the shortest but the speed can reach 16-40 fps/s, which satisfies the real-time requirements of industrial inspection and does not hinder the user experiences. Since our code is written in Matlab code, it could be further accelerated by C/C++ programming and graphics processing unit (GPU). Specifically, the most time-consuming part of our proposed method is the intrinsic image decomposition. Table 2 gives a comparison between the exact solver and the speed up solver in terms of time cost. It is obvious to see that the average processing time of the speed-up solver is lower than that of the exact solver. Due to the approximate solution and down-sampling operation, the computational complexity of our proposed method is greatly reduced, which is more attractive for practical defect detection.

V. ANALYSIS AND DISCUSSION
To further verify the superiority of the proposed method, we analyze the two main components: the effects of proposed MSSD method and the effects of proposed BSIID method. Then, the robustness of the regularization parameter is analyzed. Last, we discussed the limitations of our proposed method and future optimization directions. Since the NEU dataset is the most complex and diverse compared to the other datasets, all the subsequent analysis are test on NEU dataset.

A. COMPARED WITH OTHER SALIENCY DETECTION METHODS
The proposed MSSD method is utilized to realize the coarse detection of the defect images with uneven illumination. To verify its performance, we compared MSSD with three other saliency detection methods: HFT [45], SHFT [46], 2SLG [47], IDCL [48]. The final detection results of all the methods is shown in Figure 9. It is obvious to see that our method generates more entire defect map compared with other saliency detection methods. Then, we adopt the Recall metric to evaluate the integrity of the saliency detection results by different methods. The larger the Recall value, the better the performance. Tables 3 demonstrates the   superiority of the proposed MSSD method in improving the integrity of saliency detection result.

B. COMPARED WITH OTHER INTRINSIC IMAGE DECOMPOSITION METHODS
The proposed BSIID method is employed to remove the influence of uneven illumination of the defect image. To prove the effectiveness of the BSIID model, we compared it with VOLUME 8, 2020   five other intrinsic image decomposition methods: THQII [49], IIDOU [50], SRIE [51], JieP [52], PLE [29]. As shown in Fig. 10, the proposed BSIID method can more thoroughly remove uneven illumination, and enhance the contrast between the defect region and background region. To quantitatively evaluate the intrinsic decomposition methods, we introduce the Average Gradient of Illumination Component (AGIC) indicator [53], to evaluate the degree of uneven illumination of the reflectance images. A greater value indicates a more uneven illumination. The results are shown in Table 4, which prove the effectiveness of our proposed BSIID method in removing uneven illumination.

C. PARAMETER ANALYSIS
The regularization parameter λ balances the fidelity term and the regularization term. When the parameter λ increases, the fidelity between the shading component and defect image decreases, whereas the smoothness of the shading component increases, which will retain more details in the reflectance component. We set the parameter to {0.05, 0.5, 1, 5, 10, 20} and the intrinsic image decomposition results are shown in Fig. 11. We can see that the shading images become smoother gradually, but there is almost no change in the reflectance images from Fig. 11 (b) to (d). However, from Fig. 11 (e) to (f), as the shading component becomes smoother and away from the illumination distribution of the defect image, the reflectance component will becomes uneven gradually. This will affect the accuracy of the defect detection results. To further quantitatively verify the influence of regularization parameters on defect detection, we test the defect detection accuracy of different regularization parameters, which are displayed in Figure (12). It shows that the proposed method achieves stable performance with λ in the range [0.05, 1]. In this paper, λ is set to 0.5.

D. LIMITATIONS AND FUTURE WORK
Although our method achieves promising results in detecting uneven illumination defect images, it has a poor performance in two cases. Firstly, when the defect area is far larger than the background area, the detection result is lack of integrity, which is shown in Figure 13 (Column 1). Secondly, if part of the background regions is similar to the defect regions in term of texture and intensity, the corresponding background part may be mistaken as the defect, which displayed in Figure 13 (Column 2). In order to solve these problems, we need to find a solution to better distinguish the background area and the defect area. Considering the powerful representation ability of deep learning, we will utilize the deep features learned from convolutional neural networks to improve the detection accuracy of the proposed method in the future [54].

VI. CONCLUSION
In this paper, a novel UISDI method that employs saliency detection and intrinsic image decomposition, which can accurately and efficiently detect diverse types of defects under uneven illumination, was proposed. The proposed method was tested using four real datasets in an unsupervised manner. The main research work is summarized as follows: 1) The MSSD method is proposed to coarsely detect the defect regions, which can adapt to different types of defects.
2) The novel BSIID model, which is based on a background similarity constrain, was proposed to eliminate the effect of uneven illumination and improve the contrast between the defect and the background.
3) The speed-up optimization method was proposed to solve the intrinsic image decomposition model, which improves the efficiency of the proposed method. 4) The experiments were conducted with four realworld defect datasets. The results demonstrate that our method obtains excellent performances in both qualitative evaluations and quantitative evaluations compared to other state-of-the-art methods and satisfies the realtime requirement of actual inspection.