A Practical Low-Cost Machine Vision Sensor System for Defect Classification on Air Bearing Surfaces

In this paper, we present a newly adapted machine vision method and a practical low-cost machine vision sensor for defect classification of the air bearing surfaces (ABSs) of a hard disk drive, which controls the flying height of the recording heads moving above a disk in operation. A defective ABS can cause poor reading and writing performance; hence, it is necessary to verify its integrity before assembling it into the final product. The proposed sensor system was designed and implemented to detect defects by an effective combination of image segmentation and block matrix techniques as well as classifying them using an expert system under dark-and bright-field conditions. Our system processes subregions of interest and sub-blocks in parallel so that they can take advantage of multiple processor cores. From the trial runs, the small fractional error and low average processing time suggested that our proposed system is effective and can be used in an industrial assembly line.


Introduction
In a hard disk drive (HDD), the air bearing surface (ABS) is a small but important part of a slider, which is a part of a head gimbal assembly (HGA) that holds recording heads.The location of the ABS on an HGA is illustrated in Fig. 1.The ABS controls the flying height of the slider above a magnetic disk.For a very high density HDD, the recording head on a slider flies extremely close to the magnetic disk with a clearance of only a small fraction of a microinch. (1)Figure 2 shows a schematic of a flying slider over a spinning disk.In its flight, the ABS is lifted by the passive pressure provided by disk platter rotation.The design of a slider has to take into account its weight, flying velocity, and actuator arm skew in order to achieve a uniform flying height.The quality of an HDD is as good as the quality of its ABS; hence, an effective defect detection process is necessary.The types of defects of an ABS focused on in this paper are stains, contaminating particles, and metal scratches.An effective defect detection method is detection by image processing, but a major problem with an image processing system is the inconsistent quality of acquired images in terms of intensity, contrast, and resolution.
Currently, offline nanocontamination detection is carried out by automatic force microscopy (AFM) or scanning electron microscopy (SEM).AFM was first introduced in 1996 by Bining et al. (2) There are two types of AFM: contact mode and noncontact mode.AFM is not suitable for the inline monitoring of defects because it requires highly skilled human operators to work around the clock as well as lengthy operation time and high operating costs.SEM is usually employed to inspect very small machine parts.The advantages of SEM are high magnification, high resolution, and large depth of field (DOF).The device can achieve a resolution of better than 1 nm.However, its major disadvantage is that it destroys the surface of the scanned object.Thus, SEM is also not suitable for automated inline detection.Other techniques for detecting particulate contamination are based on light scattering, which relies on established laser detector and optics technologies.Most techniques are used for particle counting, as reported in Ref. 3. As for the development of particle counters, Blesener (3) invented a nonimaging laser particle counter, and Bhushan and Chandra (4) proposed a laser particle counter (LPC) and a sampling technique for detecting the size of contaminating particles on a rigid disk drive.Koshevar et al. (5) proposed a new nanocontamination monitoring device.None of these light scattering techniques, however, can determine the type of material of the contaminating particles.As for inline detection of other types of ABS defects such as stains, scratches, cracks, or chips, the conventional method is detection by a human operator observing ABSs through a high-magnification microscope.The two major disadvantages of using a human operator are unpredictable human error and slow detection speed.
A good detection method that has been widely used for the inline monitoring of numerous products and processes is a machine vision sensor.Even though machine vision sensor systems have long been utilized in HDD factories for purposes such as QR code checking and mainboard integrity checking, they have not been used for ABS defect detection.At the time of the development of our proposed system, we considered that using a machine vision sensor to detect ABS defects would eliminate human error and increase the number of units processed per hour.
Various defect detection algorithms have been proposed.They can be categorized into four main groups: statistical, structural, spectral and filtering, and model-based algorithms.Examples of applications of these algorithms are shown in Table 1.In this work, a simple yet practical  approach for constructing a low-cost machine vision sensor for detecting three types of ABS defects was designed and implemented.
This paper is organized as follows.In Sect.2, we explain the design of the imaging system.The hybrid defect detection algorithm for our sensor system is discussed in Sect.3. In Sect.4, we report the tested detection and classification performances of the sensor.In Sect.5, we provide conclusions.

Imaging System
In this section, the system used for capturing images during inspection is introduced.Because the defects are usually very small, the captured image must collect all of details of the ABS while minimizing noise.A high-resolution industrial CCD camera was used for capturing high-quality images.Our camera selection criteria were a minimum resolution threshold and a maximum lens focal length threshold.The minimum resolution threshold was based on the size of the smallest defect that we wanted to detect.This threshold was calculated using Eq.(1): where #pixel is the minimum resolution, and d FOV is the width or height of the field of view (FOV).The area of the ABS was around 1 × 0.8 mm 2 and we aimed to detect a defect as small as 1 μm, so according to Eq. ( 1), the minimum pixel dimension of the camera should be at least 1600 × 2000 Textile, (6) Texture (7) Co-occurrence matrix Textile (8) Principle component analysis Wood (9)

Generic algorithm
Metallic surface (30) Support vector machine Metallic surface (21) Independent component analysis Textile, (31) LCD (32) Texem model Marble (33) pixels.This specification was met by a commercially available 5 MP CCD camera, which was capable of capturing images at a dimension of 2048 × 2594 pixels.On the basis of the designed distance from the lens to the ABS, the focal length of the lens was calculated using Eq. ( 2): where f is the focal length of the lens, d sensor is the width of the CCD, which was chosen as 5.70 × 4.28 mm 2 , and WD is the distance from the lens to the ABS, which was initially designed to be 50 mm.With these values, the lens focal length threshold was calculated to be 42.537mm.This specification was also met by the same camera, which had a lens of 50 mm focal length.To be able to obtain low-distortion images, we selected a macro lens.The required magnification of the macro lens was calculated using Eq. ( 3): where Mag is the maximum magnification.For our design parameters, the required magnification should not be greater than 5.7×.Thus, we selected a 4× magnification macro lens that produced only −0.073489% distortion.With a 5-mm extension ring, the magnification was increased to 4.3×.Finally, the illumination for the imaging system was selected.Because the ABS is very small, a wide-length spot light was selected.Two illumination techniques were used, as the bright and the dark field were used to collected images from the ABS for the defect classification.The closed chamber was designed to solve the problem of disturbances by external light.
With the selected imaging system as a CCD camera, lens, and light source, the hardware for our low-cost machine vision sensor system was constructed, a photo of which is shown in Fig. 3.The system was inexpensive compared with an AFM or an SEM.This selected hardware proved to be satisfactory because the acquired images were acceptably clear: two sample images are shown in Sect. 4.

Defect Detection and Classification
In this section, we begin by describing the steps in the defect detection procedure in Sects.3.1-3.5.In the last subsection, Sect.3.6, we describe the types of defects in our classification scheme and the classification algorithm.

Extraction of region of interest (ROI)
First, an ABS image was captured by the CCD camera.Then, the captured image was extracted in order to find the ROIs.A well-known extraction method is the Chan-Vese algorithm, which finds a geometric active contour via a level set method.We tried to apply the level set method with our system, but it was not satisfactory owing to not only its low speed and high CPU load for the high-resolution image used in this work but also to the imperfect extraction.The fast level set method, proposed by Y. Li et al. (34) and H. Lu and colleagues, (35,36) improved the performance of the level set method and increased the speed of the algorithm.We tried to use this algorithm with our system, but choosing and tuning parameters to satisfy our case were not easy to implement in due time.However, it will be interesting to simplify and integrate the method for further investigation in the future work.Hence, we devised techniques that worked, its function was inspired from the "wand" tool in Photoshop software, and we found it to be satisfactory for our defect detection scheme.The implemented technique was very easy with low complexity.This technique generated the extraction mask by the Euclidean distance function between the reference value and each pixel.
Let us briefly review the Chan-Vese algorithm.This algorithm employs a geometric segmentation approach to minimizing the fitting energy of the input image and the level set function that defines the segmentation.The variational calculus method was used to evolve the level set function.The Chan-Vese model was defined according to the fitting energy function, shown in Eq. (4): where F(φ) is the fitting energy function; μ, v, λ 1 , λ 2 , and p are the user-selected fitting parameters for a particular class of images; H is the Heaviside function; I is the input image; Ω is the domain of the input image.The terms c 1 and c 2 are the average pixel values of the foreground and background, μ and v are the weights of the total length of the edge contour (boundary) and the total area of the region obtained from segmentation (if the region has a smooth boundary, the weight μ will be large), and λ 1 and λ 2 are the weights of the distance terms and are proportional to the variances of the foreground and background of the image, respectively.The terms )dx were used to represent the uniformity of the region in terms of pixel intensity.Minimizing the sum of these two terms made the foreground and background of the segmentation region as uniform as possible.
We attempted to use this method to extract ROIs.However, after trial runs, it was found to be not suitable for processing our ABS images because it used too much computation time and too many resources.Hence, we developed a simpler algorithm, the procedure of which is described below.
Our algorithm for ROI extraction: Input: (i) I(x, y, z): the intensity of a pixel at coordinate (x, y) on a color plane z in the color image of M × N pixels, where z takes a value of 1, 2, or 3, representing red, green, or blue, respectively; and (ii) x', y', w, h: x' and y' are the coordinates of the upper left hand corner of the user's selected reference area and w and h are its width and height.
Step 1: Determine the reference intensity values (R(z)) and tolerance (T) value: the reference intensity is an intensity value that is used in the process of screening a pixel in or out of the extracted ROI-a pixel with an intensity value not farther away from the reference intensity than the tolerance value is included in the ROI.It is determined as the statistical mode of all intensity values in each color plane of the reference area.Tolerance value is determined as the average value of the three standard deviations of all intensity values in each of the three color planes of the reference area.
Step 2: Create a binary mask B(x, y) for ROI extraction using the following steps: Step 2a: Calculate the Euclidean distance d(x, y) between I(x, y, z) and R(z), Step 2b: Generate a binary mask B(x, y) according to the following criteria: Step 3: Obtain the ROI by masking the image with B(x, y).

Fuzzy dynamic histogram equalization
In the scheme of image contrast enhancement, the histogram equalization is a well-known technique.Contrast enhancement for images in turbid water (37) is a contrast enhancement method, which is presented the method for correcting the illumination lost by propagation of an underwater image, whereas this work focused on light reflecting, scattering, and light distribution.Then, the fuzzy dynamic histogram equalization (38) was used to enhance the ABS image and minimize the pixel fluctuation without removing defects and noise.This technique consists of the following four steps.

Creation of a fuzzy histogram
A fuzzy histogram is smoother than a crisp histogram and was much more suitable for our application.It is a sequence of real numbers: h(i), i ∈ {0, 1, ..., L−1} where h(i) is the occurrence frequency of gray level i.Assuming a gray level I(x, y) at the coordinate I(x, y) and a fuzzy number Ĩ(x, y), the fuzzy histogram was computed using Eq. ( 5): where µ Ĩ(x,y)i is a triangular fuzzy membership function defined as µ Ĩ(x,y)i = max 0.1 − |I(x, y) − i| 4 and [a, b] is the support of the membership function.

Partitioning of the histogram
The histogram obtained was partitioned into multiple subhistograms that were individually equalized in the next step.Partitioning was carried out by finding the first-and second-order derivatives of the fuzzy histogram using Eqs.( 6) and ( 7), respectively: where ḣ (i) and ḧ (i) are the first-and second-order derivatives of the fuzzy histogram h(i), respectively, corresponding to the ith intensity level.Then, the partition points were the intensities (m 0 , m 1 , ..., m n+1 ) of all of the local maximum frequencies, which were calculated using Eq. ( 8), In the range [Ĩ min , Ĩ max ] of the original fuzzy histogram, the subhistograms [Ĩ min , m 1 ], [m 1 +1, m 2 ], ..., [m n +1, Ĩ max ] were partitioned with these points.

Dynamic histogram equalization of the subhistogram from the previous stage
The new intensity level can be expressed in the form where y( j) is the new intensity level corresponding to the jth intensity level on the input image, m i is the ith local maxima in the original fuzzy histogram and i = [1, 2, ..., n+1], h(k) is the histogram value at the kth intensity on the fuzzy histogram, and M i = m i k=m i−1 h(k) is the total number of pixels contained in the ith partition of the fuzzy histogram.

Normalization of the equalized histogram
We then normalized histogram equalization as where μ i and μ o are the mean brightness values of the input image and the equalized image ( f(x, y)), respectively, obtained from the previous stage.

Generation of a block matrix
The block matrix proposed in Ref. 39 was generated in the form of a two-dimensional array from the tilling process.The tilling process divided the M × N image into m × n image blocks of size p × q.Each member in the m × n image block represented an average intensity of each subblock, calculated using Eqs.(11) and (12).
where Y(i, j) is a tile image generated with a block of size p × q, B(i, j) is the m × n block matrix represented by two-bit quantization values between levels 1 (01) and 3 (00), and X is the mean intensity of the equalized image from the previous stage.By using Eqs.( 11) and ( 12) , the input image was resized by the tilling process and the block matrix corresponding to the tilling version was obtained.Note that the tilling process has an outstanding advantage for noise removal because the average intensity of the block is employed to represent the value of the block.

Extraction of defect features
The block matrix B from the previous step can be represented as a function that assigns a quantization level to each block in the domain of the image: I: L r × L c → Q.The terms L r = {0, 1, ..., N r −1} and L c = {0, 1, ..., N c −1}are the spatial domains of row and column dimensions, and Q = {1, 2, 3} is the domain of quantization levels.
To extract defect features, we used a texture analysis technique called the gray-level cooccurrence matrix (GLCM). (40)It is based on repeated intensities of pixels in the image and can be defined using Eqs.( 13) and ( 14) where the distance matrix can be explicitly defined as Next, the correlation feature used to identify the defected ABS or nondefected ABS was calculated using Eq. ( 15): where μ i is defined as , and σ j is defined as Note that the index Corr measures the linear dependence of the elements in the matrix between the specified elements relative to each other.

Detection of defect
Defects on the ROIs were detected on the basis of the characteristics of the block matrix, which was generated from the previous step.As mentioned previously, the algorithm began with an image that was partitioned into N sub-ROI regions and then the procedure was repeated in Sects.3.1, 3.2, 3.3, and 3.4.The search for the defects in each sub-ROI ran in parallel architecture and was synchronized.
In order to identify the defects inside the ROIs, we used Euclidean distance and the selection threshold using the method of the minimum summation of two types of errors, namely, false acceptance (e 1 ) and false rejection (e 2 ), from the threshold set.The threshold is defined as η = min(e 1 + e 2 ).( 16) The defective and nondefective ABS were classified by means of the training data set as where || || is the Euclidean distance, and f is the feature parameter obtained from the co-occurrence matrix of the block matrix.

Classification of defect
In this work, three types of defects-stains, contaminating particles, and metal scratcheswere identified.Each defect type had strong physical illumination characteristics, as shown in Table 2; the expert system was designed for classification based on the reflection characteristics.A flow chart of the expert system is shown in Fig. 4.

Results and Discussion
In order to test the designed system, the ABS images were first captured from the designed machine vision system as shown in Fig. 5.The figure shows Quadrants #1 and #2 on the ABS images.The results of Sect.3.1 are shown in Figs. 6 and 7.In Fig. 6, the results of the corresponding ROIs on the ABS using the level set method based on the Chan-Vese model (34)(35)(36) are presented.The specific values used herein for Eq. ( 4) were λ 1 = λ 2 = 1, µ = 0.1 × 255 2 , and v = 0.As can be seen, the extracted ROIs were not perfectly removed from the background of the original image.Some unwanted background is shown as something protruding at the bottom right in Fig. 6(a) of the images appeared.Likewise, some unwanted background also appears at the bottom left of Fig. 6(b).The unwanted background indicates that the algorithm suggested in Refs.34-36 may not suitable for this case.Otherwise, the values of the parameters need to be optimized.Perhaps numerical steps for the integral parts of Eq. ( 4) need to be fine-tuned until satisfactory results are finally achieved.It takes time to proceed with the fine tuning.In order to cope with this difficulty, Fig. 6. (Color online) Extraction of ROI using the level set method (34) in Sect.  the proposed algorithm presented in Sect.3.1 was presented as an alternative method.Figure 7 shows the results obtained from using the proposed method.As one can see, the extracted ROIs are clearer and better than the ROIs from the level set method.Unwanted background was removed.In addition, the proposed method had a better processing time, as shown in Table 3.The processing time for using the Chan-Vese model was 6.15 s vs 1.62 s for the proposed method.The ROI was extracted from the image size of 1942 × 2590 pixels with the pre-defined reference area for the size of 40 × 40 pixels.Figures 8(a) and 8(c) show the results for Sect.3.3 without processing through the fuzzy dynamic histogram equalization, as described in Sect.3.2.There is still noise in those figures; however, Figs.8(b) and 8(d) show that the fluctuations due to noise were removed by using the procedure in Sect.3.2.The images in the subfigures are clearer than those obtained without using the procedure in Sect.3.2.Note that the support membership function used in this procedure is a triangular one in the form [0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0].Note also that, in Sect.3.3, the tiled image was generated from the ROI image with the block size containing 30 × 30 pixels.Figure 9 shows the zoom version of Fig. 8(d), whereas Fig. 10 shows the corresponding numbering values of the block matrix (shown in the red box of Fig. 9) calculated from Eqs. ( 5) and ( 6).Numbers 2 and 3 in Fig. 10 indicate the defect areas.For Sect. 3.4, the GLCM features were calculated from the cooccurrence matrices with the distance d = 1 with θ = 0, 45, 90, and 135°.Figure 11 shows the plots of the defect detection using the Euclidean distance of the correlation features and the selected threshold presented in Sect.3.5.These thresholds were calculated automatically and adaptively because the errors had been dynamically changed.The results from this procedure are presented in Tables 3 and 4.
Table 4 shows the results for the three classified types obtained from defect detection, which were stains, contaminating particles, and metal scratches.Two types of error, false rejection and false acceptance, are shown in the table.False rejection means that the expert system identifies the perfect ABS as the defected ABS.On the other hand, false acceptance means that the expert    641 Fig. 10.Sample values of the block matrix (red box in Fig. 9).system identifies the defected ABS as a perfect one.Over-rejection may not cause as much trouble as over-acceptance.This is because over-acceptance may accept the defective parts that will be delivered to customers.A defective sample found by a customer would cause the rejection of the whole lot of the product shipment, and the products would be returned to the factory, creating a bad reputation for the company.This is serious since it is necessary to completely prevent false acceptance errors.In Table 4, all of the results were acceptable, except for the case of the false acceptance for metal scratches.Hence, false acceptance in the case of metal scratches is a concern.More rule bases for the case of metal scratches need to be adjusted or added, which would be a challenging classification enhancement for future work.Nevertheless, for defect detection only (regardless of classification), the method works very well, as it can reject all defect types.In Table 3, the total run time for all procedures was around 7 s, which was in an acceptable operation range compared with using human operators (around 5-15 s).The computer used in this test was an Intel Core i7 CPU with 4 GB RAM.For speed performance comparison, if we used the proposed inspection without the procedure in Sect.3.3, the run time was around 13 s, which was 2 times higher than that with the procedure in Sect.3.3.This is why the procedure in Sect.3.3 was introduced and included.As one can see, the advantage of the proposed method not only speeded up the process but also performed as well as human visualization.If the defect can be seen in an image, the detection result is still accurate, even though the lighting environment has changed.Note that one may conjecture about the robustness of the method over the lighting conditions.However, for a well-developed industrial line, the lighting conditions can be completely controllable.In our case, we set up the image acquisition procedure using an industrial camera inside the well-designed lighting chamber, and there was no need to check for other lighting conditions in this situation.

Conclusions
A practical machine vision design and implementation have been illustrated in this paper.A simple yet effective method was proposed to identify the defects on the ABS of a HGA.The six simple procedures suggested in this paper were ROI extraction, fuzzy dynamic histogram equalization, block matrix generation, extraction of defect features, defection detection, and classification of the defects.The key idea for speeding up automatic inspection was to divide the area of investigation into each block matrix.In doing so, searching areas can be divided as desired by the designer.The concept of using sub-blocks and sub-ROI processing in parallel was revealed to be effective, as demonstrated by the results, because the concept markedly helps to reduce the size of the input matrix before feeding to the feature extraction procedure.As the size of the matrix is reduced, the run time for extracting the features of the blocks is also reduced.Finally, the expert system for classification was designed from the illumination characteristics on the ABS.The system was tested by using normal samples and samples containing three types of defects: microcontamination with stains, contaminating particles, and metal scratches.The results were seen to be satisfactory for defect detection and classification.However, for the classification, the rules bases for classification may need to be modified in the case of metal scratches owing to the existence of false acceptances in the test.In general, the results can be verified by the proposed expert system, indicating that they were good as these visualized by the human eye.However, this process is an automatic operation in the production line, which can replace human operators.The human operators can then perform more intelligent and healthier tasks.Further work needs to be carried out on the classification system in order to classify more types of defects in the manufacturing system.The searching algorithm itself can also be enhanced by using an intelligent search, such as chaotic path, pheromone tracking, or other combinations of heuristic and analytic approaches.These topics may be viewed as subregional searches inside the blocks for fine tuning and are still a challenge.

Fig. 1 .
Fig. 1. (Color online) Air bearing surface on an HGA compared with the size of a one Thai baht coin.

Fig. 11 .
Fig. 11.(Color online) Euclidean distances and thresholds of defect detection with the correlation feature on the selected ROIs: (a) stains, (b) particles, and (c) metal scratches.

Table 1
Machine vision algorithms for industrial defect detection.