You are on page 1of 14

Texture Features Analysis Based on GLCM and Law Masks

By. Darshan Venkat and Sharib Ali


Masters in Computer Vision,University of Burgundy, Le Creusot, France
ali.sharib2002@gmail.com, darsh.venkat@gmail.com

Instructors: Proff. Robert Marti Marly & Jordi Freixenet


rmartimarly@gmail.com, jordif@eia.udg.es

Keywords: GLCM, Laws Masks, texels

Abstract:
This report is based on the study of different texture features in images using descriptors like
GLCM(Gray Level Co-occurrence Matrix) and Law Masks. GLCM is used to derive various statistical
indicators of texture including contrast, correlation, energy and entropy. Evaluation of Law Mask
involves determining of the different convolution masks and finding which is best suited for the texture
feature identification for different statistical measures like mean, absolute mean and standard
deviation. These methods are used for different images having different pixel intensities and the best
suited statistical parameter for a given methodology applied is analyzed in this report for a given
image. In addition, this report also contains short description on GLCM and Law Masks which has
been used for our feature analysis of a texture. Both the graylevel and color images has been
considered.

Contents
1 Introduction
2 Methodologies Used for Texture Analysis
2.1 GLCM
2.2 Law Masks
3 Design and Implementation
4 Experiments and Result Analysis
5 Computation Analysis
6 Conclusion

1. Introduction
Image texture defined as the spatial variation in the pixel intensities is a wide research area with
many methods. However, we have applied two most distinct and promising descriptors, GLCM and
Laws masks. The basic idea behind this was to classify different feature pixels in an image called
'texels'. These periodic property of an image often gives the texture of an image.
2. Methods Used for Texture Analysis:

2.1 Gray-level Co-Occurrence Matrices: One of the defining quality of texture is the
spacial distribution of pixel values (Tuceryan and Jain 1993). Statistical indicator have
therefore been one of the oldest method to describe texture. The aim of statistical methods of
texture analysis is to characterize the stochastic process of spacial distribution of pixel values in
an image(He and Wang 1991).
The occurrence of the gray level values can be tabulated as a matrix called gray level co-
occurrence matrix. To explain how a GLCM is constructed, lets consider an image P of
dimension N x N and G gray levels. The image block used to derive the GLCM is based on the
nearest neighborhood cells (Haralick, Dinstein and Shanmugam 1973).In this method we
assume that the information about the texture is provided by a matrix of relative frequencies
where two neighboring pixels that are separated by a distance 'd' and an angle angle theta
occur in a block. The gray value of the two pixels involved being 'i' and 'j' respectively. These
matrices are a function of angle and distance between two pixels.
Consider a small block of image I of size 5x5,and having 4 gray levels.

0 2 0 2 0
0 2 0 2 0
0 2 0 2 0
1 1 1 3 1
1 1 1 3 1

The gray level for the above image clip where d=1 and theta =0,45,90,135 are shown below.
I(d=1,theta = 0)
0 1 2 3
0 0 0 9 0
1 0 8 0 4
2 9 0 0 0
3 0 4 0 0
I(d=1,theta = 90)

0 1 2 3
0 12 3 0 0
1 3 8 1 0
2 0 1 8 1
3 0 0 1 1
I(d=1,theta = 135)

0 1 2 3
0 0 1 4 1
1 1 4 2 1
2 4 2 0 0
3 1 2 0 0

I(d=1,theta = 45)

0 1 2 3
0 0 1 4 1
1 1 4 1 2
2 4 1 0 0
3 1 2 0 0
The Co-occurrence matrix is symmetric in nature. The number of operations required to
compute a gray level co- occurrence matrix is directly proportional to the number of pixels and
the number of gray levels present in the image. All the information required for characterizing
the image texture can be obtained for the GLCM. So different type of texture descriptors can be
extracted from the matrix. Different type of texture descriptor is tabulated in the table below.

Descriptor Formula Explanation


1 Correlation A measure of how
correlated a pixel is to
Where its neighbor over the
entire image. The value
ranges from 1 to -1.

2 Contrast A measure of intesity


contrast between a pixel
and its neighbourhood
over the entire
image.The value ranges
from 0 to
(K=-1)^2

3 Energy The range of energy is


between 0 and 1.for a
unform image
uniformity is 1.

4 Homogeneity Measures the spatial


closeness of the
distribution of elements
in the co- occurrance
matrix to the diagonal
.The range is between 0
and 1.The maximum is
achieved when the co-
occurance matrix is a
diagonal matrix.
5 Entropy The entropy measures
the Randomness of the
co-occurrence matrix.
The entropy is 0 when
all the pixels are 0 and is
maximum when all the
pixels are equal.

2.2 Laws Masks:


Law Masks are a set of convolution masks used for deriving texture indicators by using
a set of gradient operators. These operators are based on combining the result of first and
second order derivatives on an image block.(Lam and Li 1995).Laws texture are computed by
applying a convolution kernel to a digital image and then performing a nonlinear windowing
operation. There are mainly 5 types of masks of size 3x3 and 5x5.These can be used to
represent features such as Edge,holes,spots,ripple and level.
Laws texture energy measures are derived form 3 simple vector of length 3.Convolve
these three features we can obtain vectors of length 5.

L3(Level) [ 1 2 1]
E3(Edge) [-1 0 1]
S3(Spot) [-1 2 -1]
L5(level) L3*L3 [1 4 6 4 1]
E5(Edge) L3*E3 [-1 -2 0 2 1]
S5(spot) L3*S3 [-1 0 2 0 -1]
R5(ripple) S3*S3 [1 -4 6 -4 1]
W5(Wave) E3*S3 [-1 2 0 -2 1]

The level (L5) vector gives a center weighted local average. Edge (E5) is similar to
gradient operator and responds to row or column stepped edges in an image. Spot (S5) is
based on the second derivative and is similar to performing Laplacian over a Gaussian. Wave
responds to slight changes in pixel intensities in an image and ripple(R5) is used to detect
ripples in an image.
Laws convolution masks are derived by multiplying the two vectors while considering
one vector as row and other vector as a column vector respectively. A set of such combinations
of 3x3 and 5x5 are shown below.
-1 4 6 -4 -1 1 -4 6 -4 1 -1 0 2 0 -1
-2 -8 -12 -8 -2 -4 16 -24 16 -4 -2 0 4 0 -2
0 0 0 0 0 6 -24 36 -24 6 0 0 0 0 0
2 8 12 8 2 -4 16 -24 16 -4 2 0 -4 0 2
1 4 6 4 1 1 -4 6 -4 1 1 0 -2 0 1

E5L5 R5R5 E5S5

L3L3 1 2 1 E3S3 1 -2 1
2 4 1 0 0 0
1 2 1 -1 2 -1
L3E3 -1 0 1 S3L3 -1 -2 -1
-2 0 2 2 4 2
-1 0 1 -1 -2 -1
L3S3 -1 2 -1 S3E3 1 0 -1
-2 4 -2 -2 0 2
-1 2 -1 1 0 -1
E3L3 -1 -2 -1 S3S3 1 -2 1
0 0 0 -2 4 -2
1 2 1 1 -2 1
E3E3 1 0 -1
0 0 0
-1 0 1
Two steps are involved in obtaining the laws of texture descriptors-
1)Applying a convolution over a image using the above masks.
2)Obtain the statistical measure using the convolution result. We can obtain three statics such as
mean ,absolute mean and standard deviation.

3. Design and Implementation

Following steps has been taken for the implementation of the algorithms-

(A)Gray Level Co-occurrence Matrix(for gray level images):


output= GrayCooccuranceMatrix(image_test,R,C,offset_value,gap);
Features:
1. User is given to enter the offset direction like 0,45,90 or 135.
2. User is given to enter the mask size.
3. It computes all the statistical parameters which we have described in the function.
4. Output comes as an array of outputs in a cell of 1x5.

(B)Gray level Co-occurrence matrix(for color images):


colorGLCM(image_test1,offset_value,gap);
Features:
1. Calculates all the statistical parameters similar to GrayLevelCoccurence Matrix function used for
gray level images but it does this for each channel
2. Finally, both the color texture images and average channel images are shown for each statistical
parameter.
Fig1. GLCM with different Statistical Parameters

(C)Law_Mask(for gray level images):


[output_image_mean,output_image_abs_mean,image_std]=Law_Mask(image_test,mask);
Features:
1.The user is allowed to input 1D filters type (both 3 size and size 5) are accepted (calculation is
made by using the same function so it removes tough computation and lengthy code.
2.The mask is calculates taking the transpose of the first.
3.The function is easy and fast to compute the mean, abs mean and the standard deviation of the
input gray level image.
(D)Law_Mask(for colored images):

LawMaskColor(image_test1,mask);
Features:
1. It calls passes the colored image 'image_test1' and 'mask' as input parameters
2. It determines the Law Mask calling the Law_Mask function above explained for the all the
three channels to extract the features.
3. Finally, these features of the texture are represented as a color of texture.
4. Texture features are also shown as by calculating the average of all the channels for different
features.

a.

b.

Fig2.(a)Law Masks L5S5 (b)Law Masks L3E3(color channels)


4.Experiments and Results

GLCM Result Analysis


We got better results with 'feli.tif' and other images except the 'mosaic8.tif' which showed some
satisfactory result with the laws masks. The various images with its output as a texture descriptor using
different statistical measures explained above has been listed with their brief explanation.
Fig. a. 0degree,mask[11 11],Contrast → we have taken computed GLCM in this case for all the R,G
and B channels and then taken then converted it to gray level image. It is the best result we got with
'feli.tif'. Here, the object is distinctly identified from the background and thus proves to be better image
for the purpose of segmentation.
Fig. b. 135degree,mask[5 5],Energy → This clearly separates the background from the objects but
some part of the hand will be merged in the background so we will be losing information in this case.
However, the texture identification is good enough.
Fig. c. 0degree,d=1,mask[7 7],Correlation → We can distinguish the texture here as well. But, the
idea behind putting this image is to make an approach towards edge detection and then making the
segmentation. So, this correlation feature analysis can also be result promising statistical measure for
GLCM.
Fig. d,e. 0degree,mask[7 7],Entropy → This worked well but we expected more dark black for the
hand and some distinct white for the rubber. But, this was better than other experimental results though
we tried randomly with very few for 'hand2.tif'.(e) better for segmentation. Its the entropy calculated
for each channel.
Fig.f. 0Degrees, mask[15 15], Correlation → This was the most difficult image for us. However, we
thought the vaiation in contrast and texture marking a clear edge makes some sense of identification.
However, we are not so sure of this result and we think that laws masks does some justice to this
texture classification.

b.

d.

c.
e. f.

Fig.5 Texture Analysis for GLCM


Laws Masks: Below we have analyzed with those laws masks which shows best, better or the
worst results. The remaining masks has been discarded and not explained as it is almost impossible to
show all and explain all of them. Those masks which are discarded is because they produce some
intermediate results.

The best result for 'feli.tif' was with the masks L3 and E3 which is shown in green. The best
was seen when it was calculated for all the pixels in each channel and the absolute mean so calculated
for then after convolution was averaged to get the image. However, nearly similar result was obtained
with direct computation of the absolute mean from the gray image but previous was more better. The
image with L5E5 was somewhat blurred so we have not placed here. The image for standard deviation
showed some distict texture feature in some cases like one best we got was with R5E5 in fig.c. But,
the features were totally degraded in the case of mean computations with this image. We have
highlighted the best result in 'green rectangle'.

b.

c.

a.
d.
e.

Fig.3 Texture Analysis with 'Feli.tif'


a. L3E3 (abs Mean for Average Channel) -Best
b. L3E3(abs Mean) -Better
c. R5E5(std deviation) -Better for Standard deviation(Texture distinct)
d. Mean with E5S5 -Worst
e. E3L3 with abs mean (for color Texture) -Not much Clear(doesn't make sense)

b.

c.

a.
d.

Fig.4 Texture Analysis with 'hand2.tif'


a. L5R5 (Mean- RGB channels used)
→ Shows distinct difference in textures (smoothness of hand and rubber clearly outlines the rough
backgound)
b. E5E5(standard deviation) → identifies the texture of hand, rubber and background clearly
c. R5R5(standard deviation) → it has almost similar feature identification but its blurred
d..E3E3(abs mean) → Hand and the rubber is almost mingled in one so its the worse among all.

b.
a.

c.

c.
d.

Fig.5 Texture Analysis with 'pingpong2.tif'

a. S5E5(Standard Deviation) → We can clearly distinguish between the rough background and the
smooth tennis bat but ball cant be seen which is its defect. We kept this image because it can easily
detect the curvy lines of the board however the image is blurred so its not better for texture feature
manipulation.

b. L3E3(abs mean) → This cannot properly give clear remark on particular features because surfaces
are seen to be uniform so its not better.

c. L5S5(abs mean) → It gives better result with clear rough background and other plain objects are
given similar shade. In addition, the ball has some reflectance which makes it distinct. So,this image
can also be considered as a better image which gives the texture features classification.

d. L3L3(Standard deviation) → This looks more like edge detection derivatives like 'sobel'. Actual
texture of the image is not clear.
a. b.

Fig.4 Texture Analysis with


'mosaic8.tif'

a. L3L3(Standard deviation)
b.S3E3(abs. Mean)
c. L5L5(Std. Deviation-color) c.
d. R5L5(mean-RGB) d.

With the mosaic, we didn't get satisfactory result with the law masks. However, fig4a.
gives some sense of texture feature.

5. Computation Analysis
The key factor of running the program with the 1.8GHz processor, core 2 duo, 1GB RAM and using
MATLAB as the working platform gave satisfactory running speed of less than 3 secs for all the images
for Laws Masks. However, it took nearly 4-6 minutes to get an output for GLCM with the images. So,
looking the cost of computation laws masks proves to have an upper hand over GLCM.

GLCM
Image mask direction time(in secs)
PingPong2(gray) [3 3] 0 180,98
PingPong2(color) [3 3] 0 587,9
PingPong2(gray) [5 5] 45 214
PingPong2(color) [5 5] 45 642

Laws Masks
Image mask time(in secs)
PingPong(gray) [3 3] 0.22
' ' [3 3] 0.73
PingPong(color) [5 5] 0.45
' ' [5 5] 0.8

Fig. Table for Computational Time for Texture Desriptors


Image “Pingpong2.tif” → Size:228x344x3
6. Conclusion
The key idea behind getting a good understanding of the texture analysis was pretty healthy and
good start towards image segmentation and pattern recognition. The texture plays a vital role in the
abstraction of key features of an image and makes the segmentation part more robust with this
classification. We were given to study different images for the texture analysis using descriptors like
GLCM and Laws masks. Not all, but few better classified the image on the basis of their texture.
GLCM gave more better results with its statistical parameters energy and entropy when taken for
different orientations and distances. We conclude that the mask size with [3 3] gave better result
because as we increased the mask size we got some blurred which destroyed the actual texture of the
image. With Laws Masks, it was very efficient but all the laws masks didn't showed good result. So, the
selection of the mask was the crucial thing in this. Overall, it gave some good results for statistical
parameters absolute mean and standard deviation.

References
1. Joan Marti, Jordi Freixenet Lecture Slides on “Texture Characterization”
2. Christian Mata Miquel, “MSc. Thesis VIBOT Texture Descriptors applied to Digital
Mammography”
3. A.N.Tassetti, E.S.Malinverni,M. Hahn,”Texture Analysis to improve supervised Classification in
Ikonos Imagery”
4. A. Karahaliou, MSC, S Skiadopoulos, PHD, L Boniatis, MSC, P Sakellaropoulos, PHD, E Likaki,
MD, G Panayiotakis, PHD and L Costaridou, PHD “Texture analysis of tissue surrounding
microcalcifications on mammograms for breast cancer diagnosis”

You might also like