(Dark good director ....) SOURCE one)
Because the texture is formed by the repeated appearance of the gray scale distribution in the spatial position, there is a certain gray relation between two pixels separated by a distance in the image space, that is, the spatial correlation characteristic of the gray level in the image. Gray-scale co-occurrence matrix is a common method to describe textures by studying the spatial correlation characteristics of gray scale.
Gray-level co-occurrence Matrix from an image
Gray-scale symbiosis matrix of images
Gray-scale co-occurrence matrix is a matrix function of pixel distance and angle, which can reflect the comprehensive information of the image in direction, interval, amplitude and speed by calculating the correlation between the two-point gray scale of certain distance and certain direction in the image.
How to use:
GLCM = Graycomatrix (I)
GLCMs = Graycomatrix (I,param1,val1,param2,val2,...)
[Glcms,si] = Graycomatrix (...)
Describe:
GLCMs = Graycomatrix (i) produces the gray-scale symbiosis matrix GLCM of image I. It is calculated by calculating the number of times that the two grayscale values are horizontally adjacent in the image I (and not necessarily the number of horizontal neighbors, this parameter is adjustable and may be adjusted by offsets, such as [0 d] represents the horizontal direction, [-d] represents the upper right 45 degree direction, [-D 0] represents the vertical direction, That is, 90 degrees, while [-d-d] represents the upper-left corner, or 135-degree direction, and each element in GLCM (I,J) represents the number of times the grayscale I is horizontally adjacent to the grayscale J in the image.
Because the GLCM interval of the dynamically obtained image is too expensive, we first convert the gray value to the gray range of I. If I is a binary image, then the grayscale symbiosis Matrix transforms the image to level two. If I is a grayscale image, it will be converted to level 8. The scale of the grayscale determines the size of the GLCM. You can specify the level of grayscale by setting the parameter "Numlevels", or you can set the "graylimits" parameter to convert the gray-scale symbiosis matrix.
Shows how to solve the gray-scale symbiosis matrix, for example, the GLCM (max) value of 1 indicates that only a pair of pixels with a grayscale of 1 are horizontally adjacent. The GLCM value is 2 because there are two pixels horizontally adjacent to grayscale 1 and 2.
( here is a few nonsense, the left is your grayscale grading of the image, the right is you follow the eight-level statistical matrix
GLCMs = Graycomatrix (I,param1,val1,param2,val2,...) returns one or more grayscale-gray symbiosis matrices, based on the specified parameters. Parameters can be short and insensitive to case.
Parameters
' Graylimits ' is a vector of two elements, representing the extent of the grayscale map in the image, and if it is set to [], the grayscale symbiosis matrix will use the minimum and maximum gray values of the image I as Graylimits
' Numlevels ' An integer that represents the grayscale in the image to a range. For example, if Numlevels is 8, it means that the grayscale of image I is mapped to between 1 and 8, and it also determines the size of the gray-scale symbiosis matrix.
' Offset ' above has an explanation, is a p*2 integer matrix, d represents the distance between the current pixel and the neighbor, by setting the D value, you can set the angle
Angle Offset
0 [0 D]
[d]
[-D 0]
135 [-d-d]
When setting the parameter offset, offsets, on this basis, 0 for the adjacent level, 45 for the adjacent diagonal, 90 for the next top and bottom, 135 the same
.................. GLCM = Graycomatrix (I)
Create a grayscale symbiosis matrix GLCM from image i. By calculating how frequently the pixels with gray level I and gray level J appear in the horizontal direction. Each element in the GLCM describes the number of times the adjacent pixel pairs appear horizontally. If the grayscale level is L then the dimension of GLCM is l*l.
2.glcms = Graycomatrix (i,param1,val1,param2,val2,...)
returns one or more gray-level symbiosis matrices based on the setting of the parameter pair.
parameter Description:
' graylimits ': grayscale bounds, two-yuan vector [low high]. The grayscale value is less than or equal to low when the corresponding 1, greater than or equal to high is corresponding to the grayscale level. If the argument is set to [], the Symbiosis matrix uses the minimum and maximum grayscale values of the image as the bounds, which is [min (i (:)) max (I (:))].
' numlevels ': Integer that indicates the number of grayscale scales in which I was scaled. For example, if Numlevel is set to 8, the co-occurrence matrix scales the grayscale values in I so that they are integers between 1 and 8. The number of gray levels determines the size of the symbiosis Matrix GLCM. Default: Digital Image: 8; binary Image: 2.
' Offset ': P-row 2-column integer matrix that describes the distance between the pixel of interest and its neighboring pixels. Each line is a two-element vector that describes the offset between pixel pairs [Row_offset, Col_offset]. The line offset Row_offset is the number of interval lines between the pixel of interest and its neighboring pixels. The same is the column offset. The offset is often expressed as an angle, and the commonly used angle is as follows: (where D is the pixel distance)
Angle 0 135
Offset [0,d] [D-D] [-D 0] [-d-d]
3.[glcms,si] = Graycomatrix (...)
returns the scaled image Si,si is used to calculate the gray-scale symbiosis matrix. The element value in SI is between 1 and the number of gray levels.
graycoprops: Get various properties of gray-scale symbiosis matrix
stats = graycoprops (GLCM, properties): Calculates static properties from the grayscale symbiosis Matrix GLCM. GLCM is an effective gray-scale symbiosis matrix of m*n*p. If GLCM is a matrix of gray-scale symbiosis matrices, then stats is a matrix that includes the static properties of each gray-scale symbiosis matrix.
Graycoprops normalized the gray-scale symbiosis matrix, so the sum of the elements is 1. The elements in the normalized GLCM (R,C) are the joint probabilities of pixel pairs that have a spatial relationship defined by the gray level R and C. Graycoprops uses the normalized GLCM to calculate the properties.
The attribute parameters are as follows:
1. ' Contrast ': contrast ratio. Returns the brightness contrast between the pixel in the entire image and its neighboring pixels. Range of values: [0, (GLCM-1) ^2]. Grayscale-consistent image with a contrast of 0.
2. ' Correlation ': related. Returns a measure of how the pixels in the entire image are related to their neighboring pixels. Value range: [ -1,1]. Grayscale-consistent images with a correlation of Nan.
3. ' Energy ': power. Returns the sum of the squares of the elements in GLCM. Value range: [0 1]. Grayscale-Consistent image energy is 1.
4. ' Homogemeity ': homogeneity. Returns the distribution of elements in the measure GLCM to the diagonal tightness. Value range: [0 1]. Homogeneity of the diagonal matrix is 1.
........ The code has a specific distance parameter, set whether we take the pixel point should be adjacent or what ... ..... ..... ..... ..... ..... ..... ..... ..... ...............
.......................................................................................................
Example:
Calculates the gray-scale symbiosis matrix, and returns the scaled image, SI
I = [1 1 5 6 8 8; 2 3 5 7 0 2; 0 2 3 5 6 7];
[Glcm,si] = Graycomatrix (I, ' Numlevels ', 9, ' G ', [])
Gray-scale symbiosis matrix for computing gray-scale images
I = Imread (' circuit.tif ');
GLCM = Graycomatrix (I, ' Offset ', [2 0]);
Characteristics of gray-scale symbiosis matrix:
Angular second-order moment (Angular Second moment, ASM)
Asm=sum (P (i,j). ^2) P (i,j) refers to the gray-scale symbiosis matrix after normalization
The second-order moment is a measure of the uniformity and the texture thickness of the image, and when the texture of the image is finely twisted and the gray distribution is uniform, the energy value is larger and vice versa.
Entropy (Entropy, ENT)
Ent=sum (P (i,j) * (-ln (P (i,j)))
is a measure of the amount of information that the image has, indicating that the complex program of the image, when the complexity of the program is high, the entropy value is large, and vice versa is smaller.
Contrast matrix (inverse differential moment, IDM)
Idm=sum (P (i,j)/(1+ (I-J) ^2))
It reflects the degree of clarity and regularity of the texture, the texture is clear, regular, easy to describe, the value is large, disorganized, difficult to describe, the value is small.
Use the Symbiosis matrix to get other features:
(1) Contrast: Also known as contrast, the value of the measurement matrix is how the distribution and local changes in the image, reflects the sharpness of the image and texture of the groove depth. The deeper the groove of the texture, the greater the contrast, the effect is clear, on the contrary, the ratio is small, the groove is shallow, the effect is blurred.
(2) Energy: the sum of squares of the values of each element of the gray-scale symbiosis matrix is a measure of the stability of the gray-scale change of the image texture, which reflects the uniformity of gray distribution and the texture thickness of the image. A large energy value indicates that the current texture is a more stable texture of the rule change.
(3) Entropy: Is the randomness measure of the information contained in the image. When all the values in the Symbiosis matrix are equal or the pixel values exhibit the greatest randomness, the entropy is the most, so the entropy value indicates the complexity of the image gray distribution, the larger the entropy value, the more complex the image.
(4) Correlation: Also known as homogeneity, to measure the image of gray level in line or column direction similarity, so the value of the size of the response to local gray correlation, the greater the value, the greater the correlation.
Gray-scale symbiosis matrix of texture feature of image