Keywords

1 Introduction

It is very much essential to machine the components as per the specified dimensional and form accuracy, as well as surface finish to satisfy the functional performance and aesthetic requirements of mechanical components of final products. It is a well-known fact that smoother surfaces exhibit higher wear resistance, higher corrosion resistance, and higher fatigue strength. These properties are very much needed in many engineering and medical applications as well. However, in certain applications like surface coatings, rougher surfaces are desirable to improve the adhesive properties.

Typically, different machining and surface finishing processes produce surfaces with different roughness values (Ra) in the range of 0.05 μm (superfinishing) to 25 μm (shaping) [1]. Two techniques, namely contact stylus profilometry and optical profilometry, are in practice to measure the roughness. Contact profilometers use diamond-tipped probes that physically move along the surface and surface irregularities are registered as amplified profiles of peaks and valleys. Whereas, the optical profilometers use light to measure the surface irregularities, and their operation is based on principles such as focus variation microscopy, confocal microscopy, and coherence scanning interferometry. Since several commercially available profilometers are desktop versions, machined components have to be taken to the measurement room to measure surface features.

With the advent of advanced and intelligent manufacturing practices, demand for in situ measurement of surface roughness is increasing rapidly. Because it provides real-time feedback to make suitable decisions to control the machining process or for online monitoring. In situ measurement refers to the measurements taken at the machine without disturbing the component’s position on the machine table, however, the machining process is stopped during the measurement. Commercially available profilometers are generally desktop type and not suitable for in situ measurement.

Quinsat and Tournier [2] proposed a method for in situ measurement of surface roughness of mechanical components using chromatic confocal sensors. The sensor was attached to the spindle of the 5-axis machining centre, and roughness values were evaluated for milling and polishing operations. Similarly, Fu et al. [3] proposed an experimental setup using a chromatic confocal sensor and developed a software programme to calculate the roughness values. A robotic arm was employed to align the chromatic confocal sensor to the workpiece with a standoff distance of 6.5 mm. It was observed that measurement error while comparing with a standard stylus-based profilometer (Talysurf PGI 800) was less than 50 nm [3].

In another optical method based on the laser scattering principle, researchers attempted to establish the relationship between the surface roughness Ra value and laser scattered density pattern [4]. For this purpose, lapped, diamond-turned, and ground surfaces with Ra values in the range of 0.005–6 µm were considered. About 3–9% error was observed with the correlation obtained from laser scattering principle compared with stylus instrument [4]. The non-contact optical methods require very expensive optical/laser sensors as well as complex alignment and control systems. In this point of view, image processing techniques are a viable option for evaluating the surface features. Further, vision-based methods are easy to install, suitable for in situ measurement and automation.

Jeyapoovan and Murugan [5] created the database of the images for milled surfaces along with measured surface roughness values (Ra). When the surface roughness has to be evaluated for a new specimen, its image is compared with images in the database for the difference in image intensity pattern considering Hamming distance and Euclidean distance as the metrics [5]. Similarly, Kumar et al. [6] applied an image processing method to evaluate the surface roughness of components produced by an incremental forming process. In this work, images of formed components, whose surface roughness is in the range of 0.6–3.6 µm, are stored in a database and compared with images of components of the components to be tested. Typically, a comparison of pixel intensity values has been done using Euclidean distance, Hamming distance, and Wavelet-based methods [6].

Chiou et al. [7] proposed a vision-based system to monitor the surface roughness of milled components remotely. In this study, 4-axis CNC milling machine was considered and surface roughness values for the different cutting conditions (spindle speed 1000–10,000 rpm, feed 0.84–6.35 mm/s) are correlated to mean intensity values of images. A good agreement between the surface roughness values and the mean intensity of images was observed and noted as a linear relationship [7].

In contrast to above, Lee and Tarng [8] evaluated the surface roughness of turned components by considering the arithmetic average of the grey-level intensity of the images Ga, extracted along a straight line. The correlation was built based on the polynomial model by considering Ga and machining parameters including cutting speed, feed rate, and depth-of-cut. It was observed that error in the measurement is in the range of 0.2–12% while comparing the Ga-based correlation to surface roughness measured by contact type profilometer (Ra) [8]. Similarly, Rajneesh Kumar et al. [9] also considered the grey-level intensity of the images (Ga) to relate to surface roughness value (Ra) for machined specimens obtained from the grinding, milling, and shaping processes. A linear regression model was developed to evaluate Ra value as a function of Ga and cutting parameters, i.e. speed, feed, and depth-of-cut.

Further, the effect of magnification of images on correlation was studied and noted that magnification of the images is ineffective in the case of milling and shaping. However, it was found to be effective for the grinding process. It was observed that the developed regression model has the maximum error of 2%, 6.44%, and 8.2% for grinding, milling, and shaping processes, respectively [9].

Alessandro et al. [10] applied the convolutional neural network (CNN) method to classify images that represent the roughness values in the range of 0.2–2.0 μm produced with the EDM machining process. A dataset of 4400 images was used to train the network and observed that the error of the prediction model is around 10%. Since it is a classification method, several hundreds of images corresponding to discrete values of surface roughness are needed, which is cumbersome [10]. Similarly, Achmad et al. [11] built CNN models for turning, slot milling, and side milling processes considering the datasets of images of 41,680 for slot milling, 45,200 for side milling and 73,600 for turning process. The accuracy of the prediction of the model is in the range of 81–91%.

In the present work, a novel method is followed to generate the dataset of grey-level intensity profiles from the images of machined surfaces, and then, a machine learning model is proposed as follows.

2 Machine Vision Setup and Experimental Data

To develop the prediction model for evaluating the surface roughness, aluminium plates of 100 × 100 × 6 mm are taken and machined using a CNC vertical milling machine. By varying the spindle speed (in the range of 275–1050 rpm), federate (in the range of 120–280 mm/min) and depth-of-cut (constant 0.5 mm), specimens with different roughness values (Ra) are obtained. Stylus instrument (TIME-TR1100) is used to measure the surface roughness and the measured roughness values (Ra) are shown in Table 1.

Table 1 Surface roughness values measured with a stylus instrument

Then, a machine vision setup is prepared, in-house, using a CCD camera (IDS USB 3.0, resolution of 2456 × 2054 pixels −5 MP), 25 mm focal length lens, co-axial light (100 × 100 mm size, make-VST) and a stand as shown in Fig. 1. The workpiece is placed on a flat surface and co-axial light is placed just above the workpiece to illuminate it. Lens is attached to the camera and positioned at a certain height from the co-axial light and adjusted the focus till the image is clear on IDS manager, an image capturing software. Figure 2a shows photographs of the specimens taken with a normal camera, and Fig. 2b, c, d shows images captured through IDS image capturing software for specimen numbers 1, 7, and 13, respectively.

Fig. 1
An image depicts a machine vision setup, in which the following parts are labeled. I D S camera manager, power supply, connection to P C, camera and lens, coaxial light, support, and workpiece.

Proposed machine vision setup

Fig. 2
4 images. a, depicts photos of specimens. b, depicts specimen 1 with R a equals 16.21 micrometers. c, depicts specimen 7 with R a equals 0.63 micrometers. d, depicts specimen 13 with R a equals 5.75 micrometers.

Photographs of the specimens and images captured using the proposed setup

The roughness profiles can be seen from the images and noted that peak and valley spots are dominant as the roughness values increase. Interpreting this intensity pattern and correlating it with roughness is a challenging task since it depends on the quality of the image, interpretation method, and efficiency of the model. In the present work, images are captured with a professional machine vision camera and capturing software. Further, from Fig. 2, it is clear that the quality of the images is good and clear. The next step is the extraction of the digitation data and relating it to roughness texture is an important task as follows.

3 Extraction and Analysis of Digital Data from Image

Digital information extracted from the images, i.e. grey-level values are analysed to understand the relation between the surface texture and corresponding grey-level values. This analysis is carried out using Python programming executed through Jupyter notebook. Python provides several built-in libraries needed for image processing, data science, machine learning, mathematical functions, and plotting.

Images captured through the proposed machine vision setup are stored in a local drive of the PC and processed through the Python programming language. At first, coloured images are converted into grey images and their grey-level values are extracted. Grey-level values for a specific window (6 rows and 10 columns) for the image (Fig. 2b) are shown in Table 2. It is well known that grey-level values are in the range of 0–255, and 0 represents black and 255 represents white. Variation in these grey-level values represents the texture of the image, particularly surface roughness in the present case. Since surface roughness is measured by the stylus instrument by moving the probe parallel to the edge on the surface, variation in grey-level values along a horizontal line is considered for this study.

Table 2 Grey-level value of the image (Fig. 2b) at the specified window

In this work, all the images are taken in the sizes of 450 × 649 except the last image (specimen no. 13) which is 542 × 1307 in size. To analyse the variation in grey-level values, intensity values along the scanned lines, as shown on the image (Fig. 2b), are considered. Variation in grey-level values along a horizontal scanned line at position (10, 10) with a length of 400 pixels for images (Fig. 2 b, c, d) is shown in Fig. 3.

Fig. 3
3 graphs depict intensity values along y axis with pixel number from 0 to 400; the 3 graphs depict the variation of grey level values for specimens 12, 6, and 0 respectively; each graph depicts the m I n, m a x, mean and G a values of the variations.

Variation of grey-level values along a straight line for specimens 1, 7, and 13 (index of specimens starts from 0)

From Fig. 3, it is observed that variation in the grey-level values looks similar to a typical roughness profile generated by stylus instruments. Hence, it is more appropriate to consider grey-level values along a straight line, while developing the correlation between the roughness values and grey-level pattern. In this work, the arithmetic average of the grey-level values (Ga) is calculated as given in the equation below.

$$G_{{\text{a}}} = \left( {\sum {\left( {\left| {y_{1} - y_{m} } \right| + \left| {y_{2} - y_{m} } \right| + \ldots + \left| {y_{n} - y_{m} } \right|} \right)} } \right.$$
(1)
$$y_{m} = \left( {y_{1} + y_{2} + \ldots + y_{n} } \right)/n$$
(2)

where

n:

Number of pixels

yi:

Grey-level intensity value for ith pixel

ym:

Mean of grey-level intensity values

It can be seen from Figs. 3 and 4 that Ga values have a linear relationship with surface roughness. As the roughness increases, Ga value also increases. In this work, a machine learning approach is proposed to find this relationship as discussed below.

Fig. 4
A graph depicts intensity from 100 to 260 with pixel number from 0 to 400. The graph depicts the variation in pixel intensity for specimens 0, 6, and 12. Variations are high for specimen 12, medium for specimen 6, and low for specimen 0.

Variation in pixel intensity patterns among the specimens 1, 7, and 13

4 Preparation of Dataset and Machine Learning Model

Machine learning (ML) is one of the important components in data science and the subset of artificial intelligence (AI). Machine learning algorithms generate the models through the training of the labelled or unlabelled data to predict or classify the data. In the present work, a prediction model is developed to predict the surface roughness of the specimen from the given image corresponding to a specimen. Since the images of the machined components are captured in a non-contact manner, this method is more suitable for in situ measurement which is a very important feature in advanced machining centres.

A large amount of data is needed for ML algorithms to attain the higher accuracy of the model. In this work, a novel approach is followed to generate a large dataset by scanning along the several horizontal lines on the images of machined surfaces (shown as dotted lines in Fig. 2). The purpose of the scanning process is to extract the grey-level values along a straight line across the workpiece. Then, the arithmetic average of the grey-level values (Ga) for each of the scanned lines is calculated as expressed in equation (1). Grey-level values for typical scanned lines and corresponding Ga values and measured Ra values are shown in the dataset of Table 3.

Table 3 Structure of the dataset for the prediction model

Each row in Table 3 corresponds to a scanned line considered on the image of the surface. In this case, 3 scanned lines are considered on each image and since there are 13 specimens, a total of 39 rows can be seen in Table 3. The last two columns show roughness values (Ra) and the arithmetic average of grey-level values (Ga), respectively. Elements in columns 0 to till the specimen number indicate the grey-level values of the scanned line. For example, (180, 175, 177, 180, 176, ...180, 175), (183, 177, 185,  193, 192, ...195, 195) and (203, 201, 202, 202, 202, ...190, 191) indicate the grey-level values for the 1st, 2nd, and 3rd scanned lines of length 400 pixels on specimen number 0. Size of the dataset and its values depend on the number of scanned lines, and its position and length. The dataset is programmatically generated and will be the input for the ML prediction model. Then, the model is trained with the ML linear regression algorithm. The major steps in the proposed algorithm are shown in Fig. 5.

Fig. 5
An algorithm depicts the steps as follows. For S equals 1 to number of specimens, read the image; convert S into grey image; split the data into training set and testing set; train and fit the model using M L regression model; validate the model; get the coefficients; predict the values.

Algorithm for the proposed model

With the proposed algorithm, as described in Fig. 5, it is found that there is good agreement between surface roughness and grey-level intensity patterns of images corresponding to the surfaces, as discussed below.

5 Results and Discussion

To develop the prediction model, labelled data of Ra and Ga is considered. In this case, 80% of data is used to train the model and the remaining 20% is used to the test model. Table 4 shows typical data consisting of original Ga and Ra values, and Ga and Ra values considered for training and testing.

Table 4 Data considered for training and testing the machine learning (ML) algorithm

Since Ga is linearly related to Ra, a simple linear regression technique is applied while training the ML model. The relation between the Ga and Ra is shown in Fig. 6, as the scattered plot along with the regression model evolved through the ML approach. From Fig. 6, it can be seen that Ra values are linearly related to Ga values. However, there is variation in Ga values of scanned lines for the same specimens.

Fig. 6
A scatter plot depicts surface roughness from 0 to 16 with an arithmetic average of the grey level values from 5 to 30. The graph depicts most of the plots lie on either side of the trend line from (3, 0) to (30, 16).

Prediction model with the proposed ML model

$$R_{{\text{a}}} = - 1.93 + 0.62 \times G_{{\text{a}}}$$
(3)

Correlation arrived through the ML model along with coefficients is shown in Eq. (3). The model is validated with test data. The predicted values for the test data are shown in Table 5. It can be noted that predicted values are closer to actual values and variation is in the range of 0.1–0.6 µm.

Table 5 Predicted surface roughness values with the proposed ML approach

6 Conclusions

The proposed machine learning approach shows a good agreement of surface roughness with the grey-level intensity pattern of the images corresponding to the machined surfaces. It is observed that three is only a slight error in the range of 0.1–0.6 µm for predicted and actual values. This is due to the certain variations in grey-level intensity patterns among the scanned lines for a given specimen. This variation occurs due to several factors including lay direction and certain black spots/patches on the image. There is a good scope for further study in this direction to build a more robust model. Further, a greater number of experiments and images may improve the performance of the model. Similarly, several uncertainty parameters in measurement, preparation of specimens, and capturing the images have an impact on the quality of the prediction model.

Applying the machine learning prediction model with the generation of a large set of data is the novelty of the present work. Even though there are certain correlations available in ligature, based on the arithmetic average of grey-level values with surface roughness, they are limited to a single scanned value per specimen and thus cannot guarantee the precision in prediction.

The proposed machine vision setup consists of a professional industrial camera, lens, and lighting system, found to be suitable for non-contact prediction of surface roughness. However, one can explore a different combination of image capturing systems.