Illumination system optimal design for geometry measurement of complex cutting tools in machine vision

Precision geometry measurement of complex cutting tools has a significant impact on the machinability of components in the industry. However, acquiring high-quality images in machine vision is a challenging problem due to the large slope and complex geometry. In view of the vital function of illumination, this paper proposed a method of optimal design for the LED array. First, the calculation model of irradiance distribution on the measurement plane is established, and the properties of the reflected light from the surface of cutting tools are analyzed based on the BRDF theory. Then, the optimal parameters are solved through the specific algorithm flow for the LED array design. Finally, a flexible LED light source is fabricated with the optimal parameters for different features of the cutting tools and used in the measurement. The measurement results show that the error of the optimized light source is less than 1%, and compared with the off-the-shelf light, the measurement accuracy is improved by 9.5% on average. Moreover, this method also presents the potential applied to other complex objects.


Introduction
In the aerospace industry, complex cutting tools are being more widely used in the manufacture of aviation parts [1]. Especially for drilling holes on CFRP components, it is proved that the structural optimization of the cutting tools has positive effects on damage reduction during the process [2]. Since tool geometry significantly impacts the machinability of components, precision measurement of the parameters of the cutting tools is necessary for better manufacturing. In addition, the knowledge of the geometry of cutting tools is also the key to exploring mechanisms of material removal and damage during the manufacturing process [3]. Currently, the most commonly employed universal optical microscope (e.g., Alicona infinite focus microscope [4]) measures the numerous parameters of cutting tools with the advantage of high resolution. While in actual measurements, the small depth of field and tedious operation steps limit the efficiency and repeatability. In contrast, the application of machine vision and imaging processing technology can be used to calculate the geometry parameters of tools rapidly and accurately. Over the previous decade, machine vision has existed as a mature technology and proved the feasibility of this technique in principle [5,6]. However, more complex structures have emerged with the gradual diversification of cutting tools. Due to the large slope and complex geometry, it is difficult to obtain image features of the complex cutting tools by using the general optical measurement system, which brings a new challenge for the application of machine vision [7,8].
For the geometry measurement in machine vision, the illumination is critical to automize image optimization, while the quality of the feature image and the efficiency of the processing algorithms can be improved with well-tuned illumination patterns and light parameters [9]. Generally, the off-the-shelf LED light sources are used directly for measurement in practice which results in variations of imaging quality between different objects [10]. Over the past few decades, illumination optimization has aroused the interest of many scholars. Of these, global homogeneous lighting throughout the field of view is the main target of illumination systems in most cases [11][12][13]. In order to achieve uniform far-field irradiance, Ivan et al. proposed a design method for an array of LEDs assembled on a spherical surface [14]. The approximate formulas of the LED array were derived by establishing the LED illuminance model of the spherical arrangements. Then, the optimum placement and angular spacing of LED-to-LED can be calculated with the analytic formula under the uniform irradiance restraint. Their work provided a basis for LED array configuration. Still, their model assumed the illuminated object to be a flat surface, meaning the case of light reflection was not considered. Apart from the analytic method, Su et al. also developed a numerical optimization method to optimize the LED array arrangement for uniform illumination distribution [15]. Another important indicator to evaluate the quality of illumination is the image contrast of the interesting object. In machine vision, most often the directional properties of the illumination are used to enhance the visibility of the essential features. More recently, with the help of reflection model theory and rendering techniques, illumination designing approaches based on surface reflection properties were reported [16]. In ref. [17], a contrast optimization model was built based on the improvements of Cook's reflection model. Furthermore, the optimal LED parameters (e.g., wavelength, angle of incidence and intensity of light) can be obtained to realize higher contrast in the image of objects with different materials. Similarly, Wataru et al. reported a low-cost illumination unit for multi-contrast imaging by changing the LED array illumination pattern [18]. The combinations of line LEDs enable the acquisition of dark-field, bright-field, and phase-contrast images. In addition, some published studies exist that deal with the optimization of non-standard LED light sources in machine vision, such as illumination for automatic optical inspection (AOI) [19,20] and combined lights [21]. Despite the widespread development of illumination design methods, these approaches above are inapplicable to the measurement of cutting tools with complex structures and high surface reflectivity, as it may result in loss of real features in the image. Up to now, few solutions on how to solve the problem of optimized illumination proposed to capture high-quality images for measurement of complex cutting tools. Thus, illumination system optimal design in machine vision should be considered, which is necessary for tool performance detection with high accuracy and efficiency.
In this paper, the multi-step micro tooth cutting tools with complex structures are taken as the main research object. We demonstrate the impact of illumination on image quality in the measurement system. Combining the illumination reflection model and radiation properties of the LED, we proposed a design and optimal method for the illumination system to resolve the problem of low accuracy and inefficient in geometry measurement of cutting tools. The rest of this paper is organized as follows. In Section 2, geometrical parameters and features of the cutting tools are introduced. After that, the images acquired under general lighting conditions are analyzed and an evaluation method of image quality for cutting tools measurement is proposed; Section 3 describes the improved reflection model and the optimal design method of illumination. Section 4 exhibits the experiment of illumination optimal and measurement results of the cutting tools; Section 5 is the conclusion of this paper.

Geometrical parameters of the drill bits
In this paper, we take the stepped drill bits with sawtooth structure as the measurement object. As shown in Fig. 1, the macro structure and the geometrical parameters are presented. According to the complex structure of the end surface, it is extremely hard to segment the geometric characteristics of these parameters. The length of chisel edge b ϕ , the thickness of drill center d c , and the width of sawtooth c 1 are the most important geometrical parameters on the end surface for the drill bits. As we know, the chisel edge is defined as the line obtained by intersecting the two flanks of the drill bits (the red part in Fig. 1(b)). The edge curve of one flank should be extracted from the image collected perpendicular to the end face to measure the length of the chisel edge. Whereas the remaining two parameters are defined by two spiral flutes (the blue part in Fig. 1(b)).
The following steps are usually conducted to achieve the measurements of the above parameters based on machine vision. First, considering the lens distortion could not be avoided, we calibrated the camera. Next, clear images with these features of the parameters at the focal planes should be acquired. Then, the edges of the features are extracted by the sub-pixel-precise thresholding operation method. Finally, the outcome measurements can be obtained by calculation of the pixel with the prior information. It follows that the quality of the feature images is the key factor in the precision and efficiency of the measurement in machine vision.

Image analysis
A vision system is built to acquire the features and a ring light is used as the light source. Figure 2 shows the imaging result of the three features to be measured under the ring light. As can be seen directly from the figure, the images may suffer from the problems of low contrast and local high reflection phenomena, which makes it difficult to identify the features. Further analysis is made on the result of edge detection, and the results are shown in Fig. 2. Although a suitable edge detection method is applied, it is difficult to accurately extract the features of the parameters to be measured. The main reason for this problem is that the standard bright-field illumination is hardly suitable for the imaging of drill bits with complex structures. Towards highquality imaging, the goal of illumination system optimal design is to make the important features visible and clear from the background. Therefore, the edge contrast and uniformity of the feature should be taken into consideration.

Irradiance of the LED array
As the most popular light source in machine vision, LEDs are being extensively used. The flexibility and stability of the LED array provide a possible path to multiple lighting regimes. In this paper, in order to realize the optimal lighting design based on the LED array, the irradiation characteristics of a single LED are analyzed at first. The calculation of a single led radiation on the target plane has been discussed in many articles. Very often, a light-emitting diode is packaged with different structures, which produces light beams with different luminous angles. The intensity distribution of the light source emitted by LED is related to the half-angle θ 1/2 and accords with Lambert distribution. at any observation angle θ is a function of the cosine to the mth power. It can be expressed by the following formula: Here, E 0 (r) is the value for illuminance at the axial distance r from the LED and m is a factor related to the half-angle θ 1/2 can be calculated by the formula: In previous literature [12,14,17], researchers have given an expression of the illuminance perpendicular to the incident direction of the LED and the target plane without taking into account the incidence at other incident angles. In this paper, the expression is improved to calculate the irradiance of different incident angles. As shown in Fig. 3 (b), we assume the LED is set at the crossover point of X i axis and Y i axis and X-Y is the target plane placed at Z i = z. Then, the irradiance of a point on the target can be written as: where α i is the incident angle of the led. The irradiance at any point on the target plane can be calculated with this equation. We assume the half angle of the LED is 30 • , and Fig. 3(c) shows the calculation result of radiation distribution on the target plane with three incident angles.
As can be seen from the figure, with the change of incident angle, the distribution of illuminance shifts on the target plane, which affects the uniformity and contrast of illumination. Moreover, we can also conclude that the half angle is also an important factor influencing the distribution of illuminance. The large angle is more beneficial to realizing uniform illumination, whereas the small angle makes it easier to produce high-contrast lighting.

Reflection model
Usually, the surface of cutting tools is regarded as a mirror plane and a simple model based on geometrical optics is used to discuss the reflection at the metal surface. Actually, as shown in Fig. 4(a), the metal surface presents tiny grooves due to the grinding process during manufacturing. Therefore, a physical illumination reflection model based on micro-panel theory is more suitable for the calculation of light reflection on the tool surface. According to the microfacet theory [22], the geometry of the BRDF definition is illustrated in Fig. 4(a) and the BRDF model of specular reflection is established as: where n is the normal of the macroscopic surface, l is the unit vector of the incident light, and v is the unit vector in the direction of the viewer. In this equation, F is the reflectance function (Fresnel function) which represents the reflectance of the incident lights. And D is the normal distribution function (NDF) of the microfacet. It is the probability density function that describes the proportion of microfacet with the surface normal h. The NDF is not enough to fully characterize the micro surface for the fact that some microfacets will be invisible from a given viewing or illumination direction. So G is the masking-shadowing function (geometry function) to calculate the reflected lights that are visible in the given direction. The three functions describe the general reflection properties of the surface. In this paper, considering the materials of the cutting tools is the alloy, the approximate calculation formula of the Fresnel function [23] is as follows: where F 0 is considered as a coefficient that depends on the surface material and the incident lights' wavelength. For metals, the value of F 0 is usually greater than 0.5, and this approximate calculation is convenient and accurate. Due to the randomness of groove distribution on the surface of the cutting tools, a microfacet distribution function based on a Gaussian distribution of microfacet slopes is applied. The expression is as follows: where γ is the tilt angle of the microfacet which is defined as |θ i − θ r |/2 , and the σ is the surface roughness. For the expression of the Geometry function, we adapted the Blinn V-grooves attenuation assumption: Thus, the reflection properties at any incident angle can be numerically calculated by the above formulas. In order to accurately describe the reflective properties of the cutting tools. Here, we obtained the BRDF curves of three observation angles under σ = 0.1 and F 0 = 0.8 (these parameters are selected according to the characteristics of the metal surface of the cutting tools) and the results are shown in Fig. 4(b). As the incident angle increases, the These curves reflect the accuracy of the calculation model, and then the radiance of the reflection on the surface to be measured can be calculated as follows: where L n (l) is the incident irradiance of the cutting tools and can be calculated by the formula (3) and through this illumination calculation model, the relationship between the light source at the exact position and the irradiance received by the camera can be calculated, and then the position of the light source can be optimized.

Parameters optimal design of LED array
The relationship between the spatial distribution of LEDs and the distribution of reflected illuminance of the surface to be measured can be obtained by the analytical models mentioned above. In the measurement of the cutting tools by machine vision, the goal of the illumination is to realize the high-contrast features against the dark background as well as the uniformity. Thus, the optimized solution of the design parameters can be solved with the objective function of contrast and uniformity. In this paper, we designed a flexible and adjustable structure to set up the LED array. As shown in Fig. 5(a), a light substrate with a gradientdecreasing structure is designed. This structure allows for multi-angle illumination while minimizing the effect of occlusions in the figure. The LED is vertically assembled on the substrate's surface, and the substrate's height and position from the system's center can be adjusted. Four substrates are designed around the cutter at equal intervals to realize the partition lighting. Three lighting angles are prepared on each substrate, one LED is placed in each grade, and 12 LEDs are designed in the whole light source system. And the spatial coordinate is established according to the measurement system. The Y axis is defined as coincident with the optical axis of the telecentric lens and the projection plane of imaging lies on the X-Z plane, and the origin is located at the center of the cutting tools. Then, we assumed that the coordinate of the LED in space is L i (x i , y i , z i ) and the incident angle of the LED is defined as α i . Thereby, the illuminance of the spatial combination LEDs can be calculated by superposition with formula (3) and the irradiance of the X-Z plane can be calculated by formula (8).
Firstly, the high-contrast lighting is discussed. Due to the cutting tools' complex morphology, each feature's normal is different. In measurement, the view direction is certain (the X-Z plane). Thus, the observation angles of various features depend on the direction of the normal. According to the BRDF curves of the tool surface, the angle of incident light must be at least 25 • to distinguish the illuminance of different reflecting surfaces. In addition, the application of partitioned light sources is also beneficial in improving the contrast of illumination. As shown in Fig. 5(b), in order to measure the chisel edge, one of the two flanks of the drill bits is the feature that needs to be illuminated. Due to the structure of the drill bits is axisymmetric, the design parameters of symmetrically partitioned LEDs should be the same. Then in order to evaluate the uniformity of the illumination, the following formula is applied: where E ave is the mean irradiance and E max presents the max irradiance of the feature region. Finally, the position of the substrate and the illumination angle of the led is adjusted according to the solved coordinates of the LED, and the illumination optimization of the system is realized. Here, we take specific drill bits as an example to explain the process of the selection of the parameters in detail. The specific algorithm flow for the LED array design is as follows: 1. The input parameters are obtained according to the cutting tools' primary dimension characteristics. As shown in Fig. 5(a), we take a drill bit with a diameter of 6mm as an example, and the goal is to measure the length of chisel edge b ϕ . One of the flanks is taken as the feature. In the coordinate system shown in Fig. 5(a), the angle between the feature face and the Y axis is ϕ 1 = 60 • , so the reflection angel θ r = 30 • . From the BRDF curve shown in Fig. 4(b), it can be seen that when the incident angle is 70 • , reflectivity is the largest, which can be distinguished from other features. Under the constraint of the substrate angle, we choose θ i = 60 • as the incident angle. 2. The size of the field of view of the imaging system field of view is determined by the size of the X-Z plane. Considering the parameters of the camera and the center lens, the calculated size of the X-Z plane in this example is 12mm*12mm. In addition, according to the distance between the feature surface and the bottom of the drill bit, the size of the X-Y plane is assumed to be 100mm*100mm. 3. Determine the parameters of LED. In this paper, the LED with a half angle of 60 • and a power of 1.8W is selected to obtain good uniformity. According to the formula (8) and the two planes' sizes, the X-Z plane's irradiance distribution can be calculated under various LED coordinates. 4. In this example, we assume that the focal plane of the chisel edge feature is the zero plane. Hence, x i = 0 and y i = 0 (the coordinates corresponding to other features can be calculated from the focal length). According to the approximate size parameters of the cutting tools, the distance of the simulated z i is set to 10mm < z i < 60mm. The irradiance range accepted by the camera is also considered. An optimization function f = min|1 − μ| is constructed and solved iteratively by nonlinear optimization using the MATLAB Optimization Toolbox. The result shows that the uniformity is optimal when z i is 50mm, and μ = 1.34.
Through the above method, we have obtained the optimal LED spatial position and the irradiance distribution in the X-Z plane in MATLAB, and the result is shown in Fig. 5(c). As can be seen from the figure, a symmetrically partitioned illumination is implemented and the illumination is viewed with high contrast from the background as well as uniformity. On the basis of the above analysis, we designed an annular array of four LED substrates fixed on an adjustable circular base, the size of which is adjustable. In this example, the radius of the base is 50mm. On each substrate, there are three LEDs with different angles, 0 • , 45 • , and 60 • , respectively, and the distance between the LEDs is 10mm. Therefore, the control strategy of the LED array can be adjusted according to different measurement parameters to achieve optimal illumination.

Measurement system and the fabrication of the light source
In this paper, a machine vision measurement system is set up to verify the feasibility of the proposed optimal design method. As shown in Fig. 6, the measurement system based on machine vision is composed mainly of an ultra-compact CMOS camera from XIEMA (Germany) and a telecentric lens from OPT Company (China). The lens is attached to the camera via a C-mount adapter and the camera is fixed on a manual lift plat, allowing acquiring the confocal images sequentially. A self-tightening drill chuck is used as the fixture of the measured drill bits. To guarantee a stable measurement, the above devices are set on the optical table with lower vibration frequency and good vibration isolation.
Here we design and fabricate a LED light source with multiple incident directions. A 3-D-printed case is used as the light substrate and the LED with a half angle of 60 • is embedded in the light substrate with different flat angles which creates particularly high contrast for precise viewing. Height-adjustable illuminator substrates with multiple LEDs shine in selectable combinations and illumination angles. And a wide variety of illumination scenarios result from the combination of settings with a LED controller. Considering the CMOS response curve and the response of metal to different spectra, the wavelength of LED is set at 458nm in this paper. Figure 7 shows the spectrum test results of the LED by a spectrometer. The designed light source has high flexibility and versatility.

Result of imaging and measurements
To validate the effectiveness of the light system optimization, the feature images of the length of chisel edge b ϕ , the thickness of drill center d c , and the width of sawtooth c 1 were acquired under the measurement system as described previously. As shown in Fig. 8(a)∼(c), the optimal lighting conditions can intuitively provide images with less bias and reduced noise. And the feature images are presented with higher contrast so as to easier and more accurate extract boundaries. Further analysis was conducted on the segmentation and edge contour extraction. We first denoised the images by Gaussian filter, and the enhanced images were segmented by the global thresholding method. Next, the regions of interest (ROI) were selected based on the characteristic parameters. The rough edge position of the parameters to be measured is obtained by Canny edge detection. Then, the sub-pixel edge extraction algorithm based on the hypothesis of the local area effect is adopted. Finally, the smooth and complete sub-pixel edge to be measured is obtained as shown in Fig. 8 Furthermore, grayscale gradient and direction analyses of the extracted features were examined. The vertical gradient along the edge direction pixels and the gradient direction are calculated. The result of Fig. 9(a) shows that the edge gradient value extracted from the image acquired under the optimized scheme is larger than that extracted from the image acquired under the ring light source illumination (perpendicular to the edge direction), which proves that the edge is easier to extract, and the gradient value changes much less than that before optimization, which proves that the extracted edge is continuous and stable. And as shown in Fig. 9(b), the edge gradient direction of the optimized image features is consistent, while the edge gradient direction before optimization changes greatly and also proves the validity of boundary extraction after optimization.
Finally, the measurement experiments on two types of cutting tools were carried out to verify the effectiveness of the illumination system optimal method. Based on the calibration model of the telecentric lens, the external camera and lens parameters are solved with the DLT The obtained value is used as the initial value when lens distortion is considered in the next step, and the final calibration internal and external and distortion parameters are obtained by LM nonlinear optimization algorithm (average re-projection error is 0.02). Using the above parameters, we calculated the measurement results shown in Table 1. Compared with the measurement results of a confocal microscope, the measurement error of the optimized light source is less than 1%, and compared with the ring light source, the measurement accuracy is improved by 9.5% on average, which proves the effectiveness and robustness of our proposed light source lighting optimization scheme.

Conclusion
Aiming at the problem of geometry measurement for the cutting tools with complex structure, this paper proposed a method of illumination optimal design for the machine vision system. On the basis of analyzing the problems caused by the existing light sources in imaging, this paper established the LED radiation illuminance model and the reflection model of the cutting tools surface respectively. Then, the relationship between the LED parameters, spatial position, and the irradiance reflected by the cutting tools is obtained in the measurement plane. Furthermore, the optimal parameters of the LED array are solved through the constraints of high contrast and uniformity. In order to verify the effectiveness of the method, a light source based on optimized parameters is prepared and applied to the machine vision measurement system. By controlling the light source, clear and sharp images can be obtained, and the measurement experiments of two types of cutting tools are carried out. Compared with the traditional ring lighting scheme, the efficiency and robustness of features edge extraction of the images obtained by the proposed light source optimization method are better. The results show that the measurement error of the optimized light source is less than 1%, and compared with the ring light source, the measurement accuracy is improved by 9.5% on average. Therefore, the proposed method improves the accuracy and the efficiency of the geometry measurement and has a potential to optimize the illumination system of other complex cases in machine vision.

Conflict of interest
The authors declare no competing interests.

Consent for publication
All co-authors consent to the publication of this work.