# Digital image processing algorithm for industrial on-site roughness evaluation in Ti-alloy machining

Sílvia Daniela Ribeiro Carvalho, Anna Carla Araujo, Ana Horovitz, Davim

João Paulo

► To cite this version:

Sílvia Daniela Ribeiro Carvalho, Anna Carla Araujo, Ana Horovitz, Davim João Paulo. Digital image processing algorithm for industrial on-site roughness evaluation in Ti-alloy machining. ESAFORM 2024, institut clement ader (ICA); LGP, Apr 2024, Toulouse, France. pp.1982-1989, 10.21741/9781644903131-219. hal-05030506

HAL Id: hal-05030506

https://hal.science/hal-05030506v1

Submitted on 11 Apr 2025

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# Digital image processing algorithm for industrial on-site roughness evaluation in Ti-alloy machining

RIBEIRO CARVALHO Sílvia Daniela<fnref n="1" />,<fnref n="2" />,a*, ARAUJO Anna Carla<fnref n="2" />,b, HOROVISTIZ Ana<fnref n="1" />,c and DAVIM João Paulo<fnref n="1" />,d

**Keywords:** Machining, Surface quality, Texture, Digital Image Processing, Ti6Al4V

**Abstract.** The surface texture is normally observed after the machining process, but nowadays it is important to use on-site analysis to improve the process automatically via smart processing. This study introduces a contactless roughness inspection method employing digital image processing on Ti6Al4V samples in turning using three different feed. Texture analysis with grey-level co-occurrence matrix (GLCM) extracted features that were correlated with the arithmetic average roughness (Ra), leading to the establishment of predictive models. The study encompassed diverse image testing, incorporating variations in resolution and brightness distributions. It was found that the pixel pair spacing (PPS) in GLCM analysis was influenced by the image resolution and feed rate. The predictive models developed with high-quality images, i.e., higher resolution and better brightness distribution, yielded similar results to those created using lower-quality images.

**Introduction**

Roughness assessment plays a crucial role in evaluating machined surface quality across industries. Traditional methods include mechanical or optical profilometers that estimate well-known amplitude parameters such as the arithmetic average roughness (Ra). While effective, these offline inspection methods prove disadvantageous for on-site analysis. In contrast, employing a computer vision system to capture and process images in real-time enables the integration of decision-making frameworks for Industry 4.0 [1].

In this context, the grey level co-occurrence matrix (GLCM) allows the extraction of texture descriptors from machined surface images, enabling statistical or intelligent modelling for predicting the tool wear [2,3], machining process (e.g., turned, milled, blasted, sanded) [4,5] and surface roughness [6,7]. These descriptors are statistical measures that give insights into the patterns of the machined surfaces. Common descriptors include contrast, energy, homogeneity, and correlation. They are computed from the GLCM, which captures how often different combinations of pixel intensity values occur within the image at a defined spatial relationship (spacing and angle). Indeed, many studies emphasize the strong correlation between the GLCM features and the cutting parameters [8], the surface roughness [9,10] and the generated vibration [11]. However, a substantial gap exists in proposing explicit modelling strategies, for predicting the machining outcomes.

Besides, a challenge in GLCM analysis lies in selecting the pixel pair spacing (PPS) and orientation (PPD), given their large impact on the occurrences within the matrix. This influences the ability to identify and relate textural patterns of the images to machining mechanisms, including roughness. Indeed, many authors [12–14] selected the PPS and PPD by visualizing the GLCM for several spacings and orientations, where optimal values had more occurrences in the principal diagonal of the matrix. Others, such as Dutta *et al.* [2] used power spectral density plots

<figure><img src="image_2.png" /></figure>

<footnote n="1">¹University of Aveiro, Department of Mechanical Engineering, Centre for Mechanical Engineering and Automation (TEMA), Campus Santiago, 3810-193 Aveiro, Portugal</footnote>

<footnote n="2">²Institute Clément Ader (ICA), CNRS UMR 5312, Toulouse, France</footnote>

<footnote>asdrc@ua.pt, baraujo@insa-toulouse.fr, chorovistiz@ua.pt, dpdavim@ua.pt</footnote>
of the GLCM features (contrast and homogeneity) to find the optimal spacing, i.e. maximum frequency peak. Moreover, they found that the GLCM features (contrast and homogeneity) exhibited periodicity concerning spacing. Consequently, the methods traditionally employed to determine the PPS in turned surfaces rely on the calculation of the GLCM for multiple spacings, significantly increasing computational time, which is an obstacle to real-time monitoring.

In his study, a contactless roughness inspection method is proposed, based on texture analysis with GLCM for Ti6Al4V with a novel strategy for selecting PPS, based on the feed and image resolution, which are promptly accessible.

## Materials and Methods

The experimental methodology for applying the surface analysis to the turning specimen is described in Fig 1 : (1) machining Ti6Al4V bar; (2) image acquisition ; (3-5) Image processing; (6) feature extraction with GLCM analysis; and (7) establishment of the roughness-contrast model.

The machining was developed in Huron DX 200 turning centre in flood cooling with a CNMG 120408 MF1 TS2000 insert. The parameters used were: constant cutting speed (Vc=60 m/min), axial depth-of-cut (adoc) of 1 mm and three levels of feed (f): 0.15, 0.2 and 0.25 mm/rev to create different profile patterns. The cutting length is fixed for each test: 35 mm.

<figure><img src="image_3.png" /><figcaption>Fig. 1. Experimental methodology, including, turning tests (1), image acquisition (2) and processing (3-5), feature extraction with GLCM analysis (6) and modelling (7).</figcaption></figure>
The image acquisition was done through two approaches: an off-site procedure using a 3D measurement to guarantee the profile precision and a potential on-site procedure using a portable optical microscope (OM) to forecast an industrial application.

An Alicona Infinite Focus measurement (IFM) is used for the 3D profile that captured 2040 X 2040 RGB images with a spatial resolution of 1000 pixels/mm. Also, it assessed the arithmetic average roughness ($R_a$) with a cut-off length of 0.8 mm and a tracing length of 4 mm. For each feed, twelve images and roughness values were measured at the start, middle and end of the cutting length. Within each zone, four measurements with a 90-degree spacing were taken.

A histogram matching technique, implemented in MATLAB R2019a, was used to uniformize the brightness distribution for each dataset (Fig. 1e-f). Then, the images were converted to grayscale (Fig. 1g-h). Afterwards, a contrast-limited adaptive histogram equalization (CLAHE) was employed (Fig. 1i-j), as advised by several authors [14,15]. This step was particularly important for the OM images, to improve the brightness distribution since there were regions with varying illumination conditions.

After the pre-processing steps, the grey-level co-occurrence matrix was calculated with the MATLAB function *graycomatrix*. Three inputs were considered for calculating the GLCM. The first (Img) was the pre-processed grey-level image. The second was the number of grey levels ('Numlevels') for discretizing the pre-processed image, that is for spreading the range of pixels (0-255) into 64 levels, to decrease the computation time, as suggested by Datta *et al.* [13]. The third ('offset') specifies the relative position, in terms of spacing and angle of the pixel pairs. For this work, as shown in Fig. 1k, the direction perpendicular to the feed marks was considered, as recommended in [3,14]. The spacing (PPS) was determined with the feed and image resolution, as presented in the results and discussion section. Fig. 1. 1-m illustrates how the GLCM matrix is calculated when a grey-level image (Img) is discretized in 8 levels, for a horizontal direction and a spacing of one pixel. GLCM (Fig. 1m) shows how often each pixel combination appears. For instance, a pixel with intensity 5, with a neighbour 7 in the horizontal direction appears 2 times in the scaled image (Fig. 1l). Using the equations from Table 1, the GLCM features were extracted. Finally, the correlation between the GLCM features and $R_a$ was estimated, and the models were created.
<table><caption>Table 1. Name, description, and equations of the texture features extracted from GLCM.</caption><thead><tr><th></th><th>Name & description</th><th>Equation</th></tr></thead><tbody><tr><td rowspan="3">Features of Contrast</td><td>Contrast (CON): measures local variations in intensity levels between neighbouring pixels.</td><td>Σ<sub>i,j=1</sub><sup>N</sup> P<sub>i,j</sub> (i - j)<sup>2</sup></td></tr><tr><td>Homogeneity (HOM): shows how closeness between the elements of the GLCM and its diagonal. It reflects the homogeneity of the texture.</td><td>Σ<sub>i,j=1</sub><sup>N</sup> (P<sub>i,j</sub> / (1 + (i - j)<sup>2</sup>))</td></tr><tr><td>Dissimilarity (DIS): is the average difference in intensity of pairs of pixels. Highlights non-uniformities.</td><td>Σ<sub>i,j=1</sub><sup>N</sup> P<sub>i,j</sub> |i - j|</td></tr><tr><td rowspan="3">Features of Orderliness</td><td>Angular second moment (ASM)</td><td>Σ<sub>i,j=1</sub><sup>N</sup> P<sub>i,j</sub><sup>2</sup></td></tr><tr><td>Energy</td><td>√ASM</td></tr><tr><td>Maximum probability (MaxGLCM): the maximum probability of occurrence of a specific pixel pair in the GLCM.</td><td></td></tr><tr><td></td><td>Entropy: measures randomness or uncertainty.</td><td>Σ<sub>i,j=1</sub><sup>N</sup> -P<sub>i,j</sub> · ln(P<sub>i,j</sub>)</td></tr><tr><td>Statistics</td><td>GLCM correlation (GLCMCor): shows how the pixel intensities are related spatially.</td><td>Σ<sub>i,j=1</sub><sup>N</sup> P<sub>i,j</sub> <div style="display: inline-block; vertical-align: middle; text-align: center;"><div style="border-bottom: 1px solid black; padding: 0 5px;">(i - u<sub>i</sub>)(j - u<sub>j</sub>)</div><div style="padding: 0 5px;">√σ<sub>i</sub><sup>2</sup>σ<sub>j</sub><sup>2</sup></div></div></td></tr></tbody><tfoot><tr><td colspan="3">P<sub>i,j</sub>: is the normalized GLCM; i, j: element row and column; N: number of GLCM elements; μ<sub>i</sub> and μ<sub>j</sub>: mean of every row and column; σ<sub>i</sub> and σ<sub>j</sub>: standard deviation of every row and column.</td></tr></tfoot></table>

## Results and Discussion

In this section, it is presented the results of the energy features, the values of correlation coefficients and the models achieved by the methodology proposed.

Fig. 2 presents the results of the energy feature exhibiting periodic variation across the PPS for all the feeds in both datasets (IFM and OM). Notably, an increase in the feed corresponded to an observed increase in the period, i.e., 150, 200 and 250 pixels for the IFM images (Fig. 2a-c), and 23, 30 38 pixels for the OM images (Fig. 2d-f). This trend was observed by Dutta *et al.* [2], who identified an optimal PPS of 10 and 16 pixels for f of 0.2 and 0.28 mm/rev, respectively.
<figure><img src="image_4.png" /><figcaption>Fig. 2. Periodic variation of the GLCM feature (energy – PPS) for both datasets, i.e. IFM and OM</figcaption></figure>

Furthermore, the results revealed that the PPS changed with the image resolution, which was 1000 and 150 pixels/mm for the IFM and OM images, respectively. This finding corroborates a statement from Gadelmawla [8], suggesting that the PPS depends on the resolution of the texture.

Moreover, it was found that the period observed in the plots of the energy along the spacing (black arrows in Fig. 2) could be estimated by multiplying the image resolution by the feed, as shown in Table 2. This promoted a reduction of the computational time when running the algorithm, as in previous articles [2,12–14], the GLCM is calculated for several spacings to find the optimal value (maximum peak). The optimal PPS values from Table 2 were also found for all the other GLCM features listed in Table 1.

<table><caption>Table 2. PPS estimation based on feed and image resolution.</caption><thead><tr><th rowspan="2">f [mm/rev]</th><th colspan="2">IFM</th><th colspan="2">OM</th></tr><tr><th>Resolution [pixel/mm]</th><th>PPS</th><th>Resolution [pixel/mm]</th><th>PPS</th></tr></thead><tbody><tr><td>0.15</td><td rowspan="3">1000</td><td>150</td><td rowspan="3">150</td><td>23</td></tr><tr><td>0.20</td><td>200</td><td>30</td></tr><tr><td>0.25</td><td>250</td><td>38</td></tr></tbody></table>

Table 3 displays the Spearman correlation coefficient between $R_a$ and the GLCM features for both datasets across various feed levels. While this coefficient does not provide information about the rate or magnitude of change, it provides insight into the direction and strength of the relationship between these variables.
<table><caption>Table 3. Correlation between $R_a$ and the GLCM features for both datasets and feed levels.</caption><thead><tr><th rowspan="2"></th><th>Group (feed)</th><th colspan="3">Contrast</th><th colspan="4">Orderliness</th><th>Statistics</th></tr><tr><th>f (mm/rev)</th><th>CON</th><th>DIS</th><th>HOM</th><th>ASM</th><th>Energy</th><th>MaxGLCM</th><th>Entropy</th><th>GLCMCor</th></tr></thead><tbody><tr><td rowspan="3">IFM</td><td>0.15</td><td>0.88</td><td>0.87</td><td>-0.87</td><td>-0.87</td><td>-0.87</td><td>-0.86</td><td>0.88</td><td>-0.88</td></tr><tr><td>0.20</td><td>0.83</td><td>0.87</td><td>-0.80</td><td>-0.86</td><td>-0.86</td><td>-0.55</td><td>0.89</td><td>-0.79</td></tr><tr><td>0.25</td><td>0.61</td><td>0.59</td><td>-0.61</td><td>-0.61</td><td>-0.61</td><td>-0.67</td><td>0.61</td><td>-0.61</td></tr><tr><td rowspan="3">OM</td><td>0.15</td><td>0.72</td><td>0.70</td><td>-0.70</td><td>-0.79</td><td>-0.79</td><td>-0.62</td><td>0.81</td><td>-0.73</td></tr><tr><td>0.20</td><td>0.63</td><td>0.63</td><td>-0.66</td><td>-0.73</td><td>-0.73</td><td>-0.74</td><td>0.64</td><td>-0.63</td></tr><tr><td>0.25</td><td>0.63</td><td>0.61</td><td>-0.64</td><td>-0.52</td><td>-0.52</td><td>-0.41</td><td>0.62</td><td>-0.64</td></tr></tbody></table>

A positive correlation was observed for contrast (CON), dissimilarity (DIS), and entropy, indicating that an increase in these features corresponds to an increase in $R_a$, considering a linear model. In rougher surfaces, higher differences in pixel intensity between the grooves and the ridges are observed, which leads to an increase in the contrast and dissimilarity. On the other hand, rougher surfaces tend to be more heterogeneous, resulting in higher entropy, due to variations in the distribution of pixel intensity.

A negative correlation was found for the other GLCM features, such as homogeneity (HOM), angular second moment (ASM), energy and maximum probability (MaxGLCM). An increase in these features corresponded to a decrease in $R_a$. Smoother surfaces tend to be more homogeneous in texture, resulting in less deviation between the diagonal and the elements of the GLCM, thereby increasing the overall homogeneity. Moreover, smoother surfaces exhibit a more ordered distribution of pixel intensities, leading to higher energy (and ASM). Additionally, smoother surfaces promote the dominance of particular pixel pairs, consequently increasing the maximum probability (MaxGLCM).

Compared to the dataset created with the optical microscope, the correlation coefficients tended to be higher for the IFM dataset. This difference could be attributed to the higher resolution and better brightness distribution of the IFM images. These properties likely enabled a better differentiation of the textural elements within the images due to more detail and a wider range of pixel intensities.

Although all the GLCM features present a higher correlation with $R_a$ (Table 3), the regression models using contrast (CON) and dissimilarity (DIS) exhibited higher R-squared, as shown in Fig. 3. Therefore, they were more effective in predicting $R_a$ than other GLCM features. Previously, Datta et. al [13] had identified contrast as one of the better parameters to study texture in turned surfaces as it effectively highlights the difference between the lighter ridges and darker grooves. These findings show that a strong correlation between the GLCM feature, and $R_a$ does not always translate into the development of satisfactory models.

The disparities between the actual and predicted $R_a$ values for CON and DIS are illustrated in Fig. 3. Overall, the residuals exhibit a heterogeneous distribution around zero, although certain points display greater deviations. Currently, the mean value of five profiles was used to assess the image roughness. However, incorporating more profiles, more spaced along the field, could provide a deeper understanding of roughness variability and possibly increase the prediction accuracy, as the GLCM analysis considers the full field of the image

Besides, in Fig. 3 it is possible to understand that three different models were created, one for each feed. This may pose limitations in terms of flexibility for digital manufacturing. To address this, Dutta et. al [2] have normalized both the dependent ($R_a$) and independent variables (contrast and homogeneity), aggregating data from multiple feeds into a single model. However, this method considers different normalization factors for each dataset, which need to be considered when making predictions. Therefore, after all, it is required to understand in which feed the images were
attained. In this study, the relationship between the PPS, the feed, and the image resolution was established. As a result, if the feed rate is unknown, it can be estimated using the PPS (estimated from the peaks from Fig. 2) and the image resolution.

<figure><img src="image_5.png" /><figcaption>Fig. 3. Relationship between GLCM features (contrast and dissimilarity) and R<sub>a</sub> with regression models for both image datasets and feed. Disparities between the actual and predicted R<sub>a</sub>.</figcaption></figure>

## Conclusions

A contactless method for the roughness inspection of machined Ti6Al4V surfaces has been proposed, based on texture analysis with GLCM analysis. The algorithm was applied to images submitted to turning with images acquired by two methods (off-site and in-site). It was found that:

* The determination of the appropriate pixel pair spacing (PPS) in the GLCM analysis of turned surfaces depends on the machining conditions (feed) and the image resolution. This allowed the appropriate spacing to be quickly determined without the need to study the GLCM feature behaviour at multiple spacings, which is time-consuming.

* A high correlation between the GLCM feature and R<sub>a</sub> does not always translate into the development of satisfactory models. Therefore, correlation does not imply causation and does not guarantee the fit of a particular predictive model.

* Predictive models R<sub>a</sub> as a function of contrast and dissimilarity.

* The predictive models developed using high-quality images from the IFM, which had higher resolution and better brightness distribution, gave similar results to those developed using lower-quality images from the portable optical microscope.

* In future research, it is intended to apply intelligent modelling for establishing predictive models. To attain that, the database will be increased, and the feature extractor (GLCM) will be parameterized according to the guidelines established in this work.

## Acknowledgements

The authors acknowledge the Portuguese Foundation for Science and Technology (FCT) for the PhD grant SFRH/BD/07040/2021 and TiFast S.R.L., from Italy, for providing the Ti-alloy.
## References

[1] S. Jain, M. Pradhan, A. Kumar, Application of Digital Image Processing on Machined Surfaces: A review, in: R. Kumar Nayak, M. Pradhan, J.P. Davim (Eds.), Recent Adv. Mater. Manuf. Technol., Springer, 2023. https://doi.org/10.1007/978-981-99-2921-4

[2] S. Dutta, A. Datta, N. Das Chakladar, S.K. Pal, S. Mukhopadhyay, R. Sen, Detection of tool condition from the turned surface images using an accurate grey level co-occurrence technique, Precis. Eng. 36 (2012) 458-466. https://doi.org/10.1016/j.precisioneng.2012.02.004

[3] S. Dutta, S.K. Pal, R. Sen, On-machine tool prediction of flank wear from machined surface images using texture analyses and support vector regression, Precis. Eng. 43 (2016) 34-42. https://doi.org/10.1016/J.PRECISIONENG.2015.06.007

[4] D.R. Patel, V. Vakharia, M.B. Kiran, Texture classification of machined surfaces using image processing and machine learning techniques, FME Trans. 47 (2019) 865-872. https://doi.org/10.5937/fmet1904865P

[5] G. Prasad, V.S. Gaddale, R.C. Kamath, V.J. Shekaranaik, S.P. Pai, A Study of Dimensionality Reduction in GLCM Feature-Based Classification of Machined Surface Images, Arab. J. Sci. Eng. (2023). https://doi.org/10.1007/s13369-023-07854-1

[6] E.S. Gadelmawla, Estimation of surface roughness for turning operations using image texture features, Proc. Inst. Mech. Eng. Part B J. Eng. Manuf. 225 (2011) 1281-1292. https://doi.org/10.1177/2041297510393643

[7] E. Alegre, J. Barreiro, M. Castejón, S. Suarez, Computer vision and classification techniques on the surface finish control in machining processes, Lect. Notes Comput. Sci. (Including Subser. Lect. Notes Artif. Intell. Lect. Notes Bioinformatics). 5112 LNCS (2008) 1101-1110. https://doi.org/10.1007/978-3-540-69812-8_110

[8] E.S. Gadelmawla, A.E. Eladawi, O.B. Abouelatta, I.M. Elewa, Investigation of the cutting conditions in milling operations using image texture features, Proc. Inst. Mech. Eng. Part B J. Eng. Manuf. 222 (2008) 1395-1404. https://doi.org/10.1243/09544054JEM1173

[9] S. Nammi, S.L. Uppu, B. Ramamoorthy, Effect of orientation of workpiece and filter cut-offs in the surface roughness evaluation using machine vision, 11th IMEKO TC14 Symp. Laser Metrol. Precis. Meas. Insp. Ind. LMPMI 2014. (2014) 98-103.

[10] I. Svalina, S. Havrlišan, K. Šimunović, T. Šarić, Investigation of correlation between image features of machined surface and surface roughness, Teh. Vjesn. 27 (2020) 27-36. https://doi.org/10.17559/TV-20191212122953

[11] K. Khalili, M. Danesh, Identification of vibration level in metal cutting using undecimated wavelet transform and gray-level co-occurrence matrix texture features, Proc. Inst. Mech. Eng. Part B J. Eng. Manuf. 229 (2015) 205-213. https://doi.org/10.1177/0954405414526577

[12] E.S. Gadelmawla, A vision system for surface roughness characterization using the gray level co-occurrence matrix, 37 (2004) 577-588. https://doi.org/10.1016/j.ndteint.2004.03.004.

[13] A. Datta, S. Dutta, S.K. Pal, R. Sen, Texture Analysis of Turned Surface Images using Grey Level Co-occurrence Technique, (2012). https://doi.org/10.4028/www.scientific.net/AMR.365.38

[14] P.K. Ambadekar, C.M. Choudhari, Application of Gray Level Co-occurrence Matrix as a feature extraction technique to monitor wear of cutting tool, (2018) 21-29.

[15] S. Dutta, S.K. Pal, R. Sen, Tool Condition Monitoring in Turning by Applying Machine Vision, J. Manuf. Sci. Eng. 138 (2015) 051008. https://doi.org/10.1115/1.4031770