constructing glcm

33
What is Texture the feel, appearance, or consistency of a surface or a substance. substance. Everyday texture terms rough, silky, bumpy refer to touch. Wh iR hT What is R oughT exture a large difference between high and low points, and a space between highs and lows approximately the same a space between highs and lows approximately the same size as a finger. What is silk texture l l d ff b h h dl d little diff erence between high andlow points, and the differences would be spaced very close together relative to finger size.

Upload: siddz101

Post on 04-Dec-2014

626 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Constructing GLCM

What is Texturethe feel, appearance, or consistency of a surface or a substance.substance.Everyday texture terms ‐ rough, silky, bumpy refer to touch. Wh i R h TWhat is Rough Texturea large difference between high and low points, and a space between highs and lows approximately the samea space between highs and lows approximately the same size as a finger. What is silk texturel l d ff b h h d l dlittle difference between high and low points, and the differences would be spaced very close together relative to finger size. g

Page 2: Constructing GLCM

Image TextureImage Texture

• Image texture works in the same way exceptImage texture works in the same way, except the highs and lows are brightness values or  grey levels GL or digital numbers DN)grey levels, GL,  or digital numbers, DN) instead of elevation changes.

• Instead of probing a finger over the surface a• Instead of probing a finger over the surface, a "window" ‐ a (usually square) box defining the size of the probe is usedsize of the probe ‐ is used. 

Page 3: Constructing GLCM

image Texture?image Texture?

Texture is a repeating pattern of local variations in imagei iintensity:characterized by the spatial distribution of intensity levels in

a neighbourhooda neighbourhood

Used to partition images into regions of interest and toclassify those regions

cannot be defined for a point

For example, an image has a 50% black and 50% whitedistribution of pixelsdistribution of pixels.

Three different images with the same intensity distribution,but with different textures.

Page 4: Constructing GLCM

Texture FeaturesTexture Features

• A major problem is that textures in the real world j pare often not uniform, due to changes in orientation, scale or other visual appearance.

• To describe a texture we can use as feature a• To describe a texture, we can use as feature a• mathematical measure of:• • fine or coarse ?• • fine or coarse ?• • smooth or rough ?• • homogeneous or inhomogeneous ? homogeneous or inhomogeneous ?• • spatial structure, orientation,• • contrast, etc,

Page 5: Constructing GLCM

Texture Measurement or AnalysisTexture Measurement or Analysis

• There are three common ways of analyzingThere are three common ways of analyzing texture:

• Statistical ApproachesStatistical Approaches• Structural Approaches• Spectral Approaches• Spectral Approaches• Textures may be random, but with certain consistent properties one obvious way toconsistent properties, one obvious way to describe such textures is through their statistical propertiesstatistical properties

Page 6: Constructing GLCM

Statistical Approaches

M t f I t it Fi t O d St ti ti• Moments of Intensity: First Order Statistics

• The most well known easiest first order statistics is the histogram: 

• Disadvantage: only pixel intensities are represented, no spatial interaction: mean how intesities are distributed over image space

Page 7: Constructing GLCM

Moments of Intensity: First Order StatisticsStatistics

• Suppose that we construct the histogram of the intensities

• in a region. We can then compute moments of the 1‐D histogram:Th fi t t i th i t it• • The first moment is the mean intensity

• • The second central moment is the variance, which describes how similar the intensities are within thedescribes how similar the intensities are within the region.

• • The third central moment, skew, described how symmetric the intensity distribution is about the mean.

• • The fourth central moment, kirtosis, describes how flat the distribution isflat the distribution is.

Page 8: Constructing GLCM

Second order statistic • Second order statistics consider pixels in pairs.• consider the relationship between groups of two (usually neighboring) pixels in the original image

• Hence, it represents bilateral spatial interactions.• It depends on 2 more parameters:• d: relative distance between pixels.• Φ: relative orientation between pixels.• For computational reasons, Φ is discretized, for• example in 4 regions around (0°, 45°, 90°, 135°).• This means the pixel pairs may be observed  diagonally, vertically in pixel space or image space

Page 9: Constructing GLCM

Gray Level Co-occurrence:Second order statisticSecond order statistic 

• Gray Level C0‐occurance is second order statistic ymeasurement that contains information about the positions of pixels having similar gray level values.

d l h h b h h• It is  a two‐dimensional array, P, in which both the rows and the columns represent a set of possible image values.image values.

• A GLCM Pd[i,j] is defined by first specifying a displacement vector d=(dx,dy) and countingdisplacement vector d (dx,dy) and counting all pairs of pixels separated by d having gray levels i and j.

Page 10: Constructing GLCM

GLCMGLCM

• GLCM texture considers the relation between two pixels at a time, called the reference and the neighbour pixel. In the illustration below, the neighbour pixel is chosen to be the one to the east (right) of each reference pixel. ( g ) f f pThis can also be expressed as a (1,0) relation: 1 pixel in the x direction, 0 pixels in the y direction.Means we are moving towards east with one pixel distance without g pany pixel distance in y direction.

• Each pixel within the window becomes the reference pixel in turn starting in the upper left corner andpixel in turn, starting in the upper left corner and proceeding to the lower right. Pixels along the right edge have no right hand neighbor, so they are not used for this countused for this count.

Page 11: Constructing GLCM

Constructing GLCMConstructing GLCM The Construction of GLCM matrix involves followingmain four steps.main four steps.•Pairing the Pixels•Constructing Pixel FrameworkM ki S t i M t i•Making Symmetric Matrix

•Normalization of the Matrix•Pairing the Pixels•GLCM texture considers the relation between two pixels at atime, The pixel pair is called as reference and neighbor pixel.•In figure shown The neighbor pixel is chosen to be the one tog g pthe east (right) of each reference pixel. This can also beexpressed as a (1,0) relation: 1 pixel in the x direction, 0 pixelsin the y direction.

Page 12: Constructing GLCM

Pairing the PixelsPairing the Pixels• Given Image:

• Pixel Pairing:g• Combinations of the grey levels that are possible for the test image, and their position in the matrix.

Page 13: Constructing GLCM

Constructing FrameworkConstructing Framework

• Twice in the test image the reference pixel is 0 and its easterng pneighbor is also 0. i.e. the combination (0,0) has appearedtwice. so is the combination of pixel (0,1). Three times thereference pixel is 2 and its neighbor is also 2reference pixel is 2 and its neighbor is also 2.

Page 14: Constructing GLCM

Making the matrix symmetrical around the diagonalg y g

• Taking the transpose of the GLCM make itTaking the transpose of the GLCM make it symmetric. 

• Normalization of GLCM• Normalization of GLCM• Means expressing the elements of GLCM in probability. After

making the GLCM symmetrical, there is still one step to takemaking the GLCM symmetrical, there is still one step to takebefore texture measures can be calculated. The measuresrequire that each GLCM cell contain not a count, but rather aprobabilityprobability.

• Probability :the number of times an outcome occurs, dividedby the total number of possible outcomes."y f p

Page 15: Constructing GLCM

Normalization of the GLCMNormalization of the GLCM

• Vi j is the value of the GLCM at cell i jVi,j is the value of the GLCM at cell i,j

Page 16: Constructing GLCM

Exercise• Exercise: Use the test image and a south spatial 

relationship with reference pixel and the neighbor below it . 

• Test image Find Pixel Pairing

•S t i l t i• Symmetrical matrix

• Normalized Matrix

Page 17: Constructing GLCM

Things to Note about Normalized Symmetrical GLCMTh di l l ll i l i i h l l• The diagonal elements all represent pixel pairs with no grey level difference (0‐0, 1‐1, 2‐2, 3‐3 etc.).

• If there are high probabilities in these elements, then the image does not show much contrast: most pixels are identical to their neighbors.

• When values in the diagonal are summed, the result is theWhen values in the diagonal are summed, the result is the probability of any pixel's being the same grey level as its neighbor.

• Cells one cell away from the diagonal represent pixel pairs with a difference of only one grey level (0 1 1 2 2 3 etc ) Similarly valuesdifference of only one grey level (0‐1, 1‐2, 2‐3 etc.). Similarly, values in cells two away from the diagonal show how many pixels have 2 grey level differences, and so forth. The farther away from the di l th t th diff b t i l l ldiagonal, the greater the difference between pixel grey levels.

• Sum up these parallel diagonals and the result is the probability of any pixel's being 1 or 2 or 3 etc. different from its neighbour

Page 18: Constructing GLCM

• Summary of steps in creating a symmetrical normalized y p g yGLCM: 

• Create a framework matrix • Decide on the spatial relation between the reference and neighbor pixel 

• Count the occurrences and fill in the framework matrix• Count the occurrences and fill in the framework matrix • Add the matrix to its transpose to make it symmetrical • Normalize the matrix to turn it into probabilities.Normalize the matrix to turn it into probabilities. •

Page 19: Constructing GLCM

Properties of the GLCM 

• CONTRAST GROUP  : How much pixel value is same to its neighbor 

– Contrast

– Dissimilarity

– HomogeneityHomogeneity

• ORDERLINESS GROUP  (How much orderness lies in the pixel arrangement)– Angular Second Moment (ASM) 

– EnergyEnergy

– Entropy (ENT)

– Maximum Probability (MAX) 

• STATS GROUP Descriptive Statistics on the GLC Matrixp– GLCM Mean, 

– GLCM Variance (or Standard Deviation) and 

– GLCM Correlation. 

Page 20: Constructing GLCM

Contrast GroupContrast Group

• Measures related to contrast use weights related to the distance f th GLCM di lfrom the GLCM diagonal.

• Values on the GLCM diagonal show no contrast, and contrast increases away from the diagonal

• Contrast:• Contrast:‐

• When i and j are equal, the cell is on the diagonal and (i‐j)=0. These values represent pixels entirely similar to their neighbor so they arevalues represent pixels entirely similar to their neighbor, so they are given a weight of 0. 

• If i and j differ by 1, there is a small contrast, and the weight is 1. • If i and j differ by 2 contrast is increasing and the weight is 4If i and j differ by 2, contrast is increasing and the weight is 4. • The weights continue to increase exponentially as (i‐j) increases 

Page 21: Constructing GLCM

Example

What is the degree of this measure? 

Second degreeExercise: Calculate the Contrast for the vertical GLCM and compare it with the Contrast for the horizontal GLCM

Page 22: Constructing GLCM

Dissimilarity (DIS)• In the Contrast measure, weights increase exponentially (0, 1, 4, 9, 

etc.) as one moves away from the diagonal. However in the dissimilarity measure weights increase linearly (0, 1, 2,3 etc.).

• Try out the Dissimilarity calculation for the horizontal image and compare the value with Contrast for the same matrix: p

Vertical Dissimilarity is 0.664; vertical Contrast is 0.996. Contrast gives a higher number than does Dissimilarity, which is as expected since Contrast weights are larger

Page 23: Constructing GLCM

• Homogeneity (HOM) (also called the "Inverse Difference Moment") Homogeneity weights values by the inverse of the Contrast weight, with weights decreasing exponentially away from the diagonalweights decreasing exponentially away from the diagonal

C l l h h i l f h h i l GLCM d i i h hCalculate the homogeneity value for the horizontal GLCM and compare it with the Dissimilarity value. 

Page 24: Constructing GLCM

Measure of orderness• Orderliness measures, like contrast, use a weighted average of the 

GLCM values. The weight is constructed related to how many times a given pair occurs.

• A weight that increases with commonness will yield a texture measure that increases with orderliness. 

• A weight that decreases with commonness yields a texture measure that e g a dec eases co o ess y e ds a e u e easu e aincreases with disorder 

• In the more orderly image on the left, each pair of values ti 2 i t t 1 f ti 3 i t t 2occurs many times: 2 is next to 1 four times, 3 is next to 2 

four times, etc. For the less orderly image, combinations occur less often: 2 is next to 1 only once, 3 next to 2 y ,three times, and so on.

Page 25: Constructing GLCM

ASM and EnergyASM and Energy

Page 26: Constructing GLCM

Exercise on ASM and energyExercise on ASM and energy

• The maximum value of 1 for either ASM or Energy occurs when all pixels in the image are identical. Quickly draw the GLCM for this situation and perform the ASM calculation.

• Solution:

• Lets suppose we have 3 level image 0,1,2,3 all having same value and lets say its equal to 2. i.e.

• Calculate GLCM:

• Step 1. pairing pixel

Page 27: Constructing GLCM

Exercise on ASM and energygy

• Calculating the pixel framework let say A=Calculating the pixel framework let say A=

• symmetric= A+A’=

• GLCM= A+A’/sum(A+A’)=• ASM: 1*1 = 1• ASM: 1 1 = 1

Page 28: Constructing GLCM

ASM calculation• Perform the ASM calculation for the horizontal GLCM: 

Page 29: Constructing GLCM

EntropyEntropy

• Using the equation calculate the Entropy of the horizontal GLCM

Page 30: Constructing GLCM

Descriptive Statistics on the GLC Matrix

Page 31: Constructing GLCM

Variance Calculation for GLCMVariance Calculation for GLCM

Page 32: Constructing GLCM

GLCM CorrelationGLCM Correlation 

• The Correlation texture measures the linear dependency e o e a o e u e easu es e ea depe de cyof grey levels on those of neighbouring pixels. GLCM Correlation is quite a different calculation from the other 

d ib d b A l i itexture measures described above. As a result, it is independent of them (gives different information) and can often be used profitably in combination with anothercan often be used profitably in combination with another texture measure. It also has a more intuitive meaning to the actual calculated values: 0 is uncorrelated, 1 is perfectly correlated.

Page 33: Constructing GLCM

Correlation Calculation• Exercise: Calculate the GLCM 

• Correlation measure for the horizontal

• test image. g