A Vision System For Surface Roughness Characterization Using The Gray Level Co-Occurrence Matrix
A Vision System For Surface Roughness Characterization Using The Gray Level Co-Occurrence Matrix
www.elsevier.com/locate/ndteint
Abstract
Computer vision technology has maintained tremendous vitality in many fields. Several investigations have been performed to inspect
surface roughness based on computer vision technology. This work presents a new approach for surface roughness characterization using
computer vision and image processing techniques. A vision system has been introduced to capture images for surfaces to be characterized
and a software has been developed to analyze the captured images based on the gray level co-occurrence matrix (GLCM).
Three standard specimens and 10 machined samples with different roughness values have been characterized by the presented approach.
Three-dimensional plots of the GLCMs for various captured images have been introduced, compared and discussed. In addition, some
statistical parameters (maximum occurrence of the matrix, maximum occurrence position and standard deviation of the matrix) have been
calculated from the GLCMs and compared with the arithmetic average roughness Ra : Furthermore, a new parameter called maximum width
of the matrix is introduced to be used as an indicator for surface roughness.
q 2004 Elsevier Ltd. All rights reserved.
Keywords: Surface roughness; Computer vision; Image processing; Co-occurrence matrix
their extensions and their moments. These descriptors are for calculations: horizontal (0,180), vertical (90,270), and the
used to measure contrast, granularity and coarseness of the two diagonals (45,225 and 135,315). The only difference
image. Texture feature descriptors can be classified into two between symmetric and non-symmetric matrices is that
categories according to the order of the statistical function while the position operator Ps;d is passed over the image for
that is utilized: first-order texture features and second-order non-symmetric matrices, both the operators Ps;d and
texture features [19]. First-order texture features, also Ps;ð180þdÞ are simultaneously passed over the image for
known as grey level distribution moments (GLDM), are symmetric matrices. Fig. 1 shows the flowchart of the
extracted exclusively from the information provided by the algorithm used to calculate the GLCM.
intensity histograms, thus it yields no information about the Fig. 2 shows how to calculate the GLCM from a sample
locations of the pixels. The second-order texture features matrix using different position operators. Fig. 2a shows a
take into account the specific position of a pixel relative to matrix represents an image of size 7 £ 7 contains six gray
another. The most popularly used of second-order methods levels (0 – 5). Fig. 2b shows the calculated GLCM using a
is the grey level co-occurrence matrix (GLCM) method, position operator P1;0 ; which produces a non-symmetric
which depends on constructing matrices by counting the matrix. The black cells indicate the main diagonal of the
number of occurrences of pixel pairs of given intensities at a matrix. Fig. 2c shows the calculated GLCM using a position
given displacement. The GLCM is sometimes called spatial operator P1;ð180þ0Þ ; i.e. for the horizontal direction, which
grey level dependency matrix (SGLDM). The GLCM has produces a symmetric matrix.
been widely used for texture analysis in many applications
[20 –24].
In this work, 3D plots of the GLCM and some statistical 3. GLCM’s calculated parameters
parameters have been employed to characterize surface
roughness. In addition, a new parameter called maximum The developed software GLCMSurf calculates four
width of the matrix (MWM) is introduced to be used as an parameters from the GLCM: (1) maximum occurrence of
indicator for the surface roughness. the matrix (MOM), (2) maximum occurrence position
(MOP), (3) standard deviation of the matrix (SDM) and
(4) maximum width of the matrix (MWM). The MOM and
2. The gray level co-occurrence matrix MOP are calculated by searching the GLCM for the
maximum value and storing its position in the form of
ðx; yÞ: To calculate the SDM, the mean of the matrix is
The gray level co-occurrence matrix (GLCM) has been
calculated firstly using Eq. (1), then the SDM is calculated
defined by Haralick et al. [19]. The GLCM is a two-
by Eq. (2), where M is the GLCM and i; j are the gray level
dimensional matrix with the same size as the number of grey
values (0 –255).
levels in an image. For example, the images used in this paper
have 256 distinct grey levels; therefore the GLCM is a matrix X255 X255
i¼0 j¼0
M½i½j
of size 256 £ 256. It could be constructed by counting the Mean ¼ ð1Þ
number of occurrences of pixel pairs (base pixel and ð256Þ2
neighbor pixel), which have gray levels i; j and their position vffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
u X255 X255
specified by a position operator Ps;d in the image. The u ðM½i½j 2 MeanÞ2
t i¼0 j¼0
position operator Ps;d describes two parameters for the pixel SDM ¼ ð2Þ
ð256Þ2 2 1
pairs: pixel pairs spacing (PPS) and pixel pairs direction
(PPD). The GLCM could be calculated as symmetric or non- The MWM is a new parameter introduced to characterize
symmetric matrices. For non-symmetric matrices, eight PPD the surface roughness with different values of Ra : Fig. 3
could be used to calculate the matrices, which represent the shows the procedures of calculating the MWM. Fig. 3a
eight directions of the neighbors to the base pixel, as shown in shows a 2D plot of a sample GLCM. The MWM is
the lower left of Fig. 6. In this work, the direction 0 means that calculated by searching the GLCM twice, one is above the
the neighbor pixel lies to the right of the base pixel; similarly, matrix diagonal to calculate d1 and the other is below the
the direction 90 means that the neighbor pixel lies above the matrix diagonal to calculate d2 as shown in Fig. 3b. Each
base pixel, etc. Symmetric matrices have only four directions search begins from the matrix diagonal in a direction normal
E.S. Gadelmawla / NDT&E International 37 (2004) 577–588 579
Fig. 2. Calculation of the GLCM for a sample matrix represents a gray level image.
2. Opening the captured images by the GLCMSurf 3. Exporting the calculated GLCMs as ASCII files for
software for the purpose of characterization, then further use by the Matlab software.
calculating and recording the previously mentioned 4. Using a specially written Matlab program to import the
parameters. exported ASCII files and plot the equivalent 3D graphs.
Table 1
Specifications of the face turning specimens
Specimen no. 1 2 3 4 5 6 7 8 9 10
Feed (mm/rev.) 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50
Average Ra 2.14 2.35 2.40 2.52 2.61 2.74 2.99 3.27 3.68 3.94
582 E.S. Gadelmawla / NDT&E International 37 (2004) 577–588
6. Results and discussion On the other hand, calculating the GLCM in a direction
along the lay produces minimum MOM and maximum
To characterize the surface roughness using the GLCM,
MWM.
the effect of the position operator Ps;d has been studied
3. The GLCMs of the two diagonals are approximately the
firstly, then a suitable position operator was used to perform
same because the lay direction is vertical.
the characterization process.
6.1. Effect of the position operator 6.1.2. Effect of the pixel pairs spacing
To study the effect of the PPS, 10 GLCM symmetric
The position operator Ps;d can affect the GLCM through matrices have been calculated for the three standard specimens
the PPD and the PPS. The effect of these two parameters on in the horizontal direction (across the lay), then the GLCM
the GLCM was studied and the results are discussed next. parameters were recorded for each specimen. Fig. 8 shows 2D
plots of five selected GLCMs for the three standard specimens
6.1.1. Effect of the pixel pairs direction using PPS equal to 1, 5, 10, 15 and 20. It is clear that for rough
To study the effect of the PPD, five images for different surfaces, the GLCM much spread around its diagonal by
areas of the 2 min. specimen were captured, then the increasing the PPS until a certain level. In addition, increasing
introduced parameters were calculated using a symmetric the PPS moves the GLCM toward the lower left of the matrix
GLCM for each image in the four directions (horizontal, diagonal for rough surfaces than for smooth surfaces. This is
vertical and the two diagonals). The obtained results are because rough surfaces contain many dark pixels.
listed in Table 2 and the 3D plots of the GLCMs of one of Fig. 9 shows the relation between the PPS and the
the captured images are shown in Fig. 7. By referring to calculated parameters for the three specimens. It could be
Table 2 and Fig. 7, the following could be observed. seen that increasing the PPS decreases both the MOM and the
SDM with a good correlation (Fig. 9a and c). Also, increasing
1. The maximum MOM and SDM are recorded for the the PPS increases the MWM with a good correlation (Fig. 9d).
horizontal direction, in which the measurement On the other hand, no correlation could be obtained between
performed across the lay. the MOP and the PPS (Fig. 9b). This revealed that the PPS has
2. The minimum MWM is recorded for the horizontal a good correlation with MOM, SDM and MWM. In other
direction, which produces maximum MOM. This means word, changing the value of the PPS would give the same
that calculating the GLCM in a direction across the characterization for the three specimens, assuming that
lay produces maximum MOM and minimum MWM. the same value is used for the three specimens. From Fig. 9d,
Table 2
Calculated parameters for the captured images of the 2 min. specimen in the four directions
Fig. 7. Effect of the PPD on the GLCM for the 2 min. specimen.
it can be concluded that using the newly introduced MWM 6.2.1. Characterization using the standard specimens
parameter with a PPS in the range of 4 –10 yields the best To characterize the three standard specimens, five images
result in distinguishing the three different roughness classes. for different areas of each specimen were captured. A
symmetric GLCM was calculated for each of the captured
6.2. Characterization using the GLCM images, then the introduced parameters were calculated for
each image using a position operator P1;0 ; i.e. PPS ¼ 1 and
To characterize surface roughness using the GLCM, the PPD ¼ 0 (horizontal direction). Fig. 10 shows one of the
characterization process were performed for both the three captured images for each specimen and the 3D plot of the
standard specimens and the 10 machined specimens. corresponding GLCMs. Table 3 shows the calculated
Fig. 8. 2D plots of the GLCMs using various values of PPS for the three standard specimens.
584 E.S. Gadelmawla / NDT&E International 37 (2004) 577–588
Fig. 9. Effect of the PPS on the parameters MOM, MOP, SDM and MWM.
parameters for each image of the three specimens. As the lay the amount of the scattered light from this surface
of the three standard specimens is vertical (Fig. 10), the increases and the surface appears darker. Also, when the
direction of calculation is selected horizontally (across surface roughness decreases, the amount of the scattered
the lay). Fig. 11 shows the relation between the average of light decreases and the surface appears lighter. The same
the calculated parameters and the arithmetic average rough- result was obtained in a pervious work [9] using the first-
ness Ra : The following items could be observed from Figs. 10 order texture features (gray level histogram).
and 11 and Table 3: 4. The MOM increases by increasing the arithmetic average
roughness ðRa Þ: This is because, for rough surfaces, the
1. The calculated parameters MOM, MOP, SDM and MWM matrix is concentrated around its diagonal and moves
have a very good correlation (. 0.96) with the arithmetic toward its lower left, which increases the MOM.
average roughness ðRa Þ: Thus, all of these parameters 5. The SDM increases by increasing the surface
could be used as indications of surface roughness. roughness.
2. The MWM decreases by increasing the surface roughness.
This means that when a surface is rough, the mass of the 6.2.2. Characterization using the machined specimens
GLCM tends to be concentrated around the main To characterize the machined specimens, three images
diagonal. On the other hand, for smooth surfaces, the were captured for each specimen under the same
values of the GLCM are much spread. conditions, then the averages of the introduced parameters
3. As the surface becomes rough, the MOP decreases by were calculated from the GLCMs using a position
moving towards the lower left corner of the matrix. operator P1;2 ; i.e. PPS ¼ 1 and PPD ¼ 2 (vertical direction).
This is because, when the surface roughness increases, The direction of calculation was taken vertically to perform
E.S. Gadelmawla / NDT&E International 37 (2004) 577–588 585
Fig. 10. The captured images and the corresponding GLCM for the three standard lapped specimens.
the measurements across the lay. Fig. 12 shows samples of 1. The MOP is very sensitive to smooth surfaces, while this
the captured images for the smoothest and the roughest sensitivity decreases for rough surfaces. Therefore, the
specimens. Fig. 13 shows the relation between the averages slope of the MOP for the standard specimens
of the calculated parameters and the arithmetic average (Ra ¼ 0:051 : 0.203 mm) is greater than the slope of the
roughness Ra : The same observations obtained for the machined specimens (Ra ¼ 2:139 : 3.934 mm).
standard specimens could be noticed here. In addition, by 2. The MWM has an opposite trend to the MOP, i.e. the
comparing Figs. 11 and 13, the following observations MWM is less sensitive for smooth surfaces, while this
could by noticed: sensitivity increases for rough surfaces.
586 E.S. Gadelmawla / NDT&E International 37 (2004) 577–588
Table 3
Parameters calculated from five images for the three standard specimens
2 min. (0.0508 mm) SDM 42.3 42.4 40.9 41.8 42.2 41.9
MOM 444.0 439.0 447.0 438.0 448.0 443.2
MOP (X) 93.0 91.0 87.0 99.0 98.0 93.6
MOP (Y) 95 101 88 95 92 94.2
MWM 52.3 50.9 50.9 53.7 52.3 52.0
4 m in. (0.1016 mm) SDM 54.6 52.9 50.6 53.3 57.2 53.7
MOM 1184.0 1176.0 1168.0 1207.0 1197.0 1186.4
MOP (X) 57.0 56.0 52.0 61.0 57.0 56.6
MOP (Y) 57.0 56.0 55.0 58.0 59.0 57.0
MWM 55.2 53.7 53.7 58.0 56.6 55.4
8 min. (0.2032 mm) SDM 64.4 66.5 61.8 63.4 63.7 64.0
MOM 1818.0 1921.0 1792.0 1826.0 1845.0 1840.4
MOP (X) 39.0 40.0 40.0 39.0 41.0 39.8
MOP (Y) 39.0 40.0 41.0 42.0 40.0 40.4
MWM 58.0 60.8 58.0 59.4 56.6 58.5
Fig. 12. Photographs of the smoothest and the roughest samples machined by face turning operations.
E.S. Gadelmawla / NDT&E International 37 (2004) 577–588 587
Fig. 13. Relation between the GLCM calculated parameters and Ra for the machined specimens.
3. The SDM has approximately the same sensitivity for considered the most suitable parameter for both smooth
both smooth and rough surfaces. Therefore, the SDM is and rough surfaces.
considered the most suitable parameter for both smooth
and rough surfaces.
References
7. Conclusions [1] Gadelmawla ES, Koura MM, Maksoud TMA, Elewa IM, Soliman
HH. Roughness parameters. J Mater Process Technol 2002;123(1):
133–45.
A vision system has been introduced for surface rough- [2] Griffiths BJ, Middleton RH, Wilkie BA. Light-scattering for the
ness characterization using the GLCM. Three standard measurement of surface finish: a review. Int J Prod Res 1994;32(11):
lapped specimens and ten machined samples were used to 2683– 94.
[3] Gadelmawla ES, Koura MM, Maksoud TMA, Elewa IM, Soliman
perform the experimental work. The 2D and 3D plots of the
HH. Using the grey level histogram to distinguish between roughness
GLCM could be successfully applied to distinguish between of surfaces. Proc I MECH E, Part B, J Eng Manuf 2001;215(4):
surfaces of different roughness. Four parameters were 545–53.
calculated from the GLCM to characterize surface rough- [4] Al-Kindi GA, Baul RM, Gill KF. An application of machine vision in
ness: MOM, MOP, SDM and MWM. The MWM is a the automated inspection of engineering surfaces. Int J Prod Res 1992;
30(2):241– 53.
suggested parameter introduced through this work. It could
[5] You Z, Chen J, Pu XL. Noncontact surface roughness measuring
be successfully applied to be used as a surface roughness system based on computer vision. In Proceedings of the 10th Annual
indicator. Meeting of the American Society for Precision Engineering. Austin,
Two parameters can affect the calculated GLCM: PPS TX; 15 –20 October, 1995. p. 116–9 [chapter 108].
and PPD. A good correlation could be obtained between the [6] Kiran MB, Ramamoorthy B, Radhakrishnan B. Evaluation of surface
roughness by vision system. Int J Mach Tools Manuf 1998;38(5-6):
PPS and the three parameters MOM, SDM and MWM. On
685–90.
the other hand, no correlation could be found between the [7] Lee BY, Juan H, Yu SF. Machine vision assisted characterization of
PPS and the MOP. machined surfaces. Int J Prod Res 2001;39(4):759 –84.
It was found that the proposed parameters have a good [8] Lee BY, Juan H, Yu SF. A study of computer vision for measuring
correlation with the average roughness Ra : It can be reported surface roughness in the turning process. Int J Adv Manuf Technol
2002;19:295 –301.
that the three parameters MOM, SDM and MWM increase
[9] Gadelmawla ES, Koura MM, Maksoud TMA, Elewa IM, Soliman
by increasing the arithmetic average roughness Ra ; while the HH. Assessment of surface texture using an uniquely
MOP parameter decreases by increasing Ra : In addition, it featured computer vision technique. In Proceedings of the Fourth
was found that the MOM is very sensitive for smooth International Machining and Grinding Conference, Society of
surfaces and this sensitivity decreases for rough surfaces. Manufacturing Engineers, SME, Troy, Michigan, USA; 7–10 May,
2001.
On the other hand, the MWM is less sensitive for smooth
[10] Zhang J, Tan T. Brief review of invariant texture analysis methods.
surfaces and this sensitivity increases for rough surfaces. Pattern Recogn 2002;35:735–47.
The SDM has approximately the same sensitivity for both [11] Weszka JS, Rosenfeld A. An application of texture analysis to
smooth and rough surfaces. Therefore, the SDM is materials inspection. Pattern Recogn 1976;8:195– 9.
588 E.S. Gadelmawla / NDT&E International 37 (2004) 577–588
[12] Garcia P, Petrou M, Kamata S. The use of boolean model for texture [20] Baraldi A, Parmigianni F. An investigation of the textural character-
analysis of grey images. Computer Vis Image Understand 1999;74(3): istics associated with gray level co-occurrence matrix
227–35. statistical parameters. IEEE Trans Geosci Remote Sensing 1995;
[13] Tsai DM, Hsieh CY. Automated surface inspection for directional 33(2):293–302.
textures. Image Vis Comput 1999;18:49– 62. [21] Davis LS, Johns SA, Aggarwal JK. Texture analysis using generalised
[14] Pitas I. Digital image processing algorithms and applications. New co-occurrence matrices. IEEE Trans Pattern Anal Mach Intell 1979;
York: Wiley; 2000. 1(3):251–9.
[15] Chen CH. A study of texture classification using spectral features. In [22] Kovalev V, Petrou M. Multidimensional co-occurrence matrices for
Proceedings of the Sixth International Conference on Pattern object recognition and matching. Graph Models Image Process 1996;
Recognition; 1982. p. 1074–7. 58(3):187–97.
[16] Konak ES. A content-based image retrieval system for texture and [23] Al-Janobi A. Performance evaluation of cross-diagonal
color queries. Master Thesis, Computer Engineering and the Institute texture matrix method of texture analysis. Pattern Recogn 2001;
of Engineering and Science, Bilkent University; 2002. 34:171–80.
[17] Carlucci L. A formal system for texture languages. Pattern Recogn [24] Torroba P, Rabal H, Arizaga R. Correction of defocusing using the co-
1972;53–72. occurrence matrix and the structure function. J Modern Opt 2000;
[18] Lu SY, Fu KS. A syntactic approach to texture analysis. Computer 47(1):69–80.
Graph Image Process 1978;303–30. [25] Handysurf E-10. Advanced Metrology Systems Limited, 2 Pomeroy
[19] Haralick RM, Shanmugam K, Dinstein I. Textural features for image Drive, OADBY Industrial Estate, OADBY Leicester, LE2 5NE,
classification. IEEE Trans Syst, Man Cybernet 1973;3:610 –21. England.