Novel Framework Based on HOSVD for Ski Goggles Defect Detection and Classification

No matter your experience level or budget, there is a great ski goggle waiting to be found.Goggles are an essential part of skiing or snowboarding gear to protect your eyes from harsh environmental elements and injury. In the ski goggles manufacturing industry, defects, especially on the lens surface, are unavoidable. However, defect detection and classification by visual inspection in the manufacturing process is very difficult. To overcome this problem, a novel framework based on machine vision is presented, named as the ski goggles lens defect detection, with five high-resolution cameras and custom-made lighting field to achieve a high-quality ski goggles lens image. Next, the defects on the lens of ski goggles are detected by using parallel projection in opposite directions based on adaptive energy analysis. Before being put into the classification system, the defect images are enhanced by an adaptive method based on the high-order singular value decomposition (HOSVD). Finally, dust and five types of defect images are classified into six types, i.e., dust, spotlight (type 1, type 2, type 3), string, and watermark, by using the developed classification algorithm. The defect detection and classification results of the ski goggles lens are compared to the standard quality of the manufacturer. Experiments using 120 ski goggles lens samples collected from the largest manufacturer in Taiwan are conducted to validate the performance of the proposed framework. The accurate defect detection rate is 100% and the classification accuracy rate is 99.3%, while the total running time is short. The results demonstrate that the proposed method is sound and useful for ski goggles lens inspection in industries.


Introduction
Ski goggles, or snow goggles, are essential for winter sporting activities like skiing and snowboarding. Factors such as an increase in disposable income and participation in outdoor recreational activities will contribute to the growth of the ski goggles market in the coming years. Skiing and snowboarding are sports that require precaution to help keep you safe as. when you cannot see well, you are more likely to injure yourself. Goggles are an essential part of skiing or snowboarding gear to protect your eyes from harsh environmental elements and injury. These sports expose your eyes to prolonged periods of harsh wind and bright sunlight. Unlike sunglasses, goggles seal your eyes from cold air, and many goggles come with lenses that block UV light, and reduce glare effects from the snow. Goggles protect your eyes from airborne snow and debris and shield them from hazards such as tree limbs and fallen branches. Ski goggles also stay securely on your head at times when sunglasses would fly off.

1.
The ski goggles lenses have a spherical surface different in size and curvature, as shown in Figure 1. Thus, capturing a two-dimensional image of the entire ski goggles lenses is a major challenge; 2.
Lenses are normally made from a polycarbonate or Trivex plastic. However, lenses are coated for multiple purposes with tints, anti-UV, or polarization, which have different light reflections. So, designing a lighting source for an image acquisition system that satisfies all types of ski goggles lenses is also a challenge; them from hazards such as tree limbs and fallen branches. Ski goggles also stay securely on your head at times when sunglasses would fly off. Ski goggles have many components, of which the most important component is lenses, which all have an important role in improving your vision, protecting your eyes, and keeping you comfortable. Nowadays, the global ski goggles market is expected to grow at a compound annual rate. In the ski goggles manufacturing industry, defects, especially on the lens surface, are unavoidable. So far, experts have classified the defect types manually. If we know the exact type of the given defect, not only can we remove the defects but also find what part of the fabrication process has problems. Because of the importance of the ski goggles lens, the defect detection and classification process, in order to ensure the high standard of the ski goggles lens, plays an extremely important role for manufacturers.  On most goggles, the lens consists of two separate lenses, called outer lens and inner lens, as shown in Figure 1. Lenses are normally made from a polycarbonate or Trivex plastic, which makes them more impact resistant and less likely to shatter than glass or normal plastics. Virtually all ski goggle lenses today protect you 100% from UV light and prevent harmful UVA, UVB, and UVC rays entering your eyes. There are two different shapes of goggles lenses: flat and spherical. Flat lenses To overcome the above challenges, we propose a novel framework based on machine vision, named ski goggles lens defect detection and classification system for real-time inspection and classification. First, we design an image acquisition system with high-resolution cameras and custom-made lighting field to get a high-quality lens image. Next, the defects on the ski goggles lens are detected by adopting parallel projection in opposite directions (PPOD) based on adaptive energy analysis. The PPOD method is used to detect the maximum and minimum value coordinates of defects based on the user's requirement. Finally, the defect images and dust are classified into six types as dust, spotlight type 1, spotlight type 2, spotlight type 3, string, and watermark by the proposed classification algorithm. The defect detection and classification results of the ski goggles lenses are compared with the standard manufacturing quality. The experiments, which used ski goggles lenses provided by a company from Taiwan, demonstrate that the proposed method is sound and useful for ski goggles lens inspection. Not only does it reduce the number of human inspectors, but the yield rate can also increase, and material loss is reduced.
The remainder of this paper is organized as follows. Section 2 describes the image acquisition system. Section 3 presents the proposed defect detection method. Section 4 describes the classification algorithms. Section 5 discusses the experimental results. Finally, Section 6 gives the conclusions of this study. Sensors2019, 8, x FOR PEER REVIEW 4 of 26 defects based on the user's requirement. Finally, the defect images and dust are classified into six types as dust, spotlight type 1, spotlight type 2, spotlight type 3, string, and watermark by the proposed classification algorithm. The defect detection and classification results of the ski goggles lenses are compared with the standard manufacturing quality. The experiments, which used ski goggles lenses provided by a company from Taiwan, demonstrate that the proposed method is sound and useful for ski goggles lens inspection. Not only does it reduce the number of human inspectors, but the yield rate can also increase, and material loss is reduced.  The remainder of this paper is organized as follows. Section 2 describes the image acquisition system. Section 3 presents the proposed defect detection method. Section 4 describes the classification algorithms. Section 5 discusses the experimental results. Finally, Section 6 gives the conclusions of this study.

Image Acquisition System
In this sub-section, the system architecture of the ski goggles lens (Foresight Optical Co., Ltd., Taiwan) inspection apparatus is first introduced, and particular considerations regarding the illumination scheme are presented. Then, the image properties and the challenges for defect detection are investigated. (a)

Image Acquisition System
In this sub-section, the system architecture of the ski goggles lens (Foresight Optical Co., Ltd., Taiwan) inspection apparatus is first introduced, and particular considerations regarding the illumination scheme are presented. Then, the image properties and the challenges for defect detection are investigated.
In each image acquisition device, the lighting setup plays a major role in the quality of the acquired images, which is related to the success or failure of the inspection. When positive light meets an object surface, based on surface object material with different refractive indices, and depending on the angle of incidence and where the medium the light is coming from (e.g., air), some of the lights get reflected. On the other hand, the superfluous lights passing through the object reflect not only on the front surface but also on the backside, while the light may be reflected back and forth several times, leading to a captured image with varied quality. Therefore, the design of a suitable image acquisition system for each type of object plays a crucial role in the AOI system. This section introduces our image acquisition system, including light source setting, camera parameters setting, image capturing design, and so on. To normalize illumination variation and increase the contrast between defect and background, lighting systems have been considered in this work, such as background lighting [11], parallel lighting [12], or infrared lighting [13]. Before choosing a suitable light source, it is necessary to prioritize the influence of the light source. The ski goggles lenses were made from a polycarbonate or Trivex plastic, which was coated for multi-purposes to protect the human eyes. They have a spherical surface different in size and curvature. Therefore, background lighting is used here. To create a homogeneous light field for the entire spherical surface of the lens, we designed a light source by using five pieces of flat light with surface-mounted LEDs, as shown in Figure 3. The flat light illuminated diffused light evenly at high output and helped the designed light source create a homogeneous light field for the entire spherical surface of the lens.
Next, we designed the camera system. Besides the light source setting, the distances among light sources, the camera with a lens, and test samples were examined to design an image acquisition system. For our experiment, symmetrical with five pieces of flat light, we attached five cameras. Each camera focused on part of the lens, which was illuminated by the corresponding flat light. Detailed parameters of the system are shown in Figure 4a and the real system image is shown in Figure 4b. The detailed hardware parameters are shown in Table 1 The remainder of this paper is organized as follows. Section 2 describes the image acquisition system. Section 3 presents the proposed defect detection method. Section 4 describes the classification algorithms. Section 5 discusses the experimental results. Finally, Section 6 gives the conclusions of this study.

Image Acquisition System
In this sub-section, the system architecture of the ski goggles lens (Foresight Optical Co., Ltd., Taiwan) inspection apparatus is first introduced, and particular considerations regarding the illumination scheme are presented. Then, the image properties and the challenges for defect detection are investigated.  In general, the defects on the ski goggles lens are small and very difficult to catch by human eyes. Therefore, image acquisition is one of the critical steps in the defect inspection system. Besides, to make the defect clearer, we designed an image acquisition system to take a high-resolution image.
Three image examples captured by our system are shown in Figure 5, which demonstrates the ski goggles lens images to be examined in this study, measuring 4096 × 3000 pixels with a 24-bit BMP format. Table 2 shows the comparison between the ski goggles lens sample and its image was taken by our system. These images were tested not only for high defect detection rate but also minimized to decrease the running time, ensuring synchronization with the factory's production line.  In each image acquisition device, the lighting setup plays a major role in the quality of the acquired images, which is related to the success or failure of the inspection. When positive light meets an object surface, based on surface object material with different refractive indices, and depending on the angle of incidence and where the medium the light is coming from (e.g., air), some of the lights get reflected. On the other hand, the superfluous lights passing through the object reflect not only on the front surface but also on the backside, while the light may be reflected back and forth several times, leading to a captured image with varied quality. Therefore, the design of a suitable image acquisition system for each type of object plays a crucial role in the AOI system. This section introduces our image acquisition system, including light source setting, camera parameters setting, image capturing design, and so on.  To normalize illumination variation and increase the contrast between defect and background, lighting systems have been considered in this work, such as background lighting [11], parallel lighting [12], or infrared lighting [13]. Before choosing a suitable light source, it is necessary to prioritize the influence of the light source. The ski goggles lenses were made from a polycarbonate  Next, we designed the camera system. Besides the light source setting, the distances among light sources, the camera with a lens, and test samples were examined to design an image acquisition system. For our experiment, symmetrical with five pieces of flat light, we attached five cameras. Each camera focused on part of the lens, which was illuminated by the corresponding flat light. Detailed parameters of the system are shown in Figure 4a and the real system image is shown in Figure 4b. The detailed hardware parameters are shown in Table 1. In general, the defects on the ski goggles lens are small and very difficult to catch by human eyes. Therefore, image acquisition is one of the critical steps in the defect inspection system. Besides,

Ski Goggles Lens Defect Detection
This section introduces the ski goggles lens defect detection algorithm. To extract the correct position of the defect in the image, we detect the contour of the defect by following the defect shape. First, the adaptive energy analysis is used to enhance the defect contour, and then the PPOD method is used to cut out the defect image. The number and size of the defect are finally calculated and classified to determine whether the manufacturer's specifications are met.
Traditional contour detection is based on edge detection approaches [14], e.g., Sobel or Canny operator, and commonly extracts edges by adopting a specific template or combining smooth function. However, the Sobel detector has a major drawback of being very sensitive to noise, and the performance of the Canny algorithm depends heavily on adjustable parameters, including the standard deviation for the Gaussian filter and threshold value. Researchers have recently developed an increasing number of edge detection operators, and each were designed to be sensitive to certain types of edges [15,16]. Unfortunately, these approaches usually require parameter tuning to adjust sensitivity throughout the image depending on contrast and differences. In this paper, the adaptive energy-based edge detector-which can not only detect edge pixels in all directions equally well but also has the advantages of no parameter tuning, low sensitivity to noise, and isotropy-is proposed.
Color is an effective and robust visual cue for distinguishing an object from others. Recently, there has been growing interest in color segmentation, which is useful in preliminary processing for many vision-based tasks, including object recognition, visual tracking, vision-based robotics, and more. However, contour detection is a technique for detecting meaningful discontinuities in the gray level and is often used in subsequent image analysis for feature extraction and object recognition.
In digital image processing, CIELAB color space [17] has high stability in the multi-color mode, which can retain more complete energy information. Based on the usefulness of CIELAB color space, which describes the most complete color model visible to human eyes, we first convert the color defect image from RGB color space to CIELAB color space and then extract the L * channel containing more brightness information as a gray level for contour detection. It is not only more useful for defect detection but can also significantly reduce processing time. Instead of processing the 24-bit ski goggles lens color image, we processed the L * channel image of CIELAB color space with only 8 bits, thus saving the running time of the proposed system.
Without loss of generality, f is assumed to be a ski goggles lens color image with a resolution of M × N, f A , A ∈ {R, G, B} representing the RGB color channels; therefore, f ∈ M×N×3 and f R , f G , f B ∈ M×N . The CIELAB color space is derived from the prior master CIE 1931 XYZ color space, which predicts which spectral power distributions will be perceived as the same color, but is not particularly perceptually uniform. To convert from RGB color space to CIE 1931 XYZ color space, the Equation and the parameters of CIELAB color space are calculated as: where and L * for the lightness from black (0) to white (100), a * from green (−) to red (+), and b * from blue (−) to yellow (+). CIELAB was designed so that the same amount of numerical change in these values corresponds to roughly the same amount of visually perceiving change. X n , Y n , and Z n are the CIE XYZ tristimulus values of the reference white point (the subscript n suggests "normalized"). The L * channel image in CIELAB color space is shown in Figure 6b. Next, for object contour extraction, an adaptive energy-based edge detector is used to smooth the L * channel image and enhance the desired defect edge. The energy e is defined by the mask with 3 × 3 pixels are presented in the following expressions: where is the local standard average value of the pixels in the mask and η = 9 is a normalizing constant.
To enhance the object of interest from the background, the binary image based on an automatic threshold proposed by Otsu [18] is adopted. The Otsu algorithm for the automatic binary threshold τ Otsu is as follows: where t is the current histogram level value from 0 to 255; ω 1 (t) is the cumulative probability from 0 to t−1; ω 2 (t) is the cumulative probability of t to 255; µ 1 (t) is the cumulative expected average of 0 to t−1; µ 2 (t) is the cumulative expected average of t to 255; and p(i) is the probability of distribution in the image. The binary image based on an automatic threshold value τ Otsu , denoted as B, is selected from the energy e as following: where pixel values labeled 255 are objects of interest, and pixel values labeled 0 are undesired ones. The binary image is shown in Figure 6c.
To fix the exact location of the defect in the ski goggles lens, this study adopts the PPOD method to determine the detection range. The PPOD method includes two projection mirrors used interchangeably to detect marginal points on the contours of defects on the ski goggles lens image. For binary image B, the first projection, called the forward projection and denoted as m F , runs from the top left to the bottom right of the image to obtain the maximum value coordinate in the projection. The second projection, called reverse projection, with the mask denoted as m I , runs from the bottom right point back to the first left point of the image to obtain the minimum value coordinate in the projection. The mask m F is defined in Equation (14), while the mask m I is defined in Equation (15).
Based on the result of PPOD, the defects are automatically extracted to take down their numbers, sizes, coordinates, and classification. The manufacturer's specification is then used to determine the defects of whether to meet the manufacturer's specifications. Figure 6 shows the overall result of our defect detection method. Figure 6a shows the original ski goggles lens taken by our acquisition image system. Figure 6b shows the channel L * of the original image in CIELAB color space. Figure 6c shows the adaptive energy image of Figure 6b. Figure 6d shows the results of the binary image by Otsu's algorithm, Figure 6e shows our PPOD method and Figure 6f shows the defect detection result. The overall defect detection algorithm diagram is shown in Figure 7. As the results can be seen, the defects are detected accurately.  To fix the exact location of the defect in the ski goggles lens, this study adopts the PPOD method to determine the detection range. The PPOD method includes two projection mirrors used interchangeably to detect marginal points on the contours of defects on the ski goggles lens image. For binary image B, the first projection, called the forward projection and denoted as , runs from the top left to the bottom right of the image to obtain the maximum value coordinate in the projection. The second projection, called reverse projection, with the mask denoted as , runs from the bottom right point back to the first left point of the image to obtain the minimum value coordinate in the projection. The mask is defined in Equation (14), while the mask is defined in Equation (15).
Based on the result of PPOD, the defects are automatically extracted to take down their numbers, sizes, coordinates, and classification. The manufacturer's specification is then used to determine the defects of whether to meet the manufacturer's specifications. Figure 6 shows the overall result of our defect detection method. Figure 6a shows the original ski goggles lens taken by our acquisition image system. Figure 6b shows the channel L * of the original image in CIELAB color space. Figure 6c shows the adaptive energy image of Figure 6b.

Defect Classification
In this section, we propose the algorithms to classify the defects into four main types such as dust, spotlight, string, and watermark, while the spotlights will be classified into three types, named spotlight type 1, spotlight type 2, and spotlight type 3, as shown in Figure 2. This is the requirement from the manufacturer because our defect detection and classification system not only inspects the quality of the product but also enables fast and accurate inspection of detecting faults early in the production chain. Therefore, the manufacturer required the detection all types of defects with the size as small as possible, even very tiny as dust, which is very difficult to detect by a human. Although we designed an adaptive image acquisition system, however, due to the focal length problem caused by the curvature of the goggles, the intensity of the brightness, the weakening of the bulb, the different types of coated lens, etc., lead to the image obtained being uneven in brightness. The front and back scenes were not obvious enough, as shown in Figure 2. Therefore, the image of the defect is enhanced by an effective method before classifying.

Defect Image Enhancement
For color image enhancement, many researchers have tried to reduce the effect of illumination on the image. Recently, some researchers were successful in applying singular value decomposition (SVD) for color face image enhancement [19][20][21][22][23]. However, these methods are useful for natural light sources, and not suitable for ski goggles defect color images taken under custom light sources. In this sub-section, we present a color defect image as a third-order tensor and propose a method to enhance the defect image by analysis the component of the tensor. By using high-order singular value decomposition (HOSVD) to decompose the defect color image of Figure 8a, we can find the interdependence of the structural components of the two dimension (2D) digital image.

Defect Image Enhancement
For color image enhancement, many researchers have tried to reduce the effect of illumination on the image. Recently, some researchers were successful in applying singular value decomposition (SVD) for color face image enhancement [19][20][21][22][23]. However, these methods are useful for natural light sources, and not suitable for ski goggles defect color images taken under custom light sources. In this sub-section, we present a color defect image as a third-order tensor and propose a method to enhance the defect image by analysis the component of the tensor. By using high-order singular value decomposition (HOSVD) to decompose the defect color image of Figure 8a, we can find the interdependence of the structural components of the two dimension (2D) digital image. Over the past two decades, the use of tensors and their decomposition has become increasingly popular. In multilinear algebra, HOSVD of a tensor is a specific orthogonal Tucker decomposition [24][25][26]. The power of a tensor framework can be presented in a visually and mathematically compelling manner by decomposing and representing an image in terms of its causal factors concerning data formation. HOSVD has been successfully applied to signal processing as well as big data [27], computer vision [28], and facial recognition [29].
The tensor is defined as a multidimensional array [30]. More formally, an N-way or Nth-order tensor is an element of the tensor product of N vector spaces, each of which has its coordinate system. For instance, an RGB color defect image of size × is expressed as a third-order ∈ ℝ M×N×3 space, where M and N correspond to the x-and y-resolutions, respectively, and the number of color Over the past two decades, the use of tensors and their decomposition has become increasingly popular. In multilinear algebra, HOSVD of a tensor is a specific orthogonal Tucker decomposition [24][25][26]. The power of a tensor framework can be presented in a visually and mathematically compelling manner by decomposing and representing an image in terms of its causal factors concerning data formation. HOSVD has been successfully applied to signal processing as well as big data [27], computer vision [28], and facial recognition [29].
The tensor is defined as a multidimensional array [30]. More formally, an N-way or Nth-order tensor is an element of the tensor product of N vector spaces, each of which has its coordinate system. For instance, an RGB color defect image of size M × N is expressed as a third-order A ∈ R M×N×3 space, where M and N correspond to the x-and y-resolutions, respectively, and the number of color channels is three, as shown in Figure 8b. The tensor A includes three frontal slices denoted by Ai (the first, second, and third frontal slices are R, G, and B color channels, respectively). The HOSVD of tensor A can be expressed as where U i , i = 1, 2, 3 are matrices and called the inverse factors of A, and S is the core of tensor A. Given tensor A, the core tensor S is computed as: The core tensor S and its frontal slices are presented in Figure 8c. Unlike SVD, the core coefficients are not only located on the main diagonal of the frontal slices and evenly distributed across the frontal slices, but large values are also distributed around the main diagonal lines. To analyze in more detail the effect of the core tensor on the appearance of color defect images, by turn for using only one of the three frontal slices of core S and assigning the remaining frontal slices to O matrices. O is an all-zero matrix, where every element is equal to zero. Figure 9a presents six color defect images of ski goggles lenses. Figure 9b shows the reconstructed images of Figure 9a by keeping the first frontal slice of core S unchanged and assigning the other two frontal slices to all-zero matrices. Figure 9c shows the reconstructed images by keeping the second frontal slice of core S and assigning the other two planes to O. Similarly, Figure 9d presents the reconstructed face images when the third frontal slice of core S is fixed and the other two planes are assigned to O. As seen, the first frontal slice of the core contains the most spatial structure (edge) of a defect. Besides, most of the reconstructed defect images, by keeping the first plane of core tensor and assigning the other two planes to O, look more clear. Therefore, we use them for classification.
where , = 1,2,3 are matrices and called the inverse factors of , and is the core of tensor . Given tensor , the core tensor is computed as: The core tensor and its frontal slices are presented in Figure 8c. Unlike SVD, the core coefficients are not only located on the main diagonal of the frontal slices and evenly distributed across the frontal slices, but large values are also distributed around the main diagonal lines. To analyze in more detail the effect of the core tensor on the appearance of color defect images, by turn for using only one of the three frontal slices of core and assigning the remaining frontal slices to O matrices. O is an all-zero matrix, where every element is equal to zero. Figure 9a presents six color defect images of ski goggles lenses. Figure 9b shows the reconstructed images of Figure 9a by keeping the first frontal slice of core unchanged and assigning the other two frontal slices to all-zero matrices. Figure 9c shows the reconstructed images by keeping the second frontal slice of core and assigning the other two planes to O. Similarly, Figure 9d presents the reconstructed face images when the third frontal slice of core is fixed and the other two planes are assigned to O. As seen, the first frontal slice of the core contains the most spatial structure (edge) of a defect. Besides, most of the reconstructed defect images, by keeping the first plane of core tensor and assigning the other two planes to O, look more clear. Therefore, we use them for classification.

Defect Image Classification
After extracting defects by the proposed algorithm, the defects are then used to classify based on the manufacturer's specification. Based on our defect detection results, we can manually classify defects into five types, such as spotlight (type 1, type 2, and type 3), string, and watermark. The defects have different sizes and low contrast between the defect and background; even a tiny defect embedded in a ski goggles lens image may differ only slightly from the surrounding region. All these properties make the inspection extremely hard. This section proposes an effective method to classify defects in the ski goggles lens with a high accuracy rate.

Classification of Dust and Defect
Dust is a physical substance produced by the environment. It will adhere to the surface of the ski goggles lens before coating, and the light will go through it. However, when the lens is coated, the dust is the cause of light refraction on the coated lens. To classify the dust and defects, we analyze the change of the grayscale value of the horizontal line going through the center of the defect.
First, the enhanced defect image is converted to a grayscale image and then has a horizontal line go through the center of the defect, as shown in Figure 10b Figures 11 and 12, respectively. As can be seen in the image, the variation of gray level values of the horizontal line going through the center of the dust images, as shown in Figure 11c, has a parabolic shape, which is very different when compared with the variation of gray level values of the horizontal line going through the center of the defect image, as shown in Figure 12c. Therefore, we classify the dust and defect by computing the number of extreme points of h(x) function.
on the manufacturer's specification. Based on our defect detection results, we can manually classify defects into five types, such as spotlight (type 1, type 2, and type 3), string, and watermark. The defects have different sizes and low contrast between the defect and background; even a tiny defect embedded in a ski goggles lens image may differ only slightly from the surrounding region. All these properties make the inspection extremely hard. This section proposes an effective method to classify defects in the ski goggles lens with a high accuracy rate.

Classification of Dust and Defect
Dust is a physical substance produced by the environment. It will adhere to the surface of the ski goggles lens before coating, and the light will go through it. However, when the lens is coated, the dust is the cause of light refraction on the coated lens. To classify the dust and defects, we analyze the change of the grayscale value of the horizontal line going through the center of the defect.  Figures  11 and 12, respectively. As can be seen in the image, the variation of gray level values of the horizontal line going through the center of the dust images, as shown in Figure 11c, has a parabolic shape, which is very different when compared with the variation of gray level values of the horizontal line going through the center of the defect image, as shown in Figure 12c. Therefore, we classify the dust and defect by computing the number of extreme points of h(x) function.   Figures  11 and 12, respectively. As can be seen in the image, the variation of gray level values of the horizontal line going through the center of the dust images, as shown in Figure 11c, has a parabolic shape, which is very different when compared with the variation of gray level values of the horizontal line going through the center of the defect image, as shown in Figure 12c. Therefore, we classify the dust and defect by computing the number of extreme points of h(x) function. Denote . is a number of the extreme points of h(x) function, and an algorithm is designed or h(k − 1) ≥ h(x k ) and h(x k + 1) ≥ h(x k ). (19) Denote No. ex is a number of the extreme points of h(x) function, and an algorithm is designed to separate dust from defect as follows:

Classification of Point (Spotlight Types) and Line(String and Watermarking)
In this sub-section, we propose a method based on the shape of a defect to classify the defects into two groups. Group 1 includes the spotlight defects that have point shape. Group 2 includes string and watermarking defects that have a line shape.
First, we convert the enhanced color defect image f sized M×N from RGB color space to CIELAB color space and then extract the L* channel as a gray level for contour detection by adaptive energy-based edge detector as discussed in Section 3. Next, we separate the defect region from the background of the defect image as shown in Figure 13a. Here, we set the white color (grayscale value of 255) for the points within the defect region and black color (grayscale value of 0) for the background, as presented in Figure 13b. The image in this step is denoted as B. The B image is then divided into four equal parts along two axes through the center of the defect image and perpendicular to the edges, as shown in Figure 13c. The classification of string and point defects is done by calculating and comparing the ratio among the average of grayscale values of four equal parts.
Then, we separate the defect region from the background of the defect image f sized M × N by using adaptive energy analysis, as discussed in Section 3. Here, we set the white color (grayscale value of 255) for the points within the defect region and black color (grayscale value of 0) for the background, as presented in Figure 10b. The image in this step is denoted as B. The image B is then divided into four equal parts along two axes through the center of the defect image and perpendicular to the edges, as shown in Figure 10c. The classification of string and point defects is done by calculating and comparing the ratio among the average of grayscale values of four equal parts, as follows: where µ B is the average of the grayscale value of four quadrants, and µ Bi , i = 1, 2, 3, 4, is the average percentage of the i-th quadrant referred to as µ B . Based on our observations, the defect region of Group 1 (point shape) is usually distributed into four parts of the defect image, while Group 2 (line shape) defects usually focus on one or two quadrants of the image.
where B is the average of the grayscale value of four quadrants, and , = 1,2,3,4, is the average percentage of the i-th quadrant referred to as . Based on our observations, the defect region of Group 1 (point shape) is usually distributed into four parts of the defect image, while Group 2 (line shape) defects usually focus on one or two quadrants of the image. Denote sets S 1 and S 2 with µ Bi , i = 1, 2, 3, 4, that can be defined as follows: Denote µ S1 and µ S2 as the average values of all elements in sets S 1 and S 2. Let n(S 1 ) and n(S 2 ) as the element numbers of S 1 and S 2., while µ S1 and µ S2 can be calculated as follows: The classification of point and line defects is done as follows:

Classification of Spotlight Defect into Three Types
In this sub-section, we propose a method based on HOSVD and entropy to classify the point shape defects into three types of spotlight defects such as spotlight type 1, type 2, and type 3. First, type 1 of spotlight defects is classified from point shape defects, and the remains are classified into type 2 or type 3.
Here, we use the HOSVD to analyze the point shape defect image as shown in Figure 14a. The reconstructed point shape image is replaced with the first inverse factors U 1 by an identity matrix I as shown in Figure 14b, The classification of point and line defects is done as follows:

Classification of Spotlight Defect into Three Types
In this sub-section, we propose a method based on HOSVD and entropy to classify the point shape defects into three types of spotlight defects such as spotlight type 1, type 2, and type 3. First, type 1 of spotlight defects is classified from point shape defects, and the remains are classified into type 2 or type 3.
Here, we use the HOSVD to analyze the point shape defect image as shown in Figure 14a. The reconstructed point shape image is replaced with the first inverse factors 1 by an identity matrix I as shown in Figure 14b,  Based on our observation, the distribution of the three color channels of type 1 spotlight defect images is more different than the remaining spotlight types, as shown in Figures 15-17. Therefore, type 1 spotlight defect is obtained by comparing the maximum, minimum, and median values of three color channels, as follows: Based on our observation, the distribution of the three color channels of type 1 spotlight defect images is more different than the remaining spotlight types, as shown in Figures 15-17. Therefore, type 1 spotlight defect is obtained by comparing the maximum, minimum, and median values of three color channels, as follows: Next, we classify spotlight type 2 and type 3 by comparing the mean, denoted as µ s , standard deviation, denoted as σ s , and entropy, denoted as e s , based on the largest color channel of the defect image. In digital image processing, entropy is a measure of an image information content, which is interpreted as the average uncertainty of the information source. The entropy of an image can be used for measuring image visual aspects [31] or for gathering information to be used as parameters for adaptive histogram equalization [32]. Entropy is widely used for measuring the amount of information within an image. Higher entropy implies that an image contains more information. The entropy of information e was introduced by Shannon [33] in 1948, and it can be calculated by the following Equation: where p i denotes the probability mass function of gray level i, and it is calculated as follows: of occurrences of intensity levels No. of intensity levels .
the type 2 and type 3 of the remained point shape defects are classified by the Equation: Next, we classify spotlight type 2 and type 3 by comparing the mean, denoted as , standard deviation, denoted as , and entropy, denoted as , based on the largest color channel of the defect image. In digital image processing, entropy is a measure of an image information content, which is interpreted as the average uncertainty of the information source. The entropy of an image can be used for measuring image visual aspects [31]or for gathering information to be used as parameters for adaptive histogram equalization [32]. Entropy is widely used for measuring the amount of information within an image. Higher entropy implies that an image contains more information. The entropy of information e was introduced by Shannon [33] in 1948, and it can be calculated by the following Equation: = − ∑ log 2 255 =0 (40) where denotes the probability mass function of gray level i, and it is calculated as follows:

=
No. of occurrences of intensity levels No. of intensity levels .
the type 2 and type 3 of the remained point shape defects are classified by the Equation:

Classification of String and Watermark Defects
We make a comparison with mean μs, standard deviation σs, and entropy es of the largest color channel for the defect image to further classify lines into string and watermark, as follows: In summary, the defects have been classified into six types: dust, spotlight (type 1, type 2, and type 3), string, and watermark based on the manufacturer's specifications. The overall classification algorithm diagram is shown in Figure 18.

Classification of String and Watermark Defects
We make a comparison with mean µ s , standard deviation σ s , and entropy e s of the largest color channel for the defect image to further classify lines into string and watermark, as follows: In summary, the defects have been classified into six types: dust, spotlight (type 1, type 2, and type 3), string, and watermark based on the manufacturer's specifications. The overall classification algorithm diagram is shown in Figure 18.

Experiment Result and Discussion
In this section, the defect detection and classification algorithms are tested on four types of ski goggles lens samples with a total of 120 pieces provided by the cooperator, as shown in Figure 1.

Image Acquisition Setting
The proposed systems were implemented in Microsoft Visual Studio C++ 2010. The experiments were conducted on a PC with an Intel Core i7-4790 CPU @ 3.60 GHz, RAM DDR3 8 GB, running with Windows 10 operating system. The system used Basler avA2300-30kc camera with Camera-Link interface and equipped with KAI-4050 CCD sensor delivering 31 frames per second at 4 MP resolution, sensor size with 12.8 mm × 9.6 mm, resolution (H × V) with 4096 × 3000 pixels, pixel size (H × V) with 5.5 µm × 5.5 µm. The camera adapted was Nikon 60 mm f/2.8 microlens (Nikon, Minato, Tokyo, Japan). This lens is an excellent normal and short telephoto lens, as well as a superb close-up lens, which means an object as small as an inch across can fill the frame. The light source was equipped with PHILIPS Ambiance Globe 17W E27 Cool daylight (PHILIPS, Amsterdam, Netherlands).

Defect Detection Result
In order to inspect whether the ski goggles lens satisfies the requirement of the manufacturer or not, the ski goggles lens image was used to locate and extract the defects. The RGB image was transformed into CIELAB color space to get the L* channel image for contour extraction. Based on the localized energy analysis of the L* channel image, the image was converted to binary image based on the Otsu algorithm and then was used to located and extract the defects by the proposed PPOD method. The size and number of the defects were then calculated to check against the requirement of the manufacturer's specification and later put to the classification process to make a decision whether it could pass or not. In our experiments, we achieved a 100% defect detection rate. The average time including load/unload for defect detection was 30 s/piece.

Defect Classification Result
Based on the manufacturer's specifications, the defects were classified into six types: dust, spotlight (type 1, type 2, type 3), string, and watermark. The overall algorithm diagram is shown in Figure 18. First, the defect images were enhanced by HOSVD. Based on the analysis of the components in the core tensor, the most important information of defect was found in the reconstructed images by keeping the first plane of core tensor and assigning the other two planes to zero matrices. Therefore, the image of the defect was first enhanced by the proposed method before classifying it. Next, the dust image was classified from defects by computing the number of extreme points of variation of gray level values of a horizontal line going through the center of the defect.
The defect image was then classified into two groups based on examination among the average values of four equal parts of the defect image. Group 1 included three types of spotlight defects with point shape, while Group 2 included the string and watermarking defects with line shape. For the spotlight defects, we first used HOSVD to reconstruct point shape images by replacing the first inverse factors U1 by an identity matrix I. To obtain type 1 of spotlight defects, we compared the value of the maximum, minimum, and median of three color channels of the reconstructed image. The type 2 and type 3 of the spotlight were then classified by comparing the mean, standard, and entropy of the strongest color channel of the defect image. For the line shape defect, we also computed mean, standard and entropy of the strongest color channel of the defect image to classify them into string defect and watermark.
The experimental results show that our method is feasible in the ski goggles lens inspection system and more effective than the traditional human visual inspection method. Through experimental tests on 176 defects (classification rate of 98.6%) and 120 dust images (recognition rate of 100%), the presented method achieved a classification rate of 99.3% in accuracy and a running time of 0.5 s per sample in average. The results show that our system can detect and classify the defect in the ski goggles lens with high efficiency, even in case the size of the defect is very small and impossible to be seen clearly by human eyes. Moreover, the running time was short so the proposed framework could fully meet the manufacturer's requirements. The proposed system not only inspects the quality of the product but also enables fast and accurate inspection of detecting faults in the early period of the production line.

In Comparison with Related Works
In general, researchers use modern statistical or data mining methods to resolve the classification problem [34]. However, the learning algorithms depend heavily on finding a good sparse feature vector, which is represented with an object [35][36][37][38]. Our method uses statistical features to distinguish various defect types. To demonstrate the generalizability of the proposed method, we did more experiments.
We compared the defects enhanced by the proposed HOSVD method with other methods, such as local binary pattern (LBP) [39], gradient [40], and Webber's law [40]. These methods are very useful to remove the effect of lighting on the object. Figure 19a presents original images with one dust image and five defect images, Figure 19b presents the result by applying the LBP method, Figure 19c presents the result by applying the gradient method, and Figure 19d presents the result with the Webber method. In our test, the most important task is to classify dust from defects. We computed the horizontal line going through the center of the defect and observed the variation of gray level values. of 100%), the presented method achieved a classification rate of 99.3% in accuracy and a running time of 0.5 s per sample in average. The results show that our system can detect and classify the defect in the ski goggles lens with high efficiency, even in case the size of the defect is very small and impossible to be seen clearly by human eyes. Moreover, the running time was short so the proposed framework could fully meet the manufacturer's requirements. The proposed system not only inspects the quality of the product but also enables fast and accurate inspection of detecting faults in the early period of the production line.

In Comparison with Related Works
In general, researchers use modern statistical or data mining methods to resolve the classification problem [34]. However, the learning algorithms depend heavily on finding a good sparse feature vector, which is represented with an object [35][36][37][38]. Our method uses statistical features to distinguish various defect types. To demonstrate the generalizability of the proposed method, we did more experiments. We compared the defects enhanced by the proposed HOSVD method with other methods, such as local binary pattern (LBP) [39], gradient [40], and Webber's law [40]. These methods are very useful to remove the effect of lighting on the object. Figure 19a presents original images with one dust image and five defect images, Figure 19b presents the result by applying the LBP method, Figure 19c presents the result by applying the gradient method, and Figure 19d presents the result with the Webber method. In our test, the most important task is to classify dust from defects. We computed the horizontal line going through the center of the defect and observed the variation of gray level values.    Figure 20a has a parabolic shape, which is very different when compared with the variation of gray level values of the horizontal line going through the center of the defect images. However, we cannot distinguish dust from defects when using LBP (Figure 20b), gradient (Figure 20c), and Webber (Figure 20d). Accordingly, by using a simple statistical feature obtained from the HOSVD image, we found it easy to classify dust from defects with a 100% true detection rate. On the other hand, we classified dust from defects by using a learning method with the support vector machine (SVM) [41]. We used the histogram of oriented gradients (HOG) descriptors [42] as a feature vector for SVM. In this study, the radial basis function kernel exp (−γ x − x 2 ), where x and x are represented as feature vectors in input space, was used in SVM and the parameter γ is set to 20 with an experimental setting. However, the results were not as good as expected. We only got a 71% true classification rate. This was caused by the size of dust, in which the defect images were really different.   Figure 20d). Accordingly, by using a simple statistical feature obtained from the HOSVD image, we found it easy to classify dust from defects with a 100% true detection rate. On the other hand, we classified dust from defects by using a learning method with the support vector machine (SVM) [41]. We used the histogram of oriented gradients (HOG) descriptors [42] as a feature vector for SVM. In this study, the radial basis function kernel exp (−γ‖x − ′‖ 2 ), where x and x' are represented as feature vectors in input space, was used in SVM and the parameter γ is set to 20 with an experimental setting. However, the results were not as good as expected. We only got a 71% true classification rate. This was caused by the size of dust, in which the defect images were really different.
In this study, the optimized goggles detection system was used as the main axis, and the image capturing system was customer-designed to improve the performance of the goggles detection system. With the designated environment, taking the clear original image as the starting point, according to two major problems, the lighting source should uniformly light the whole goggles for capturing the original image, and therefore the shooting mode of five cameras is proposed. Based on the cameras and the angles of shooting, we can make each camera capture a smaller range, effectively avoiding classification errors caused by blurring with focus. In addition, the bowl shape LED light source was been customer-designed for the architecture of five cameras, the main purpose of which was to cover the entire goggles. According to the above experimental results, it is confirmed that the goggles detection system of this paper is optimized, which effectively increases the efficiency of the proposed system. The shooting structure of the five cameras can also accommodate more different goggles samples and obtain clear image matching and screening. The algorithm can greatly reduce In this study, the optimized goggles detection system was used as the main axis, and the image capturing system was customer-designed to improve the performance of the goggles detection system. With the designated environment, taking the clear original image as the starting point, according to two major problems, the lighting source should uniformly light the whole goggles for capturing the original image, and therefore the shooting mode of five cameras is proposed. Based on the cameras and the angles of shooting, we can make each camera capture a smaller range, effectively avoiding classification errors caused by blurring with focus. In addition, the bowl shape LED light source was been customer-designed for the architecture of five cameras, the main purpose of which was to cover the entire goggles. According to the above experimental results, it is confirmed that the goggles detection system of this paper is optimized, which effectively increases the efficiency of the proposed system. The shooting structure of the five cameras can also accommodate more different goggles samples and obtain clear image matching and screening. The algorithm can greatly reduce the system operation time and is more suitable for production line use. The overall calculation time has been accelerated in this study so that the goggles detection system can achieve immediate operation.

Conclusions
In this study, we propose an effective ski goggles lens defect detection and classification system, which has three parts. The first part includes an optical structure for image acquisition that can remove natural light interference and then highlight defects. The second part includes an efficient algorithm called the PPOD method, which includes two interchangeable projection mirrors to detect marginal points on the contour of defect on the ski goggles lens image and then locate and extract the defect image. Finally, an efficient classification algorithm is proposed to classify the defects into six types: dust, spotlight (type 1, type 2, and type 3), string, and watermark based on manufactory requirements. The experimental results run on 120 ski goggles lens pieces provided by the cooperative manufacturer and have shown that our system can get a 100% defect detection rate and a 99.3% classification accuracy rate. Moreover, it only takes 0.5 s on average to perform the inspection for a piece of ski goggles lens.