Defect Detection on Texture using Statistical Approach

In this paper we present several techniques for detecting a simple defect on the texture. The simple defect is the defect that can be detected directly via image histogram or via image histogram of the transformed original image in the wavelet space. In this proposed method we used kernel density estimate instead of histogram for presenting the distribution of the image gray levels. The simple defect can be detected as the area in the tail of the image gray level distribution. Therefore a threshold in the left or right (or both) side(s) of the gray level distribution is needed. This threshold will indicate the defected area to the non defected area in the image distribution. In this paper, we used three techniques to determine the threshold poin. The first one, we used the concept of significance level in statistical hypotheses, we assume that the probability of the defect gray level lies in that level, e.g. alpha = 5%, the threshold point in this approach is the point in the gray level (x-axis of the distribution) that makes the probability of the gray level equal to alpha. The second approach, we used the modified Otsu method, and the last one we used the Hill estimator. These approaches will produce a rectilinear which covers the defected area. The smallest the rectilinear can detect the defected area the better the performance of the proposed method. In this way of measurement, Hill estimator performs better than the other two proposed methods.


Introduction
Visual inspection on texture has played a role in the quality control in recent years, since products' quality control has been designed and presented to ensure not giving defect products to customers. The human doing quality control has been replaced by mechanics and visual vision has been replaced by computer vision.
Finding defects automatically for any types of texture have been a research topic for several years. Some methods have been developed in many field of interest, Peyré [1] proposed a new method to synthesize and inpaint geometric textures, Liu and Fieguth [2] classified the random features of texture based on random projection, Cavalin, et al. [3] developed wood defect detection using gray scale images and optimized feature set. Their measurements include the contrast, energy, entropy and correlation in the images. Yang, et al. [4] applied the adaptive wavelet for fabric defect detection. They occupied non sub sampled octave band filter bank and discrete wavelet frame for constructing their procedure. Other approach in the multi resolution decomposition was given by Moahseri et al. [5]. 1 Faculty of Industrial Technology,Industrial Engineering Department, Petra Christian University, Jl. Siwalankerto 121-131, Surabaya 60236. Indonesia Email: halim@petra.ac.id * Corresponding author Timm and Barth [6], approached this problem by computing the distribution of image gradients and then fitted the Weibull and determined the shape and scale parameters to detect the defect on the texture. Franke and Halim [7,8], also handled this issue by comparing signals and images using wild bootstrap tests. Peng, et al. [9], used a set of multi criteria decision methods to rank classification algorithms for detecting defect on texture datasets.
Generally, texture is a visual property of a surface, representing the spatial information contained in object surfaces, Haindl [10]. Depending on the size of variations, textures range from purely stochastic, such as white noise, to purely regular such as chessboard. Based on the sense of its regularity structure, basically texture can be classified into three different classes: regular texture, random texture, and semi-regular texture ( Figure 1).
In this paper, we elaborated a method for detecting a simple defect, i.e., defect that occurs as outliers to the texture and can be recognized as different spots of gray level to the image (See Figure 2).  On this type of defect, its density function has tendency to be a skew distribution, either to the left (dark gray level) or to the right (light gray level) depends on the gray level of the defected area. If the defected area is darker than the non-defected one, then the distribution will be skew to the left. Otherwise, it is skew to the right.
However, sometimes the defect is hard to detect directly from the original image, e.g. the defect on the wood (center image of Figure 2). The defected area will come to the surface if we use wavelet transform to the image. Wavelet transform is like Fourier Transform. Fourier Transform decomposes signal into sines and cosines, while wavelet decomposes signal into more general functions that follows several rules. Some examples of wavelet functions are Haar wavelets, Daubechies wavelets, Mexican hat. It is well known that wavelet is very powerful to detect "jump" on the pattern (Nason [11]). Therefore, before we proceed with finding the defect, we use wavelet transform as the first step of the procedure, and look for the most suitable space such that our method can perform well. Figure 3 and Figure 4 exhibit examples of finding a simple defect in the texture. At first, we transform the original image using wavelet transform. In Figure 3, the structure of the image is simple, the defect can be seen clearly as a spot in the image. In the approximation space of the wavelet the spot is clearer than the other spaces, and the distribution of the gray level shows that the distribution is skew to the right. The correct threshold of the distribution will indicate, which area can be spotted as defect area, and which ones are not. While for the Figure 4, the structure of image in Figure 4 (that is wood) is more complex than the structure of image in Figure 3. Directly estimating the distribution of the gray level in Figure 4 will not make the defect area exhibit. However, using wavelet transform, we can see in the horizontal scaling, the defect part of the image is appeared. Additionally, the histogram of the gray level is stiff and it has two thresholds (in the left and right) for indicating the defect area.

Methods
The idea of this propose method is first, we transform the image into the wavelet space, since it is more robust for detecting the defect in the image (see Figure 4), and then using the kernel density we will calculate the density of the gray level of image. Kernel density is smoother than the histogram for estimating the density of the gray level. Finally, we used several methods for detecting the threshold for separating the defect spot to the not defect one.
In this section we will give a brief description of kernel density estimate, for detail explanation please refer to Wand and Jones [12]. Further, we will explore the threshold procedure for finding the defected area on the simple defect detection and at the end we present the result of this procedure.

Kernel Density Estimate (KDE)
Let be an i.i.d. sample drawn from a distribution with an unknown density ƒ. We are interested in estimating the shape of this function ƒ. Its kernel density estimator is; where is a kernel function and is the bandwidth.
Some properties of KDE: (1) To ensure should be symmetric and have a unique maximum at 0 and also ∫ is to take as probability density function (pdf). (2) To ensure that a kernel estimator has attractive mean squared error properties, it turns out to be important to choose so that ∫ , ∫ , ∫ , denotes for a kernel It is well known that the choice of kernel functions will not change the estimation significantly. However, the choice of bandwidth matters on the density estimation. Since, if the bandwidth is too small then the bias of a kernel estimator becomes smaller in magnitude, but its variance will increase, and vice versa. Moreover, smaller bandwidth makes the kernel estimate becomes too wiggle, and it becomes over smooth when the bandwidth is large. Therefore the principal goal in kernel estimation is to find an "optimal" bandwidth.
achieved via optimizing the mean square error

Optimal Bandwidth
To get the optimal bandwidth we have to trade-off compromise between the bias and variance of the KDE. Fortunately, this trade-off comprise can be (MSE) of the estimator, since by definition: Take the integration of (2) then we get, The bias and variance of (3) can be written consecutively as: Put equations (4) and (5) into (3) and let n then we get the Asymptotic MISE, i.e.
Finally, we take derivative of (6) with respect to and solve for the derivative equal to zero, then we get the optimal global bandwidth, i.e., the bandwidth will be the same for the whole function of estimate.

Determine the Threshold
There are three approaches that we are going to explore in this paper. The first one, is the simple threshold, i.e. we assume that the probability of the defect gray level is greater than (or less than) for example 5%. The second one is automatic thresholding using modified Otsu [13] methods and Hill estimation for measuring the tail of the distribution [14].
Basically, before we define the threshold, we should know the shape of the gray level distribution, i.e., skew to the left, skew to the right or symmetry.

Simple Threshold
Depend on the shape of the gray level distribution, we can have either one-sided threshold (if the shape of distribution is skew to the left or right) or twosided threshold (for symmetry distribution) ( Figure  5). Let is the threshold, then if the shape of the distribution skews to the left, the threshold is just the upper bound of the integral ∫ , where is the density function that can be approximated by kernel density function (1), is assumed probability of the defected gray level, e.g., . For the right skew the threshold is determined by∫ , while for the symmetry distribution it determines by∫ ; and ∫

Modified Otsu Method
We will describe a brief review of the Otsu method for selecting optimal image threshold. Let the value of gray-level ranging from 0 to L-1, where L is the number of distinct gray level. Let the number of pixels with gray-level be and be the total number of pixels in a given image, then can be regarded as the probability of occurrence of graylevel and ∑ as the average of the entire gray-level. For a single thresholding, the pixels of an image are divided into two classes and where is the threshold value. The probabilities of the two classes are: ∑ and ∑ . The mean gray-level values of the two classes can be computed as Using discriminant analysis, Otsu [14] showed that the optimal threshold can be determined by maximizing the between-class variance, i.e., (9) Where the between-class variance is defined as (10) Hui-Fuang [13] modified (10) by emphasizing the valley of the distribution, i.e., (11) and substitute the in (9) with in equation (11). The key to the valley-emphasis formulation is the application of a weight, , where the smaller the value of (low probability of occurrence), the larger the weight will be.
In this work, instead of using the discrete probability for measuring the occurrence of gray-level in the image, we use the continuous probability ∫ ̂ and continuous first moment A comparison of these two approaches is given in the Figure 6. The density of the defected image is right skew, the skewness measurement is positive (0.8358). It tells us that the defected area would belighter than the non-defected area, and it is matched to the image in Figure 6a, i.e., indeed the defected area is in nearly white color. Moreover, the expected threshold should be around 1.0 (the right tail of the distribution). We can see clearly in Figure  6c and 6d, that the threshold point suggested by modified Otsu method gives a close guess to the expected threshold point.

Let the Tails Speak for Themselves
Let from the distribution with algebraic tail form as , where is the reversed order statistics, is called the upper tail index. Hill [14], introduced an estimator where is the number of observations above the threshold . Equation (12) requires a choice of .

Choosing the Cutting Observation
Renyi` representation theorem: where identically.
Fundamental theory of rank statistics says that and . Inverting and solving for : By definition ( ) Now (14) can be formulated as Test the hypothesis comes from an exponential distribution for Once the hypothesis of is rejected at certain then we got the threshold.

Results
We compare three methods we presented above for a single image, which give different performances. First, we used a trial and error threshold. After several trial and errors, from large to small gray level probability, the trial could not detect the defected part of the texture (see Figure. 7a, for gray level probability, ). The defected pixels are scattered in the whole image.
Next, we used the hill estimator (15), and found that the stopped at twenty. The defected pixels can be clustered into one region, and when the clustered positions are transferred into the original image, we found the defected area (see Figure 7b). For the Otsu method and modified Otsu method, we first smoothed the image to get a better result. The modified Otsu method produces compact clustered defected image, that the classic one. For the classic Otsu method, after clustering the defected pixels, we then discarded the clusters which only have a few members (e.g. less than 10 pixels). Even the result in the original image is the same for this case; the modified Otsu method gives more robust defect detection than the classical one.
The three proposed methods can be combined with the trial and error using . Since, the modified Otsu is more robust than the classic one; we do not include the classic Otsu method into the procedure of finding threshold for detecting defect on the texture procedure of finding threshold for detecting defect on the texture:

Conclusion
In this paper we transformed the original image into wavelet space and used kernel density for measuring the image histogram. We then applied three approaches for detecting the threshold points in the image density. The threshold points indicate the defect spot in the image. In the first approach, i.e. using simple threshold, we need to do some trial and error in determine the value of the alpha. While for the second and third approaches, i.e., modified Otsu and Hill estimator, the threshold can be detected automatically. We also proposed a procedure. The procedure will produces a rectilinear which cover the defect area (see Figure 7 and 8). The smallest the rectilinear can detect the defected area the better the performance of the proposed method. In this way of measurement, Hill estimator performs better than the other two proposed methods.
In this works we only can detect a simple defect in one location. Combining the Hill estimator with clustering analysis can detect more than one defect on the texture, which can be done in the future research. Since, this method only work for simple defect, this method fail to detect pattern defect, which also will be elaborated in the future research.