Abnormality detection strategies for surface inspection using robot mounted laser scanners

Abstract The detection of small surface abnormalities on large complex free-form surfaces represents a significant challenge. Often surfaces abnormalities are less than a millimeter square in area but, must be located on surfaces of multiple meters square. To achieve consistent, cost effective and fast inspection, robotic or automated inspection systems are highly desirable. The challenge with automated inspection systems is to create a robust and accurate system that is not adversely affected by environmental variation. Robot-mounted laser line scanner systems can be used to acquire surface measurements, in the form of a point cloud 1 (PC), from large complex geometries. This paper addresses the challenge of how surface abnormalities can be detected based on PC data by considering two different analysis strategies. First, an unsupervised thresholding strategy is considered, and through an experimental study the factors that affect abnormality detection performance are considered. Second, a robust supervised abnormality detection strategy is proposed. The performance of the proposed robust detection algorithm is evaluated experimentally using a realistic test scenario including a complex surface geometry, inconsistent PC quality and variable PC noise. Test results of the unsupervised analysis strategy shows that besides the abnormality size, the laser projection angle and laser lines spacing play an important role on the performance of the unsupervised detection strategy. In addition, a compromise should be made between the threshold value and the sensitivity and specificity of the results.


Introduction
Quality control is an essential part of all successful manufacturing operations, with the requirement for 100% inspection of manufactured items being common place in many industries. A particularly challenging inspection task involves the localisation of surface abnormalities on large area surfaces; for example, metal surface inspection is an important step in manufacturing of large and highly sculptured components such as car bodies. Localising small surface abnormalities is a difficult, time consuming and costly task, that must be undertaken to ensure the car body finish is blemish free following the painting process, and important factor for customer satisfaction and perceived quality. In other applications, early detection of such abnormalities has an important impact on the operation of critical components subjected to high stress, such rotating power generation components, where regular inspections are carried out not only at time of manufacturing, but also at regular intervals, to ensure reliable operation.
Traditionally, such inspections are carried out by a human expert; while the human is effective at locating abnormalities, they are subject to limitations in accuracy, consistency, speed and reliability. Therefore, strong motivation towards the automation of such surface inspection tasks has resulted in a range of different machine based inspection technologies.
Early inspection technology was based on the analysis of camera images, and many automatic inspection systems utilise colour and texture analysis of digital images; examples of recent works in this case are given in [1,2], which focus on the detection of rail defects and abnormalities on titanium-coated Aluminium surfaces. A good set of reviews covering less recent research can be found in [3][4][5][6]. The lack of 3D local information is one of the main limitations of image based inspection systems. Stereo vision systems [7,8] can maintain the 3D localisation requirement but, are not appropriate for flat surfaces where there are no prominent features available. Structured light scanners [9][10][11] avoid this issue by projecting a pattern of light and dark features on the target surface.
One highly successful widely available technology, which is accurate, contactless and fast, is laser line scanning technology [12,13]. The low weight and compact size of laser line scanners allow them to be easily integrated with industrial robots to form a flexible inspection system. By using a robot to scan over a target surface, the laser scanner is able to acquire dense 3D PCs with micrometre level resolution. However, while large quantities of data can be quickly collected, the processing and analysis of this data to yield a robust inspection process still represents a significant challenge. A considerable amount of research has been conducted on the use of laser scanners for automatic inspection in manufacturing applications. One group of strategies for surface abnormality detection is based on the use of an existing ideal CAD model. Examples of such strategies can be found in [14][15][16][17][18]. The dependency on an existing ideal model of the object is the main issue for CAD-based strategies. Techniques that are independent of a CAD model include [19], where a noise removal method was proposed to detect simple deformations in a PC that resembles outliers in a smooth surface. In [20], a technique for PC segmentation based on octree structures and recursive subdivision of the volume of a 3D mesh was introduced. The subdivision was performed based on thresholding the standard deviation of surface normal. Both of these strategies are based on subjective tuning of a threshold parameter. In [21] enhanced octree-based feature extraction was combined with segmentation and classification. Deviation in surface normal was also used as point weights in [22]. The limitations of these methods remain unclear, in terms of the size of abnormalities that can be detected, given variable scanner parameters, and PC quality, such as line spacing or point noise. Such considerations of this technology for the detection of large abnormalities have been studied in applications such as construction and civil engineering, where abnormalities are a few cm in sizes on concrete surfaces [23]. Conversely, there are no studies that have considered the use of laser scanners for relatively shiny metal surfaces with abnormalities in the µm or mm size domain.
This paper addresses the problem of abnormality detection on freeform metal surfaces using PCs generated from a robot mounted laser scanner. The work is based on the premise that successful abnormality detection not only depends on the detection algorithm, but it also depends on other important factors such as the shape and size of abnormalities, the quality of the acquired PC and the scan conditions. In addition, the choice of a supervised or unsupervised strategy can also be an important factor. For example, an unsupervised detection strategy is an advantage when enough training samples are not available, data quality is consistent and a certain amount of error is tolerable; however, a well-trained supervised detection is preferred when robustness is important, especially when the data quality is not consistent. Therefore, this work starts by first systematically demonstrating how PC quality (e.g. noise and missing points) is a function of scan parameters (e.g. laser projection angle and line spacing variability). The impact of PC quality, on the performance of an unsupervised abnormality detection algorithm is then determined experimentally; showing how performance is affected by factors such as PC quality, abnormality size and threshold parameters.
Then, to achieve a more robust detection process, a supervised abnormality detection algorithm is considered, based on a more realistic scenario. In the scenario considered, the qualities of the measured PCs are highly inconsistent. This is a result of the target surface which is significantly curved, and a robot scan path which does not fully match the surface shape; as a result there are inconsistent laser projection angles, geometrically dependent variation in lateral line spacing, and varying noise over the PC. However, despite the significant variation in PC quality, the proposed supervised algorithm is able to cope with these issues robustly.
The paper is organized as follows; Section 2 is about the materials and methods; the equipment setups used for this work and the data sets collected are described. Section 3 is focused on the theoretical concepts and calculations related to PC analysis. The experimental results collected to investigate optimum inspection strategies are presented in Section 4, and finally there is a discussion and conclusion in Sections 5 and 6 respectively.

Materials and methods
In this section, data preparation requirements are described for both the unsupervised algorithm, where experiment condition is controlled, as well as for the supervised algorithm where more realistic conditions apply. This includes the artefacts, laser scanners, robot system and reconstructed PCs. The sources of noise and uncertainties in the PCs are also explained.

Artefacts
Two different types of Artefacts were used in this work. One of them is a planar square shape artefact of 6 × 6 cm size with a 5 × 5 matrix of abnormalities. The abnormalities are diamond shape cavities. At each row the abnormalities are similar in size. The diameter of the abnormalities in the first two rows is approximately 700 µm across, and then this is reduced to 550 µm, 180 µm and 120 µm in the next three rows.
The second type of artefacts, are Aluminium curved surface objects. Two pieces of Aluminium surfaces of around 20 cm length and 10 cm width with different curvature levels are used. On the surfaces there are bumps and dents of approximately 700 µm-1 mm in diameter.
The large freeform aluminium artefact is representative (in terms of material and potential defects) of car body panels and similar large scale highly curved structures. On the other hand, the planar artefact is intended to present a variety of abnormalities of different sizes; allowing us to draw conclusions on the impact that abnormality size has on the accuracy of the detection algorithm.

Laser scanners
Two different laser scanners were used in this work that will be described in the following sections.

Micro epsilon laser scanner
For the analysis of the planar artefact, a Micro Epsilon 3D profile sensor, scan control 2900-50 Laser displacement measuring system, was used. It is an accurate commercial laser scanner, consisting of a laser light source, a sensor matrix. Fig. 2.1 shows an image of the micro epsilon sensor that was used. The optical system on the sensor projects the diffusely reflected light of the laser line onto a highly sensitive sensor matrix. In addition to distance information (z-axis), the controller also uses the camera image to calculate the position along the laser line (x-axis). These measured values are then output in a twodimensional coordinate system that is fixed with respect to the sensor [24]. For this scanner, the number of points in a profile is 1280 and the adjacent point distances are 7.8 µm. At a middle z range, the resolution along the x axis is μ 40 m and according to the data sheet of the sensor, the resolution along the z axis is μ 4 m.

Custom made laser scanner
For the scan of the two curved shape Aluminium objects, a custom made laser scanner consisting of a Flexpoint MVnano, 450 nm, 1 mW, 30°fan angle, focusable laser and a Basler acA1600-20 gm GigE camera was used. Choosing a triangulation angle of 35°and a stand-off distance of 110 mm, the scanner resolution is calculated to be 84 µm/pixel (X direction, along the laser line) and 146 µm/pixel (Z direction, depth). This can be improved by fitting across the imaged laser line width, achieving sub-pixel resolution, as done by using the Halcon library [25] at the time of PC extraction (see Data sets in Section 2.3.2). The number of points per scan line is about 800. Therefore, the resolution of the custom laser scanner is less than the micro epsilon commercial laser scanner, adding an extra challenge to the detection problem for the curved aluminium surfaces.

Robot
For testing both types of laser scanners, they were mounted on a Fanuc LR Mate 200 iC industrial robot arm, driven by a R-30/A Mate controller. Fig. 2.2 shows the Fanuc robot with the mounted custom made laser scanner. Moving the scanners with the robot arm over an object allowed a surface scan to be done, with a resolution in Y direction defined only by the robot motion.
In the case of the curved Aluminium objects, the robot path was chosen such that the laser scanner was almost normal and at the same stand-off distance to the target surface. This allowed scanning of the large objects with substantial curvature and height variation, without losing laser scanner data due to exceeding the working distance of the scanner, or due to signal loss occurring at high angles (attributed to light scattering and back-reflection). However, this path was generated from the estimated target geometry, obtained via interpolation of a few sample points; as a consequence, the scanning path might not always accurately follow the object surface, resulting in sub-optimal data quality, especially due to the highly curved surfaces. Additionally, the scan was performed with fixed step size in the Y direction (dY), resulting in potentially varying lateral line spacing (L i ) on a curved object (See Fig. 2.3, constant dY, varying L i ). The scan steps (dY) were 500 µm for the less curved Aluminium object (L-L) and 250 µm for the highly curved one (HeH).
The scan step (dY) was 50 µm in scanning of the planar artefact. This high resolution allows subsampling the scan lines to repeat the analysis for different resolution levels of lateral line spacing. The angle between the laser and the surface normal was varied in the range of 0°-25°in steps of 5°in scanning experiments of the planar artefact. This angular variation influences the PC quality, which will be explained further in Section 2.4.

Data sets
In order to generate a 3D representation of the scanned objects, the 2D laser profiles acquired by the camera sensor should be used. In addition, the camera, laser and robot calibration information as well as the 3D transformations related to the robot movement during the scan are utilised.

Planar artefact data
The resulting 2D profiles of scan lines from the Micro Epsilon scanner are transformed into the robot coordinate system using a 3D hand-eye homogenous transformation matrix (the transformation from laser scanner to robot end-effector) and also the unique transformations from robot end-effector to robot base for each scan line. Fig. 2.4 shows the results of the reconstructed surfaces for six different projection angles. On the top right of each plot, a zoomed area around < < − < < μ x μ μ y μ 459 m 460 m, 81 m 80 m is illustrated. It can be seen that the resulting PCs quality degrades severely for the last two angles and is poor at 15°. More explanations about PC quality and its relation to the projection angle will be given in Section 2.4. Due to the high resolution of these scans none of the abnormalities can be seen in Fig. 2.4. Fig. 2.5 shows the enlarged abnormalities of different sizes for the first three projection angles that have better PC qualities. These abnormalities mostly form a gap in scan lines. Although all abnormalities are clearly representing a gap in the scan lines, it is clear from the image that recognizing them from the PC is a significant challenge, especially for the smaller sizes. Fig. 2.6 compares the abnormalities of different sizes over the PC at a 5°projection angle. The two smallest abnormalities are indistinguishable from the normal regions.

Aluminium objects data
The curved shape Aluminium objects were scanned using the custom made laser scanner. Both objects contain distinct features, such as dents and bumps of about 700 µm-1 mm in diameter as shown in Fig. 2.7(a). In both cases, identical laser scanner settings were used, but the step size (dy) was changed, this was 500 µm and 250 µm for the L-L and HeH samples respectively. Subsequent laser line extraction and object reconstruction was performed using the Halcon image processing software library [25]. As each laser scanner image was taken, it was transformed into the robot base coordinated system that was chosen as a common coordinate system. Fig. 2.8 shows the two PCs and some of the abnormalities. As can be seen, the line spacing is not constant in both PCs due to the reasons explained in Section 2.2.3. The line spacing variability L i is shown as boxplots of the space between adjacent lines in which also indicates the level of spacing variation in each case. Based on the line spaces and the abnormality sizes in Fig. 2.7(a), it is clear that an abnormality should be coincident with at least two or three lines in most parts of the PCs. However, they  might be missed if they are located on those few number of outlying lines with more than 1 mm spacing.

Noise and uncertainties
Generally, in a laser scanner system, there are different sources of inaccuracy that can result in uncertainty in a PC; for example, reflection from surface (depending on the type of surface) or on sharp edges due to the blooming effect, environmental effects such as light condition or dust, shadowing that might occur when a part of the object lies in the path from the projected laser line to the camera or systematic range error due to the difference in reflectivity of the surfaces elements [26]. These effects result in gaps and holes in a PC due to partial reflections. However, by appropriate choice of the laser-camera positions and their angle to the surface normal, and by controlling the environmental conditions, these effects can be alleviated.  In addition, any scanning process parameter that vary the CCD laser image properties such as aliasing effects and speckle effects [26] can be considered as a factor that can influence the PC quality [27]. One of the factors that reduce the noise is the choice of threshold value used for laser line segmentation from the image profiles. A high threshold value might cause useful data be incorrectly discarded. On the other hand, a low value, can safely keep all the line points, but might result in a noisier PC, especially in some local region. In the case of the Micro-Epsilon sensor, this threshold is fixed at 128 for the manual mode that is used for this work. In the case of custom-made laser scanner, the threshold is adjusted slightly lower to 100, when developing the reconstruction program in Halcon. Due to these low value thresholds, noise removal strategies are employed in this work to reduce the effect of noise.
Another important uncertainty factor is related to the angle between the camera and surface normal at the laser incident point (α c ); the angle between the laser rays and surface normal, which is called the projection angle (α p ); and the angle between the laser and camera, which is actually The camera-laser angle is usually fixed in a laser scanner set-up. It is reported that the optimal angle for the latter is 90°, and for each of α c and α p is 0° [26]. These constraints are contradictory and a compromise in their values should be considered. For example, given a set-up with fixed + α α ( ) c p , a reduction in α p , means an increase in α c . In our work, the use of a Micro Epsilon commercial laser scanner means it is not possible to control these angles. Therefore, we consider the set-up as a black box and apply a data driven strategy to find the best angle for abnormality detection. For this aim, the projection angle is varied as described in Section 2.3.1. As shown in Fig. 2.4 the variation in α p , has great impact on the quality of PC. Computational analysis of the resulting PCs quality will be described in Section 3.1.1 and also the obtained results together with abnormality detection performance as a function of the projection angle will be shown in Section 4.1. In the case of the custom made laser scanner, the camera-laser angel is 35°and the laser was almost orthogonal to the surface during the scans, i.e. α p ≈ 0.

Data analysis
In this section, the analysis steps of the unsupervised approach, using the planar artefact to generate well controlled data will be explained first. Then, the proposed supervised strategy for the more realistic data scenario, using the curved surfaces, will be described comprehensively.

Unsupervised analysis
In this section, first the quality evaluation analysis for the planar artefact PCs will be described. Thereafter, the unsupervised abnormality detection strategy will be explained step by step. This strategy is used for the analysis of planar artefact data, with systematic variations in the threshold value, abnormality size, line space resolution and laser projection angle.

Computational analysis of PC quality
Different factors for the evaluation of PC quality have been reported in literature [28,29]. In this paper, the PC quality is evaluated based on completeness and noise. For the completeness measure, the idea used in [30] is considered. The number of missing data points over all the PC lines is divided by the total number of data points over the PC, including the valid data points and the missing ones. A missing data point is a point in the extracted lines in which, one of the 2D values is not measured properly, due to reflection, camera viewing angle or any other noise factors.

Missing Ratio
I missing points I total points The other quality factor that is computed is noise. It is measured as the standard deviation of the Euclidean distances of all points and their corresponding points on a locally fitted surface. For this aim, PCs are divided into patches of 2 × 2 mm and then, each patch is fitted to a plane surface. A limit of 20 points is considered for fitting a patch to a surface. That means that the patches with less than 20 points were not considered for noise evaluation. Since the acquired PCs in different projection angles vary in the number of total data points, the standard error of Euclidean distances is also computed to cancel the effect of the number of data points in the noise comparison.

Pre-processing
In order to alleviate the problem of low amplitude systematic noise and remove the outliers around the PCs, a smoothing filter is used for the data obtained from the Micro Epsilon. The MATLAB "pcdenoise" function was used. This function removes outlier points. A point is an outlier if the average distance to its k-nearest neighbours is above the specified threshold. In this work, k is chosen as four and the threshold is one standard deviation from the mean of the average distances.

Unsupervised abnormality detection
As seen in Fig. 2.5, the abnormalities of the planar artefact form gaps over the scan lines. Therefore, for abnormality detection, the Euclidean distances between the adjacent points i, j in each line is computed, d ij and the points are assigned to the abnormal class C abnormal if their distances are more than a threshold (see Eqs. (3.1) and (3.2)). Otherwise, they are assigned to the normal class C normal .
In this work, a PC obtained by the Micro Epsilon scanner consists of more than 1.5 million data points. To reduce the scale of the abnormality detection problem, the PC is subdivided into groups that each represent a surface patch of 2 × 2 mm. In this way rather than considering data on a point by point basis, and the abnormality detection decision is made for each individual patch.
Due to the flat structure of the planar artefact, the lateral line spacing (L i ) and the step sizes (dy) are equal in this case. Since we are interested to see how the resolution in lateral spacing between the lines affects the abnormality detection, subsampling of the lines is performed at = sp [1, 2, 3, 4, 5] levels. As mentioned in Section 2.2.3, the line spacing resolution dY is 50 µm for the planar artefact. For each line spacing, the detection process is repeated based on different thresholds. The threshold values are varied based on the diameter of the abnormalities μ μ μ μ {700 m, 550 m, 180 m, 120 m} divided by two. Since the first two rows of the abnormality matrix have similar sizes, just one of them is considered.

Performance evaluation
The performance of this unsupervised binary classification is evaluated based on the performance of abnormality detection. In addition, from a manufacturing point of view, the most important factor is to detect the abnormalities, or true positives (TP). If misclassification occurs, then misclassification of a normal point as an abnormality, which is a false positive (FP), is less critical than classifying a true abnormal point as normal, which is a false negative (FN). Therefore, the receiving operating characteristic (ROC) curve is computed based on the true positive rate (TPR) or sensitivity as well as the true negative rate (TNR) or specificity [31]. They are computed as based on Eq. where TN is the true negative. An ROC curve is plotted as sensitivity verses the FPR or − specificity (1 ). We are interested to have high TPR, ideally one, and a low FPR.

Supervised analysis
A robust supervised strategy is used for the analysis of the realistic data scenario described in Section 2.3.2. In this scenario the PCs acquired from the curved Aluminium objects are noisier and have a varying level of noise and lateral line spacing. In addition, the shapes of abnormalities are more complex than simple gaps in scan lines (see Fig. 2.8). The main aim of the supervised analysis is to classify the PCs local regions into one of the two normal or abnormal classes. For this aim, the abnormal PC areas were labelled manually and the remaining PC areas were assigned into the normal class. A supervised strategy requires dividing the PC data into training and test sets. Around two thirds of each PC was considered for training and the rest for test. The data selected for training was then used to form a classification model. This model was used in the test step to identify the abnormal areas of the test PC data. The proposed algorithm can be described as three main steps; pre-processing for smoothing and highly noisy data exclusion, followed by feature extraction and classification model training, finally followed by a test step.

Pre-processing
At this step, first a fine smoothing is performed to remove the few undesired points around the PCs. Following the same approach used for the planar artefact PC, the MATLAB PC noise removal function, "pcdenoise", with a small neighbour size (less than five) and fine threshold value was used for this aim. While this alleviates small fluctuations over the PCs, some features associated with real abnormalities, especially in PCs with high line spacing, are lost after this step, as shown in Fig. 3.2. In the data sets used in this work, this effect was observed in some left side areas of HeH (see Fig. 2.8). One of such abnormalities is shown in Fig. 2.8.c. Due to this effect, an abnormality detection model should be developed based on features that are capable of finding such cases.
Another issue is that, this fine smoothing step does not remove the more significant noise in the PCs. As explained in Section 2.4, due to the low threshold level, noisy PCs were formed. Basically, two different noise effects can be observed in the data sets; there is a general noise in all PC areas and even with fine smoothing, some noise is still present. In addition, regions of high level noise exist in some sections of PCs. To illustrate the variability in PC quality, an example set of PC data, containing such a spread of noise and also a real abnormality, is shown in Fig. 3.4. Such noisy regions can easily be misclassified as a real abnormality which increases the amount of FP. To cope with this possibility, an adaptive local mean filter is used on small patches of PC before feature extraction to handle the general noise effect. In addition to the adaptive filter, a novel approach is taken to address the second noise spread problem, whereby all data from the laser scanner is accepted regardless of the perceived quality. An algorithm is then applied to assess the quality of the data, in order to detect the regions with a high spread of noise; to achieve this, the following analysis steps are performed: • First, the most suspicious lines, in terms of noise, are found using the point to point gradients as a means of variation detection. The sum of the absolute values of point to point gradients for each scanned line = … l 1, 2, , N PC are considered, . n l is the number of points at line l and ∂Z i /∂i shows the gradient of changes in the Z direction at point i which is the direction that the height variation noise occurs. Then, those g l s higher than one standard deviation from the mean are considered l as a list of suspicious lines.
• Second, the list of suspicious lines is analysed. The aim is to find whether the observed noise in a line is due to the existence of a local abnormality observed in a small number of points in the line, or if the noise observed is spread over a large number of points. For this aim, the suspicious lines are segmented into bins of fixed length (20 points) = … , b 1, 2, , B and the variation in each bin is compared to the average variation of the line population. Based on our observations, a pre-assumption is that the number of regular points in a line is not less than the highly noisy ones. This means that the average variation of total bins is closer to the population of regular points, rather than the noisy ones. Based on this, the average sum of the absolute values of gradients at each bin μ b as well as the total average over all the bins μ tb is calculated. Then, the difference of each bin from the overall average (of gradients) is computed. Considering the distribution of distances is normal, a threshold can be defined using their average and standard deviations + μ σ d d to detect the number of irregularities in the line that exceeds the threshold. If there are few numbers of bins (e.g. less than 5) far from the average distances, there exists a local region rather than a more evenly spread noise contribution (see Fig. 3.3). Such lines are excluded from the original list of suspicious lines found in the first step.
• Third, the suspicious lines are checked to be adjacent and those individual lines far from the other groups are excluded. A margin (e.g. 2) is also considered to include the neighbour lines before and after the group of lines in the list.
• In the last step, the noisy points of the group of lines are found based on thresholding the g l s as performed in the first step. The detected points at each line are integrated to remove the discontinuities and the neighbour points within a margin before and after the area are also included. Furthermore, the spread of indices between the group of lines are equalized so that, an integrated rectangular shape area is formed as shown in Fig. 3.3 and the corresponding indices are recorded in a filtered list L.
These points are excluded from the analysis and their 3D location can be used for further follow-up, re-scan and inspections.

Feature extraction
The features necessary to classify an abnormality are defined based on the structures and characteristics of abnormalities that make line data collected for them different from the data collected from a regular surface. PC abnormalities are not all in similar shape. For example, the abnormalities shown in Fig. 2.8a and b of L-L are more similar in structure to the one shown in Fig. 2.8d for HeH. However, there are abnormalities such as Fig. 2.8c, which are different in structure due to the smoothing at pre-processing step explained in Section 3.2.1. The abnormalities similar to the former case might be confused with some noisy regions of the PCs, but the shape of those similar to Fig. 2.8c is different due to the missing points. They have similar form to the  For feature extraction, the labelled abnormal regions as well as some points from different normal regions of each PC training area are considered. An equal number of data points in the abnormal and normal classes is considered. That is due to the use of support vector machine (SVM) classifiers, whose decision boundaries are sensitive to unbalanced classes and can be skewed toward the dominant class. A local rectangle patch of points of only a few millimetres is considered around each point. An adaptive local mean filter is applied to the patch for denoising in the next step. The window size of the filter changes adaptively based on the sum of absolute values of gradients inside a patch, which shows the level of variability and noise in that patch. Thereafter, six different features are extracted, that will be described in the following subsections.

Normal features.
One type of classic feature for abnormality detection is surface normal. For finding the normal to a patch, a surface is fitted to the patch points and then, the normal to the fitted surface is computed (see Fig. 3.5). This normal is initiated from the average coordinate of all points in the patch (P i in Fig. 3.5). Then, the angle between the normal and the connecting vector between P i and each point in the patch P p is considered (α in Fig. 3.5). The deviation of α from 90°increases mainly when there are variations in a patch due to the existence of an abnormality or high level of noise. Recalling that the major noisy regions are excluded at the pre-processing step and the adaptive filtering alleviates the noise, we observed that the number of points with high level of deviations (e.g. more than 50°) is more in an abnormal patch than a noisy or regular one. Therefore, the first normal feature is defined as the number of points in the patch with high degrees of deviations The second feature is defined based on the absolute value of difference between Δ αp and their population mean μ (Δ ) . The population mean is computed using all the samples in a patch. This feature can be discriminative in conditions that the number of abnormal points with large deviations is less compared to the majority of regular points in a patch.

Height features.
A significant characteristic of most abnormal patches is the change in height of some points compared to the regular points. This can be quantified as a feature for each point in the patch f Zp , by fitting a surface to a patch and finding the differences in the original height of the points and the corresponding height in the fitted plane.
In addition, the height changes can be considered at each line within the patch. In this case, the absolute value of height deviations from the population mean at each line is considered

Chi-squared statistics (χ 2 ).
Since in many cases, the abnormal points in a patch line have similar behaviour to a Gaussian distribution, the goodness of fit to a Gaussian is considered as a feature f χ 2. The chisquared statistic is a measure of the goodness-of-fit of the data to the Gaussian model. This statistic shows how many standard deviations each data point lies from the model and is computed using Eq.  Fig. 2.8c, there is not any significant local variations in   pr so that, d ne , d pr are the distances to the nearest points in the next and previous lines respectively. This feature is discriminative for the abnormal points before or after a line with a gap in, or the points located in peaks or valleys around the abnormality area. However, they may not be significantly different for the points within the line that the gap is located.
3.2.2.5. Feature transformation. An important requirement of a robust classification model is to be trained based on discriminative features. Meaning that, the features of different classes should be well separated from each other and the level of overlap between the features of the two classes should be as small as possible. As will be shown in Section 4.2.2, there exist some overlap between the features of normal and abnormal classes of the training data. In order to increase the distance of the training features of the two classes (F tr ), the well documented generalised Rayleigh Quotient strategy for feature transformation is employed [32,33].
We consider the mean and covariance of the two normal and abnormal classes as μ ( , Σ ) no.
abno. . Then, the generalised Rayleigh Quotient strategy is based on the within-class covariance and between-class T . n no. and n abno. are the number of samples in the two classes and μ t is the total mean of all of the two class's features. The basic idea is to transfer the original training features trabno into a new orthogonal space so that, the distance between the features in each class be minimized (S w ), while their distance to the features of the other class be maximized (S B ). The results should be a reduction in the overlap between the features of the two classes and this enhances the classification model. For this aim, the, Eigen decomposition of − S S w 1 B is performed to find an Eigen vector that maximises the generalised Rayleigh Quotient objective function: The resulting Eigen vector (w) corresponds to the largest Eigenvalue. Depending on the desired percentages of variation that is explained by the Eigen values, more than one Eigen vector can be used. In this work, the first three Eigen vectors, W (1,2,3) are used for transforming the training and test features (F tr , F ts ) into an orthogonal feature space so that, = T F W tr tr (1,2,3) and = T F W ts ts (1,2,3) . Then, having n samples and p features as F n × p , the transformed features will be T n × 3 . The transformed features of the two classes will be better separated from each other as will be shown in Section 4.2.2.
3.2.2.6. Training a classification model. Using the transformed features T tr , an SVM classifier is trained. SVM is a kernel-based classification method, which is based on a maximum margin algorithm [34]. The reason for the choice of this classification method is that it is appropriate for data sets with linear or non-linear behaviour due to the use kernel functions in its' objective function. SVM maps features into a high dimensional feature space using the kernel so that the classification is performed more easily. For training an SVM classification model, an optimal kernel function as well as its associated optimal parameters should be found.
Usually, model selection strategies such as K-fold cross validation (CV) is used for tuning the kernels and parameters [34]. It divides the training data (F tr) into K roughly equal-sized folds and each time considers one of them as a validation set and trains a model using the rest of the folds (see Fig. 3.6a). For the k th fold, a candidate model (e.g. a candidate kernel) is fitted to the other (K− 1) folds of the data. Then, the model error (prediction or classification error) is calculated by applying the fitted model on the k th fold. This is done for = k K 1, 2, . . ., . Combining this with the number of candidate models gives a validation error map. By averaging the error map over the K folds, the optimal model is identified based on the minimum average error (see Fig. 3.6b). The dimensionality of the average error map depends on the number of candidate parameters. For example, in this work, the choice of kernel and three related parameters are done using an 8-fold CV; the resulting five dimensional error map is averaged over the eight folds that give a four dimensional averaged error map. The minimum element of this map is used to find the optimum parameters among the candidates. In this work, the LibSVM [35] toolbox for MATLAB is used for the SVM algorithm.

Test step
A PC, acquired from the custom made laser scanner, typically is on the scale of a few hundred thousand points. Applying the feature extraction and classification on this large set of points is computationally intensive. In order to reduce the computational load, first a fast unsupervised thresholding strategy, similar to the method explained in Section 3.1.3, is applied on each PC. The threshold value is chosen based on the range of abnormality sizes.
The result of this unsupervised step provides all the suspicious points including abnormalities (TP), noisy and missing point areas (FP). Using this subset of data means the main analysis steps, including patching, adaptive filtering, feature extraction are performed only on the limited set of suspicious points. The learnt Eigen vectors W (1,2,3) (from the training data) is used for feature transformation afterwards, = T F W ts ts (1,2,3) . Using the trained SVM classifier, the extracted features are classified into one of the normal or abnormal classes. During the feature extraction, when a patch is defined for one of the suspicious points, the analysis is also performed for any other suspicious points in that patch. In other words, more than one suspicious point might share the same patch.

Experimental results
In this section, the obtained results from both the unsupervised as well as supervised analyses strategies for the planar artefact and curved shape Aluminium object will be presented.

Unsupervised analyses results
In this section, first, the evaluations of planar artefact PCs in terms of quality for different projection angles will be presented. Then, the unsupervised abnormality detection algorithm test results are described for all the controlled conditions and systematic variations.

Quality computation results
The first experiment for the planar artefact evaluates the quality of the PCs, when scanned in different projection angles. As explained in Fig. 3.6. (a) The CV concept, (b) an example of a one dimensional averaged error map for selection of optimal model. Section 3.1.1, the quality was evaluated in terms of the number of missing points and deviations from a local fitted surface. Due to the lack of points in the 25°data (see Fig. 2.4), the PC in this projection angle could not be analysed. Table 4.1 presents the results. As can be seen, all of the calculated factors including the number of missing points in scan lines, the mean, standard deviations and standard errors of Euclidean distances from the locally fitted surfaces are increased as a result of increasing the projection angle of the laser scanner.
Due to the poor quality of the PCs and increased number of missing points acquired at the 15°and 20°projection angles, the PCs at these angles were not considered for the abnormality detection analysis.

Abnormality detection results
The second experiments for the planar artefact, is about abnormality detection. Four different factors were varied in this experiment; the systematic change in sizes of abnormalities of the planar artefact (see Fig. 4.1), the threshold for the unsupervised detection algorithm, the line resolution (step size dy) and the projection angle. The PCs were analysed based on the analysis procedures described in Section 3.1. Fig. 4.2 shows the number of abnormalities that have been detected at a 5°projection angle by the unsupervised strategy for four sizes of abnormalities and for different threshold values and line resolutions. Since the first two rows have similar abnormality sizes, the results of just one of them are reported. As can be seen, the detection process improved for higher resolutions (smaller dy) and smaller threshold values. Although that is the desired result, the low threshold values increases the number of wrongly detected abnormalities dramatically. It is not feasible for an inspection system to re-check most parts of the object for abnormalities that are incorrectly detected.
The ROC curves for different lines spacing resolutions and threshold values at 5°projection angle are shown in Fig. 4.3. As can be seen, for small threshold values, both TPR and FPR increased. While the former is desirable, the latter results in a problem. In the worst case, when both the resolution and threshold were lowest in value, the FPR was one, meaning that all the normal patches were detected as an abnormal. It is therefore clear that a compromise should be made to have a high TPR but low FPR. The last two rows of abnormalities were hard to be seen even by eye and in the PCs, they could not be distinguished from the normal areas as shown in Fig. 2.6. Therefore, reducing the threshold to detect those sizes of abnormalities introduced a significant amount of FP to the results. Consequently, the results of applying the two smallest thresholds, the diamonds and pentagrams markers are overlaid in Fig. 4.3. Similar trends were seen in the results for the other analysed projection angles 0°and 10°.
Due to the reasons explained in Section 2.4, the projection angles of the Micro Epsilon laser scanner in terms of abnormality detection were evaluated based on the data analysis results. In order to compare the combined effects of projection angle and line resolution, the TPR, FPR, TNR and FNR for different angles and line resolutions are illustrated in Fig. 4.4. The threshold value was kept at an intermediate level, 225 µm, in these plots. As can be seen, the best abnormality detection results or in another words, highest TPR and lowest FNR were obtained at 5°p rojection angle and after that at 10°. The worst result, lowest TPR and highest FNR, in this case was obtained at a complete 0°projection angle. The best result for classification of normal points, the lowest FPR and highest TNR, were obtained for 0°and then for 5°. Regarding the line resolutions, the higher resolutions obtained better results in terms of TPR and FNR but the FPR and TNR for them was also higher. This shows that, the higher the number of data points in the tested local patches, the better the abnormality detection. On the other hand, it is more probable that a normal point falsely be detected as an abnormal one among the many points in a highly dense patch.
In Fig. 4.5, the TPR, FPR, TNR and FNR verses different projection angles and threshold values are shown. Similarly, the worst TPR and FNR as well as the best FPR and TNR were obtained for 0°and the best TPR and FNR were achieved at 5°. The two smallest threshold values were the best in terms of TPR and FNR and the worst in terms of FPR and TNR.

Supervised analyses results
In this section the results of the pre-processing, combined with the training and test steps analysis performed on the curved shape Aluminium objects is presented.

Pre-Processing results
At the pre-processing step, the noise detection algorithm described in Section 3.2.1, found the regions of the PCs where a high level of noise exist. The distribution of noise over the HeH PC and the corresponding filtered noisy areas by the algorithm are shown in Fig. 4.6a and Fig. 4.6b respectively. Similar results are illustrated for L-L PC in Fig. 4.6c and Fig. 4.6d. Only the areas where there were a high level of noise spread were excluded and the local noisy areas were included in the data set to be analysed, and were treated by the adaptive mean filter before feature extraction.

Feature extraction and training step results
Based on the characteristics of the abnormalities of the L-L PC, that were explained in Section 3.2.2, five features including were used for training a classifier for this PC. These features are appropriate for abnormalities that have deviations from surface normal and height in their structure and have a shape that can be approximated by a Gaussian profile.
In the case of HeH PC, besides these five features, the maximum distance between the nearest points in the adjacent lines f prox was also used. Fig. 4.7 shows the extracted features from the HeH and L-L PCs. As can be seen in the distribution of features along the f N1 axis Fig. 4.7a and Fig. 4.7c, many abnormal features (in red colour) have high values ( > 50°) of Δ αp compared to the regular ones.
For a few abnormal features, (α p ) was close to 90°and therefore, their related f N1 was close to the regular features (in blue colour). That can also be observed along the f N2 axis. As expected, f χ 2 is lower for most of the abnormal features that have a Gaussian shape behaviour compared to the regular features (see in Fig. 4.7a and Fig. 4.7c, the f χ 2 axis). In the case of height features (Fig. 4.7b and Fig. 4.7d)), f Zp shows better discrimination rather than f Zl . This might be due to the fact that the former was computed using all data points in a patch while the latter was computed based on the data points of one line in a local patch. In the case of HeH, the last feature, f prox shows a discriminative effect between the two classes. As shown in Fig. 4.7b, along the f prox axis, the regular class features are grouped into two groups of low and high values. The low proximity features were extracted from the high resolution areas of the HeH, where the adjacent lines spaces were very low. Conversely, the regular points in the high spaced lines have high values of f prox . In the case of abnormalities, most of their features are in the middle part of the f prox axis, except those located on the high spaced lines of the PC. After feature extraction, the features were transformed into a new space, using the Rayleigh Quotient for increasing the distances of the features of the two classes, as explained in Section 3.2.2.5. The first three feature components in the new space are shown for L-L and HeH in Fig. 4.8. As can be seen, the training features are well separated in the new space and the classification performance was 100% and 98.913% for the training labelled data of HeH and L-L PCs respectively.

Test step results
At the test step, first the unsupervised thresholding were applied to detect the suspicious points as shown in Fig. 4.9 for HeH and L-L PCs.
The suspicious points that were among the initially detected highly noisy areas (from the filtered list) are shown in black colour in the images. Those points weren't considered in the next analysis steps. Then, based on the algorithm procedures explained in Section 3.2.3, the final abnormalities were classified (Fig. 4.9b and Fig. 4.9d). The program found all the abnormalities successfully for both PCs and there were no false positives in the case of L-L and only one false positive for HeH.

Discussion
The results obtained from the unsupervised strategy demonstrated the influences of the factors that were varied systematically over the data sets. Two key factors in this case are the choice of the threshold value for the unsupervised algorithm, and the sensitivity of the algorithm to the laser projection angle. An ideal inspection system should detect all the abnormalities and gain a sensitivity value equal to one, it should not misclassify any normal region as an abnormal one (an FPR value of zero or specificity of one); however, this optimal performance is not usually the case when systems are put in to practice. As such, the analysis of results from the Micro Epsilon scanner showed that by using small thresholds, high sensitivity is achieved but, the specificity dramatically decreases. Therefore, a compromise should be made in the choice of threshold. This is also acceptable empirically based on the fact due to the limits of the laser scanners resolution, it is impossible to detect the two smallest sized abnormalities that are located in the last two rows of the planar artefact. Hence, we do not expect the classification algorithm to detect them. While this represents a lower limit in terms of abnormality detection, it does mean that a proper threshold value can be chosen at a higher range e.g. in this work a value of half the size of the third smallest abnormality. Fig. 5.1 shows the detected number of abnormalities at each row of the planar object when different thresholds were chosen. As can be seen from Fig. 5.1, abnormalities can be successfully detected if the threshold size is at least less than the defect size.  As well as considering the resolution of the laser scanner device, it is also important to consider how this device is positioned relative to the target surface. In particular it has been shown that the laser projection angle with respect to the target surface is an imporant factor to consider. The analysis of PC data, aquired for a range of projection angles, showed that even though the best PC quality was achieved at 0°, the  unsupervised abnormality detection algorithm has the worst results for this projection angle. This can be explained based on the geometrical characteristics of the diamond shape abnormalities. That means the surfaces within these abnormalities become better visible to the laser scanner at 5°. This was determined based on the data driven optimisation strategy that was applied. Based on the observed results, it is clear that the good PC quality at 0°helps to avoid misclassification of the normal regions of the PC so that, the best FPR is obtained in this angle and after that at 5°. Therefore, the interesting result of the data driven strategy suggests that, the 5°can be considered as the best compromise on the projection angle for having optimum TPR and FPR value. Regarding the proposed supervised technique, according to the results shown in Section 4.2.3, the unsupervised thresholding strategy that was applied initially on the curved objects data found a set of suspicious points that also included some normal points (FP) besides the abnormal points (TP). That indicates the important role of the proposed supervised feature extraction and classification algorithm for achieving robustness. One of the main issues in this work is the choice of features. Generally, it is desirable to choose the most discriminative features with minimum correlation or dependency. In order to test the advantage of keeping all selected features, the model performance was evaluated in terms of FP and FN as well as the classification performance at training step for different sub sets of features. Therefore, the classification model was trained separately using the two normal features, the two height features, the chi-squared feature for both L-L and HeH and also using the proximity feature for HeH and the performance was evaluated. As shown in Fig. 5.2, for both PCs, the best result was obtained using all the features. This demonstrates that each of the defined features characterize a unique aspect of the abnormalities that   is important for discrimination.
Regarding the required time for inspection and analysis, the current inspection system is presented as a proof of principle and current inspection speed is on the order of 500 mm 2 /s. However, an optimized setup can perform orders of magnitude faster and can be achieved through more effective integration of robot and laser scanner. In addtion, the use of high frequency line scanners, allowing for faster surface sweep, would also increase inspection speed. Having a previously trained classification model the data analysis time is also short. The running time of the test algorithm for finding abnormalities on the aluminium object, where the aquired PCs were on the order of 150 thousand data points, was 3.35 s (using MATLAB 2015). This make the use of proposed inspection strategy reasonable for real time applications.

Conclusion
In this paper two data analysis strategies for surface abnormality detection in the manufacturing domain were presented. The relationship between PC data quality, size of abnormalities and threshold parameters with the performance of an unsupervised thresholding abnormality detection algorithm was investigated. A commercial laser scanner, manufactured by Micro Epsilon, was used to scan a planar artefact in controlled conditions considering abnormality size, resolution and laser projection angles. The PCs quality in different projection angles was evaluated. In addition, the effect of abnormality size, threshold value, scan line resolution as well as the projection angle (PC quality) on the sensitivity and specificity of the unsupervised thresholding algorithm was studied. The results showed that using an intermediate threshold value of 225 µm, the best compromise in the desired TPR and FPR results can be achieved. In addition, based on the characteristics of the abnormalities and structure of commercial laser scanners, a 5°laser projection angle achieved the best compromise on discrimination of abnormalities from regular regions in terms of TPR and FPR. Furthermore, a robust supervised abnormality detection strategy was proposed for a more realistic data scenario, when the two different PCs with inconsistent quality and complex object shape was used. Results showed that robustness cannot be achieved in this condition using only an unsupervised thresholding strategy. However, using such a method prior to the supervised detection step is beneficial as it helps reducing the computation load for the subsequent supervised classification steps. The training classification performance of the proposed supervised strategy was 100% and 98.913% for the two PCs, all abnormalities were found in the test step and there was only one FP for one of the two tested PCs.