TEX

Texture analysis


EnvironmentsPYTHON :: EASI :: MODELER
Quick linksDescription :: Parameters :: Parameter descriptions :: Details :: Example :: Algorithm :: References

Back to top

Description


TEX calculates a set of texture measures for all pixels in an input image. The measures are based on second-order statistics computed from the gray level co-occurrence matrices. Either texture measures for a specific direction or directional invariant measures can be computed. The texture measures may be used as input features to classification algorithms.
Back to top

Parameters


tex(fili, dbic, filo, dboc, texture, flsz, greylev, spatial)

Name Type Caption Length Value range
FILI* str Input file name 1 -    
DBIC List[int] Image Layer 0 -    
FILO* str Output file name 1 -    
DBOC List[int] Texture Measure Layer(s) 0 -    
TEXTURE* str Texture measures 1 -    
FLSZ List[int] Filter size (pixels, lines) 0 - 2 3 - 101
Default: 25,25
GREYLEV List[int] Number of gray levels 0 - 1 1 -
Default: 32
SPATIAL List[int] Spatial relationship (pixel, line) 0 - 2 Default: 1

* Required parameter
Back to top

Parameter descriptions

FILI

Specifies the file containing the channels to be analyzed for texture measures.

DBIC

Specifies the input channel for which the texture is to be analyzed. Input data will be scaled down to the specified number of gray levels (GREYLEV/Number of Gray Levels) during texture calculation.

FILO

Specifies the PCIDSK file containing the texture measures. May be the same as the input file.

DBOC

Specifies the list of output channels to contain the computed texture measures. When FILO specifies an existing file, then DBOC must specify the correct number of existing 32-bit real output channels in that file. The total number of output channels must equal the number of texture measures specified by the TEXTURE parameter times the number of input channels. An input channel cannot be used as an output channel. When FILO specifies a new file to be created, DBOC should not be specified.

TEXTURE

Specifies the list of texture measures to be computed.

Duplicate texture measures are not allowed.

The following are the supported textural measures (measures 1-8 are computed from the gray level co-occurrence matrix):
  1. Homogeneity
  2. Contrast
  3. Dissimilarity
  4. Mean
  5. Standard Deviation
  6. Entropy
  7. Angular Second Moment
  8. Correlation
  9. GLDV Angular Second Moment
  10. GLDV Entropy
  11. GLDV Mean (equivalent to Dissimilarity)
  12. GLDV Contrast (equivalent to Contrast)
  13. Inverse Difference

FLSZ

Specifies the window size to use for producing the co-occurrence matrix for each input pixel. The window size must be odd so that the pixel being processed is centered in the window. The window size must be an odd integer between 3 and 101.

GREYLEV

Specifies the number of gray levels to be used when constructing the GLCM matrix. The default value is 32.

SPATIAL

If two values are specified, they define the spatial relationship (dx, dy) of a pixel to its neighbor, which define both the distance and direction for texture analysis.

If one value is specified, it represents the distance between a pixel and its neighbor, and directional invariant texture measures will be computed. Typically the distance is 1 or a small integer.

Back to top

Details

TEX calculates a set of texture measures for all pixels in an input image. The measures are based on second-order statistics computed from the gray level co-occurrence matrices. Measures can be computed for either texture measures for a specific direction, or for directional invariant measures. The texture measures may be used as input features to classification algorithms.

Texture is an important characteristic used to identify objects or regions of interest in an image. Unlike spectral features, which describe the average tonal variation in the various bands of an image, textural features contain information about the spatial distribution of tonal variations within a band.

It is best to work with an image on which no filtering has been performed, because filtering functions average out much of the textural character of the image.

TEX produces several output images in which the gray levels represent textural measures of the input image These textural measures are derived from a gray level co-occurrence matrix or difference vector computed for each user-defined rectangular window and spatial relationships of the input image. The texture measure is placed at the center of the window, at the appropriate position in the output image.

Depending on how the SPATIAL parameters are specified, TEX can compute either texture measures for a particular direction, or for directional invariant measures. When two numbers are specified for SPATIAL, they are taken as the offsets (dx, dy) of the pixel neighboring the reference pixel. Texture measures for this distance and direction are computed. If only one number is specified for SPATIAL, it is taken as the distance between the pair of pixels. In this case, TEX computes directional invariant texture measures which are the averages among texture measures for 4 directions (0, 45, 90, 135 degrees).

The output images contain the raw texture measures, which may have different ranges of values. To ensure that important information is not lost, users must always save the images in 32-bit real channels. After having assessed the distribution of the image using HIS, users may then use SCALE to tailor the scaling to their specific needs.

TEX cannot process pixels on or near the edges of the image because the window does not have all of the required pixels within it. Therefore, for an image processed with a rectangular window X by Y in size, the first and last (x + 1) / 2 pixels per line will be the same and the first and last (y + 1) / 2 lines in the output image will be the same. (The four outside edges are replicated to provide sufficient data). Be careful to avoid these regions when selecting training data for supervised classification.

Earlier versions of TEX (up to V6.1) were developed by ICT Automatisering Deventer B.V. and TNO Physics and Electronics Laboratory in the Netherlands. The 6.2 version was a completely new implementation which incorporated several enhancements and corrections over the older versions. The 9.0 version is a computational advancement on prior versions implemented by D.A. Clausi (Systems Design Engineering, U. of Waterloo). Prior versions constrained the number of gray levels (G) to 16, however, 9.0 incorporates a fast algorithm whose speed is not dependent on G (for many statistics) and partially dependent on G (for some statistics). As a result, G can be set to a wider range of values to retain more of the signal content, without significant concern for computational demands. Using a greater value for G is appropriate in certain applications. For more information on the use of 32 or more gray levels when classifying SAR sea ice image data, refer to D.A. Clausi and Soh & Tsatoulis, C. in the References section.

Back to top

Example

Create 10 32-bit real texture measure images from a 16-bit ERS-1 image on channel 11 of the file "irvine.pix".

from pci.pcimod import *
from pci.tex import *

file='irvine.pix'
pciop='ADD'
pcival=[0,0,0,10]              #Add 10 32R channels

pcimod(file,pciop,pcival)

fili = file
dbic = [11]                    #Radar Image
filo = file
texture = ','.join(range(1,10+1))        #Select required texture
dboc    = range(12,21+1)
flsz    = [25,25]              #Filter Size in pixels
greylev = []                   #Defaults to 32. Number of gray levels
spatial = []                   #Defaults to 1 (dir invariant)

tex (fili,dbic,filo,dboc,texture,flsz,greylev,spatial)
    
Back to top

Algorithm

The texture measures used by TEX are based on the articles by R.M. Haralick, K. Shanmugan and I. Dinstein; R.M. Haralick; and R. W. Conners and C. A. Harlow. See the Reference section for details on these articles.

In the description of images, pixel color and brightness are commonly used parameters. A less-often used parameter is the texture (graininess). As opposed to color and brightness (which are associated with 1 pixel), texture is computed from a set of connected pixels.

There are several paradigms for measuring texture mathematically. A commonly used one is based on the gray-level co-occurrence matrix (GLCM) (also called gray-level dependency matrix in the literature). A GLCM is a two-dimensional histogram of gray levels for a pair of pixels (Ref,Nbr), separated by a fixed spatial relationship. The GLCM approximates the joint probability distribution of a pair of pixels. Most of the texture measures are computed from GLCM directly. In addition, some texture measures are computed from a gray-level difference vector (GLDV), which itself is derived from a GLCM. If directional invariance of the texture measures is required, the GLCMs with SPATIAL at 4 directions (0, 45, 90, 135 degrees) are summed before texture calculation.

The following example shows a GLCM and a GLDV produced from a 5x5 pixel window with SPATIAL = (0,1) (Nbr is one pixel below the Ref pixel).


      Window of imagery               Resulting co-occurrence matrix

      +---+---+---+---+---+           p         pixel value
      | 4 | 6 | 8 | 5 | 4 |           i
      +---+---+---+---+---+           x      4  5  6  7  8  9
      | 5 | 5 | 8 | 7 | 6 |           e    +-                -+
      +---+---+---+---+---+           l  4 | 0  1  1  0  0  1 |
      | 6 | 7 | 7 | 7 | 9 |              5 | 0  0  1  2  0  0 |
      +---+---+---+---+---+           v  6 | 0  1  1  0  1  1 |
      | 8 | 8 | 4 | 8 | 6 |           a  7 | 1  0  0  1  2  0 |
      +---+---+---+---+---+           l  8 | 0  1  0  1  2  1 |
      | 9 | 8 | 9 | 5 | 6 |           u  9 | 0  0  1  0  0  0 |
      +---+---+---+---+---+           e    +-                -+

    

TEX will start in the top-left corner and count the occurrences of each reference pixel (Ref) to neighbor pixel (Nbr) relationship. For example, the first relationship is 4 (Ref) to 5 (Nbr), the second relationship is 6 (Ref) to 5 (Nbr), and so on. The co-occurrence matrix lists the number of occurrences of each relationship. For example, the (Ref,Nbr)=(7,8) relationship occurs twice, and the (8,7) relationship occurs once. Therefore the (7,8) element of the GLCM is set to 2 while the (8,7) element is set to 1. Note this type of GLCM is asymmetric. TEX actually uses a symmetric GLCM, which is the sum of the asymmetric co-occurrence matrix with its transpose.

The GLDV counts the occurrence of reference-to-neighbor pixel absolute differences. Element 0 of the GLDV is the number of times the difference is 0 (the neighbor pixel value equals the reference pixel value), element 1 the number of times the absolute difference is 1 (the reference minus neighbor pixel value is 1 or +1), and so forth. The GLDV is derived from the GLCM by adding the matrix elements in lines parallel to the main diagonal. For the imagery window in the example above, the GLDV is:


      absolute difference | GLDV element
      +-------------------+------------+
      0            |      4
      1            |      7
      2            |      4
      3            |      4
      4            |      0
      5            |      1

    

This GLDV shows that the absolute difference between the reference and neighbor pixel is 5 in only one case (Ref=4, Nbr=9).

For a local window size FLSZX by FLSZY and spatial vector SPATIAL = (DX,DY), the total number of pixel pairs used to build the GLCM is 2*(FLSZX-|DX|)*(FLSZY-|DY|). This is also the sum of all the elements in GLCM. If the input image has N gray levels, the square GLCM has N**2 elements. For a typical N (such as N=256) and a small window, the resulting GLCM will be very sparse. To obtain a GLCM that adequately reflects the joint probability distribution, the GLCM must contain a reasonably large average occupancy level. This requires a lower number of gray levels and a large window size. For this reason, TEX performs a pre-scaling to reduce the number of gray levels of input image to GREYLEV. An histogram equal-area scaling method is used. This scaling method efficiently uses the GREYLEV level dynamic range while preserving the shape of the original histogram. It is also robust against a small amount of extreme outliers in the input image.

The texture of an image is related to the gray-level joint probability distribution, which is approximated by the co-occurrence matrix. In particular, the amount of dispersion that the GLCM elements have about the diagonal characterizes the texture of the local region. A small dispersion means that the texture is coarse compared to the length of the spatial relationship SPATIAL; that is, the texture elements are larger than this length in the direction of SPATIAL.

The different texture measures supported by TEX are listed below, where:

Homegeneity

SUM(i,j=0,N-1)(P(i,j)/(1+(i-j)**2))

Homogeneity is high when GLCM concentrates along the diagonal. This occurs when the image is locally homogeneous in the scale of the length of SPATIAL.

Contrast

SUM(i,j=0,N-1)(P(i,j)*(i-j)**2)

Contrast is the opposite of Homogeneity. It is a measure of the amount of local variation in the image. It is high when the local region has a high contrast in the scale of SPATIAL.

Dissimilarity

SUM(i,j=0,N-1)(P(i,j)*|i-j|)

Similar to Contrast. High when the local region has a high contrast.

Mean

Mean_i = SUM(i,j=0,N-1)(i*P(i,j))

Average gray-level in the local window.

Standard Deviation

Var_i = SUM(i,j=0,N-1)(P(i,j)*(i - Mean_i)**2)
    Std. Deviation_i = SQRT(Var_i)

Gray-level standard deviation in the local window. High when there is a large gray-level standard deviation in the local region.

Entropy

SUM(i,j=0,N-1)(-P(i,j) * LOGe(P(i,j))),  assuming that 0 * LOGe(0) = 0.

Entropy is high when the elements of GLCM have relatively equal values. It is low when the elements are close to either 0 or 1 (that is, when the image is uniform in the window).

Angular Second Moment

SUM(i,j=0,N-1)(P(i,j)**2)

This is the opposite of Entropy. It is high when the GLCM has few entries of large magnitude, low when all entries are almost equal. This is a measure of local homogeneity.

Correlation

SUM(i,j=0,N-1)(P(i,j)*(i-Mean_i)*(j-Mean_j))/SQRT(Var_i * Var_j)

Correlation measures the linear dependency of gray levels of neighboring pixels. When the scale of local texture is much larger than the distance of SPATIAL, correlation is typically high. When the local texture has a scale similar to or smaller than SPATIAL, there will be low correlation between pairs of pixels (apart by SPATIAL).

GLDV Angular Second Moment

SUM(k=0,N-1)(V(k)**2)

Similar to Angular Second Moment, it measures the local homogeneity. High when some elements are large and the remaining ones are small.

GLDV Entropy

SUM(k=0,N-1)(-V(k)*LOGe(V(k)), assuming that 0*LOGe(0)= 0

This is the opposite of GLDV Angular Second Moment. High when all elements have similar value.

GLDV Mean

SUM(k=0,N-1)(V(k)*k)

GLDV Mean is mathematically equivalent to the Dissimilarity measure above. It is available for compatibility reasons.

GLDV Contrast

SUM(k=0,N-1)(V(k) * k**2)

GLDV Contrast is mathematically equivalent to the Contrast measure above. It is available for compatibility reasons.

Inverse Difference

SUM(i,j=0,N-1)P(i,j)/|i-j|**2, for i!=j

Measures image homogeneity. It is high when most of the occurrences in the GLCM are concentrated near the main diagonal.

As shown above, some of the textural measures relate to specific textural characteristics of the image, such as the texture element size and the contrast. Others characterize the complexity and nature of gray-level transitions that occur in the image. Although these features contain information about the textural characteristics of the image, it is difficult (if not impossible) to identify which specific textural characteristic is represented by each of these features. To solve a specific problem (for example, to separate forest from maize fields in a radar image on ground of a different texture), the usual approach is to compute all different texture measures and to use the measure which provides the best result (for the example above, the best separation between forest and maize fields).

A number of papers have considered which textural measures are preferred. Further reading and additional references can be found in the following papers:
Back to top

References

Clausi, D.A. (2002) "An analysis of co-occurrence texture statistics as a function of gray-level quantization". Canadian Journal of Remote Sensing. Vol. 28, No. 1. pp. 45-62.

Soh, and Tsatsoulis, C. (1999) "Texture analysis of SAR sea ice imagery using gray level co-occurrence matrices" IEEE Trans. Geoscience Remote Sensing. vol. 37, no. 2. pp. 780-795.

R.M. Haralick, K. Shanmugan and I. Dinstein. (November 1973) "Textural features for image classification" IEEE Trans. on systems. Man, and cybernetics. Vol SMC-3, No. 6. pp. 610-621.

R.M. Haralick. (May 1979) "Statistical and structural approaches to Texture" Proceedings of the IEEE. Vol. 67, No. 5. pp. 786-804.

R. W. Conners and C. A. Harlow. (May 1980) "A theoretical comparison of texture algorithms" IEEE Trans. on pattern analysis and machine intelligence. Vol PAMI-2, No. 3

© PCI Geomatics Enterprises, Inc.®, 2024. All rights reserved.