Illumination modelling for reconstructing the machined surface topography

Illumination estimation is crucial for surface detection methods based on visual image reconstruction. The luminance of the machined surface topography with desertification fractal structure is difficult to accurately describe using existing illumination models, which depend on the macrosurface geometric features and reflection characteristics. Therefore, machined surface topography illumination model under coaxial light microscopic vision is proposed in this paper for the online detection of complex surfaces and special functional surface topography in the manufacturing field. Based on light scattering theory, the luminance of the surface topography is studied under the coaxial light microscopic vision; the influencing factors of luminance of surface topography are revealed and the illumination model of machined surface topography is established. The experimental results show that less calculation error occurs when using the proposed illumination model, which can be used to more accurately describe the luminance of machined surface topography. The research results will lay a foundation for online detection and monitoring of machined surfaces.


Introduction
Machined surface topography determines the wear resistance, corrosion resistance, contact stiffness, fatigue resistance and part surface sealing and has an important impact on the matching properties, static and dynamic characteristics, service life and reliability of mechanical equipment [1,2]. Therefore, the rapid and accurate measurement, evaluation and control of the machined surface topography is of great significance for intelligent manufacturing [3].
In the detection method based on visual image reconstruction, the image of the object surface is obtained by using relevant instruments, the three-dimensional topography of the surface is reconstructed according to image characteristics [4] and surface quality detection and evaluation are realized; the advantages of this method include its fast speed and good real-time performance [5,6]. The illumination model is the basis of 3D reconstruction based on visual images which can describe the relationship between the surface luminance and its geometric features. Therefore, the illumination model has attracted the attention of many researchers [7,8]. Torrance et al. proposed that the object surface slope had normal distribution characteristics and used the slope distribution function, geometric attenuation factor and Fresnel function to describe the surface luminance [9]. Cook et al. assumed that the object surface had Berkmann distribution characteristics and established the Cook-Torrance illumination model [10]. Hirayama proposed an accurate illumination model for objects coated with multilayer films to achieve calculations of light brightness on smooth surfaces and locally smooth rough surfaces [11]. Jager et al. proposed a detailed illumination model for bifacial photovoltaic modules by considering direct light and diffuse reflected light from the sky and treated the illumination of the ground in detail; the irradiance components can be calculated arbitrarily at many positions along the module [12]. Thus, the existing illumination models mostly depend on the reflection characteristics and geometric characteristics of the macrosurface. A machined surface is very flat on the macroscale, but its surface topography has the characteristics of periodic and random changes [13], resulting in complex reflection characteristics of the surface topography. Therefore, the existing illumination models are prone to the problems of large error and low efficiency when describing the reflected luminance of the surface topography.
Coaxial light microscopic vision is an optical microimaging technology that uses coaxial light illumination, which can overcome the fuzziness and distortion shortcomings of traditional microimages. Wang et al. proposed using the coaxial light microscopic vision method to measure the distance between the spot lattice to solve the difficulty of measuring the spot size in the process of laser processing silicon wafers and obtained high-precision measurement results [14]. Ikgeun et al. proposed measuring the geometric features of the molten pool using a coaxial light microscopic vision [15]. Liu et al. studied the machine vision-based condition monitoring and fault diagnosis of machine tools and proposed using the textural features of coaxial optical microscope images for fault diagnosis and evaluation [16]. Nammi studied the direction of the surface lamination mode of machined parts, quantified the surface roughness by using the coaxial light microscopic vision method and reduced the influence of the surface layer on machine vision parameters [17]. It can be seen that the application field of coaxial light microscopic vision technology is gradually increasing [18].
For the aforementioned problems of the illumination model, coaxial light microscopic vision-based machined surface topography illumination model is proposed in this paper. Based on light scattering theory, the illumination characteristics of surface topography under coaxial light microscopic vision are studied, and an illumination model suitable for machined surface topography is established. The research results of this paper will lay a foundation for the online detection and monitoring of machined surfaces. Figure 1 shows the luminous flux transmission principle. A i is the light-emitting surface, and A j is the object surface. dA i and dA j are the light-emitting surface topography and object surface topography, respectively, and N i and N j are the normal directions of the surface topography dA i and dA j , respectively. θ i and θ j are the included angles between N i and N j and the central line of the two surface topographies, respectively. I i is the luminance of the surface topography dA i to the surface topography dA j . dω i and dω j are the solid angles of the twoface elements. Then, the luminous flux dF i transmitted from dA i to dA j can be expressed as

Related theory
The luminous intensity J is the luminous flux of the solid angle dω for the surface topography dA j in the observation direction V. θ r is the included angle between the normal direction of the surface topography and the observation direction; then, the luminance of the surface topography dA j in the observation direction is The probability density of luminous flux projected by the surface topography in the observation direction is defined as the reflection distribution function f r . k is the transfer coefficient, where 0 ≤ k ≤ 1. Then, the luminous flux in the solid angle dω of the observation direction is given by The corresponding luminous intensity J is Therefore, Eq. (2) can be expressed as Applying the definitions from Eq. (1) to Eq. (5) yields  The calculation process of luminance is complex and prone to problems including large errors and low efficiency, which are due to the influence of factors such as the incident direction and observation direction.

Surface topography luminance under coaxial light microscopic vision
Coaxial light microscopic vision is an optical microimaging technology using coaxial light illumination. The light source is far from the surface topography, and the incident light direction and observation direction are parallel to the optical axis of the imaging system. Figure 2 shows the geometric relationship between the incident light and the surface topography under coaxial light microscopic vision. The incident light vertically illuminates the macrosurface. N is the normal direction of the macrosurface; n is the normal direction of the surface topography dA; θ i is the angle between the normal direction of the surface topography dA and the direction of the incident light; V is the observation direction; θ r is the included angle between the normal direction and the observation direction of the surface topography dA; and I i is the effective luminance of the light source on the surface topography dA.
The incident light direction is parallel to the observation direction. We find that the relationship between the incident angle θ i and the observation angle θ r is Moreover, there is a large distance between the light source and the surface topography. Therefore, the solid angle dω i of the incident light can be approximated as a constant. Then, Eq. (6) can be expressed as: where C is a constant.
Using K = C × k, we find The luminance of the surface topography in the observation direction under the coaxial light microscope vision is only related to the incident luminance and reflection distribution function, which greatly simplifies the solution process of the luminance.

Modelling of machined surface topography luminance
Based on light scattering theory, the light beam irradiates the machined surface, and part of the light energy will be reflected by the surface topography, causing specular reflection. Another part of the light energy will be transmitted to the shallow medium of the machined surface, selectively absorbed by the shallow medium or scattered by the shallow medium into the upper air medium, resulting in diffuse reflection and volume scattering, as shown in Fig. 3. Compared with the geometric characteristics of the machined macrosurface, the surface topography is nonsmooth and discontinuous, exhibiting characteristics of periodicity and randomness. In addition, in the visible and near-infrared regions, except for the super smooth machined surface, the height root mean square of most machined surfaces is greater than the incident wavelength. Therefore, it can be considered that the machined surface topography has specular reflection, diffuse reflection and volume scattering characteristics. f s represents the specular reflection component; f d represents the diffuse reflection component; and f v represents the volume scattering component. Then, the scattering function f r of the machined surface topography can be expressed as: where k s , k d and k v are the coefficients of the three components.

Specular reflection
Based on surface topography theory [19], the surface geometric feature D, geometric attenuation factor G and Fresnel reflection coefficient F are the main factors affecting the specular ref lection component. The expression of the specular reflection f s can be given by where i denotes the incident direction.
The normal declination angle refers to the angle between the normal direction of the microsurface and the normal direction of the macrosurface. The smaller the normal declination angle is, the smaller the deviation of the microsurface normal direction from the macrosurface normal direction, and the smoother the corresponding geometric shape, as shown in Fig. 4. θ is the normal declination angle. Hence, the normal declination angle can reflect the geometric characteristics of the corresponding surface topography.
Our previous research results show that the machined surface topography has a lognormal distribution with respect to its geometric features [20], which can be expressed as where a and b are undetermined parameters. The a denotes the kurtosis of the normal declination angle distribution, which is related to the surface texture and roughness. The b denotes the skewness of the normal declination angle distribution, which is related to the processing technology.
The geometric attenuation factor is used to describe the attenuation of luminous flux caused by the occlusion of one surface topography from another surface topography, which depends on the surface topography normal distribution function and surface topography details. According to the projections in surface topography theory, the sum of the projected areas of the visible surface topography is equal to the projected area of the macrosurface, that is: Assuming that the Smith function can be used to describe the shadowing effect of the machined surface topography, according to the characteristics of the coaxial light microscopic vision, Eq. (13) can be expressed as: The Fresnel reflection coefficient can be used to describe the proportion of the reflected light to the incident light when the light passes through the machined surface topography. Usually, the Fresnel reflection coefficient is obtained by using the Fresnel equation, but the refractive index of the corresponding wavelength must be measured in advance, and the calculation process is complex. For convenience, the Fresnel reflection coefficient can be expressed by a power exponent function, namely: where m and n are undetermined parameters, which are related to the refractive index of the machined surface.

Diffuse reflection
Considering the reversibility of light, the diffuse reflection of the machined surface topography is related not only to the incident angle but also to the reflection angle. The Minnaert model can be used to accurately describe the variation of the diffuse reflection component with angle and meet the reciprocity. Therefore, the Minnaert model is used to describe the diffuse reflection component of the machined surface topography, namely: where d is the undetermined parameter, and the value range is (0,1).

Volume scattering
Based on the geometric characteristics of the machined surface topography, the scattered light will be reflected many times between adjacent surface topographies. The smaller the normal declination angle of the surface topography is, the smaller the reflection time and the larger the volume scattering value. The larger the normal declination angle of the surface topography is, the greater the number of reflections and the smaller the volume scattering value. Therefore, it is assumed that the volume scattering of the machined surface topography is related to the normal declination angle and follows the normal distribution: Therefore, under the coaxial light microscope vision, the luminance of the machined surface topography at a single wavelength can be expressed as: where the first term is the specular reflection model for the machined surface topography, the second term is the diffuse reflection model, and the third term is the volume scattering model.
In addition, according to the reflectivity equation: It can be seen that when and only when k s + k d + k v ≤ 1, the luminance of the machined surface topography meets the condition of energy conservation. Figure 5 shows the measurement platform of the machined surface topography, mainly including the Leica DCM 3D microscope, active damping platform, industrial computer and power regulator. The Leica DCM 3D microscope combines coaxial optical microscopy with white light

Measurement of machined surface topography
Industrial computer interferometry and can be used to obtain the image and topography data of the machined surface topography at the same time. The surface roughness comparison sample produced by the Harbin Measuring Tool Factory is used as the measurement object to measure the surface topography of turning, boring and plain milling samples, as shown in Fig. 6. The Leica DCM 3D microscope with a 10 × magnification lens is used to obtain the sample surface topography. At the same time, a blue light source with a wavelength of 460 nm is used. The measurement area is 1.27 mm × 0.95 mm; the image is 1212 pixels × 909 pixels; the sampling number is 768 points × 576 points; and the size of the sampling points is 1.66 µm × 1.66 µm.
The measurement results of the sample surface topography are shown in Fig. 7.

Preprocessing of surface topography image
The sampling point of the sample surface topography is 768 × 576, and the pixel of the corresponding image is 1212 × 909, which is difficult to use for follow-up research. Moreover, there are many black spots and shadows in the  image, which seriously affect the quality of the image. Therefore, the image interpolation and image filtering methods are used to preprocess the machined surface topography image, and the results are shown in Fig. 8.

Preprocessing of surface topography
Using the normal declination angle to study the illumination model of the machined surface topography, it is necessary to process the height data of sample surface topography into normal declination angle data. N (p, q, − 1) is the normal vector of the macrosurface, n (z x , z y , − 1) is the normal vector of the surface topography, and (p 0 , q 0 , − 1) is the normal vector of incident light. Then, the expression of the normal declination angle is given by where z x and z y are the height gradients of the surface topography in the x and y directions, respectively.
Since the illumination angle and reflection angle are very small under coaxial light irradiation, it can be considered that the normal vector of incident light is (0,0, − 1), which is parallel to the normal direction of the macrosurface. Then, the normal declination angle is: The height data of the sample surface topography are processed into normal declination angle data by Eq. (23), and the results are shown in Fig. 9.

Parameters of the illumination model
The genetic algorithm (GA) is a global search learning method based on natural selection and natural genetic mechanisms in the biological world and the global optimal solution in the process of evaluating multiple solutions. It has the characteristics of strong robustness and is a simple algorithm [21]. Therefore, the genetic algorithm is used to determine the parameters of the illumination model.
According to the normal declination angle data of the sample surface topography, the minimum mean square error between the calculation results of the illumination model and the grey of the measured image are taken as the objective function.   where I model is the calculation results of the illumination model; I measured is the grey of the measured image; and g(θ) is a weight function.
Suppose that the object function is less than 0.01, and I i of the illumination model is set as the incident luminance of the obtained original image. The parameters of the illumination model can be confirmed with GA, as shown in Table 1.

Experiment and analysis
To evaluate the feasibility and accuracy of the proposed illumination model, it is used for image synthesis of the machined surface topography and compared with common illumination models, such as the Lambert model, Phong model, Torrance-Sparrow model and Cook-Torrance model.
According to the characteristics of the coaxial light microscopic vision, the common illumination models are simplified by taking the normal declination angle as the variable. The results are shown in Table 2.
The parameters of common illumination models are determined by using the above GA algorithm. The results are shown in Table 3.  Figures 13,14, and 15 are grey histogram of surface topography image of turning, boring and plain milling samples, respectively. The greyscale of the composite image of the Lambert illumination model is mainly concentrated in the area with a large greyscale and has a narrow distribution range. The grey histogram curve of the composite image of the Phong and Torrance-Sparrow illumination models is high on both sides and low in the middle. The greyscale is concentrated on both sides of the curve, which easily causes large amounts of light-dark contrast in the composite image. The grey histogram curve of the composite image of the Cook-Torrance illumination model presents a convex feature, that is, the greyscale is mainly concentrated in the middle of the histogram curve, and the distribution at both ends is very small, which easily leads to a fuzzy image and unclear detail information. The grey histogram curve of the composite image of machined surface topography illumination model presents smooth characteristics, and the greyscale is evenly distributed. The grey histogram curve of the original image is smooth and full; the grey is evenly spread; and the grey details of the image are rich. Therefore, the analysis results show that the grey histogram of the composite image of machined surface topography illumination model is closer to that of the original image.

Mean square error analysis of the image
The mean square error (MSE) can be used to quantitatively evaluate the grey error between the composite image and the original image. Figure 16 shows compared with other illumination models, the grey mean square error is the smallest using this model. Therefore, the MSE analysis results show that the calculation accuracy of machined surface topography illumination model is higher.

Structural similarity analysis of the image
The structural similarity index (SSIM) can be used to quantitatively measure the similarity of two images from three aspects: greyscale, contrast and structure [22]. Figure 17 shows the calculation results of the structural similarity between the composite image and the original image of the surface topography of the turning, boring and plain milling samples. As seen from Fig. 17, the SSIM values of composite images of common illumination models are low, and the maximum is only 0.676. The SSIM values of the turning, boring and plain milling surface topography images synthesized by machined surface topography illumination model are higher, with values of 0.71, 0.802 and 0.783, respectively. Because the SSIM range is [0,1], the larger the SSIM is, the smaller the distortion of the composite image. Therefore, the SSIM analysis results show that the composite image of machined surface topography illumination model is more similar to the original image, and the image distortion is less.

Peak signal-to-noise ratio analysis of the image
The peak signal-to-noise ratio (PSNR) is a method that can be used to evaluate the quality of a composite image of the machined surface topography and can be defined by the mean square deviation [23], that is: where MAX I is the maximum value of the greyscale of the image. The higher the PSNR is, the better the composite image quality. Figure 18 shows the calculation results of the PSNR between the composite image and the original image of the surface topography of the turning, boring and plain milling samples. The PSNRs of the composite images of the Lambert and Cook-Torrance illumination models are lower than 20 dB, and the PSNRs of the composite images of the Phong and Torrance-Sparrow illumination models are between [20,30]

Conclusion
An accurate illumination model is very important for the online detection of machined surfaces based on visual image reconstruction. In this paper, a coaxial light microscopic vision-based illumination model of surface topography is proposed. According to the characteristics of coaxial light vision and the geometric characteristics of surface topography, the illumination model for machined surface topography is established. The surface topography data are obtained, and the illumination model parameters are determined by a genetic algorithm, which is used for the synthesis of surface topography images. The synthetic experimental results show that the composite image of machined surface topography illumination model is close to the original image in terms of the grey histogram, MSE, SSIM and PSNR. The proposed illumination model can more accurately describe the luminance of the machined surface topography and has higher calculation accuracy. The proposed illumination model can serve as an effective and novel way to describe the luminance of the machined surface topography, especially the surface topography with a rough fractal structure. It can be utilized in the reconstruction of machined surfaces and the prediction of  functional behaviours, such as contact, wear or friction, of engineering assemblies manufactured by machining. However, due to the limitation of our research conditions, the proposed method was not applied to non-metallic material surfaces, such as plastic. In the future, we will study the different material surface topography to further optimize our illumination model to improve its accuracy.

Declarations
Ethics approval The authors declare that this manuscript was not submitted to more than one journal for simultaneous consideration. The submitted work is original and has not been published elsewhere in any form or language.
Consent to participate All the authors consented to participate in this research and contribute to the research.

Consent for publication
All the authors consented to publish the research. There are no potential copyright/plagiarism issues involved in this research.

Conflict of interest
The authors declare no competing interests.