Image feature operator--the principle analysis and implementation of gray-scale symbiosis matrix (eight)

Source: Internet
Author: User

image feature operator--the principle analysis and implementation of gray-scale symbiosis Matrix (eight)

[Email protected]

Http://blog.csdn.net/kezunhai

The gray-scale co-occurrence matrix was first proposed by Robert M. in the early stage, known as the gray Space dependency matrix (Gray-tone spatial-dependence matrices), in which 28 texture features can be calculated according to the Gray Space dependence matrix. For more information, refer to: Textural Features for Image classification. 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.

The Gray-scale symbiosis matrix, defined as the joint distribution probability of pixel pairs, is a symmetric matrix which not only reflects the comprehensive information of the image grayscale in the neighboring direction, the adjacent interval and the amplitude of variation, but also reflects the location distribution characteristics between the same gray-level pixels, and is the basis of the computational texture feature. set F (x, y) as a digital image with a size of MXN and a gray level of NG, the gray-scale symbiosis matrix that satisfies a certain spatial relationship is:


where # (x) represents the number of elements in the set X, obviously p is the matrix of Ngxng, if (x1,y1) and (x2,y2) between the distance is D, both and the coordinates of the horizontal axis angle is θ, you can get a variety of spacing and angle of the gray-scale co-occurrence matrix (i,j,d,θ). The value of the element (I,J) represents a grayscale of I and another two pixels with a gray scale of j that appear in the direction of the angle. Often, we use in the four-direction of 0°, 45°, 90° and 135° symbiosis Matrix, the formula is as follows:


To further understand the calculation of the gray-scale symbiosis matrix, the following is an example of a 4x4 image block that quantifies grayscale to 0~3 and positional relationships:

                           ,         &NB Sp                                   block                          ,         &NB Sp                                 position represents


Its grayscale matrix is:


In turn we can get the matrix of four directions (here distance d=1):


Here the simple calculation of the # (0,0) at 0° is done with the following description: For the image block, there is the first line of the (0,0) relationship (n), (n), the second line (2,1), (2,2) and (2,2), and (2,1), the value is 4; 1,0) (1,3), (() and (2,,3), (2,2), the value is 2.

through the above introduction, we calculate the symbiosis matrix, often is not directly applied to calculate the gray-scale co-occurrence matrix, but on the basis of the calculation of texture characteristics, we often use the contrast, energy, entropy, correlation and other features to represent texture characteristics.

1) ASM (angular second moment) characteristics (or energy characteristics )

The formula is calculated as follows:


ASM is the square sum of the values of gray-scale co-occurrence matrix elements, so it is also called energy, which reflects the uniformity of gray distribution and texture thickness of the image. If all the values of the Symbiosis matrix are equal, the ASM value is small; Conversely, if some of the values are large and the other values are small, the ASM value is large. When the elements in the Symbiosis matrix are centrally distributed, the ASM values are large at this time. The ASM value indicates a more homogeneous and regular variation of the texture pattern.

2) Contrast ratio (contrast)

The formula is calculated as follows:


How the value of the contrast metric matrix is distributed and how much of the local variation in the image reflects the sharpness of the image and the depth of the groove of the texture. 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.

3) entropy ( entropy)

The formula is calculated as follows:


entropy is a random measure of the amount of information contained in an image, and texture is information of the image. When all the elements in the Symbiosis matrix have the greatest randomness and all the values in the spatial symbiosis matrix are almost equal, the entropy is larger when the elements in the Symbiosis matrix are distributed. Therefore, the entropy value indicates the complexity of the image gray distribution, the greater the entropy value, the more complex the image.

4) Self-correlation (correlation)

The formula is:


correlation is also called homogeneity, which measures the degree of similarity of the gray level of the image in the direction of rows or columns, so the size of the value reflects the local gray correlation, the greater the value, the greater the correlation. Self-correlation reflects the consistency of image texture. If there is a horizontal orientation texture in the image, the cor of the horizontal direction matrix is greater than the COR value of the remaining matrices. It measures the similarity of the elements in the row or column direction of the spatial gray-scale symbiotic matrix element, so the correlation value size reflects the local gray-level correlation in the image. When the values of the matrix elements are equal, the correlation values are large; Conversely, if the matrix cell values differ greatly, the correlation values are small.

5) Deficit moment (Idm:inverse difference moment)

The formula is:


The deficit moment reflects the homogeneity of image texture, and measures the local change of image texture. The large value indicates that there is a lack of change between the different regions of the image texture, and the local is very homogeneous. if the diagonal element of the gray-scale symbiosis matrix has a larger value, the IdM will take a larger value. Therefore, successive grayscale images will have larger IDM values.

More information about the eigenvalues of the gray-scale co-occurrence matrix can be found in the reference materials of the greetings, which introduce more than 20 kinds of related features, such as variance, Fangcha, entropy and so on.

If the above features are used as image classification, identification, etc., you can combine the above computed features to form a vector, for example, when the distance difference value (A, a, b) takes four kinds of values, it can be synthesized to obtain the vector:

feature=[asm1, CON1, IDM1, ENT1, COR1, ..., ASM4, CON4, IDM4, ENT4, COR4]

The integrated vector can be regarded as a description of the image texture, which can be further used for classification, identification, retrieval and so on.

Next, to further introduce the implementation of gray-scale co-occurrence matrix (not a description of the difference, not understand the reference):

Enum glcm_direction{glcm_angle_horizontal,glcm_angle_vertical,glcm_angle_digonal45,glcm_angle_digonal135};// Binimage: Grayscale map//Idir: direction, 1--0°, 2--45°,3--90°,4--135°//normalization factor: 0° (2Ny (nx-d), 45° (2 (ny-d) (nx-d), 90° (2NX (ny-d), 135° (2 ( ny-d) (nx-d)//idist:1,2,3,4....//Gray_level: Grayscale level, recommended value 8, 16, 32, 64void CALCGLCM (Iplimage *binimage,vector<double >& features, int idist/* =1 */, Glcm_direction glcmdir/* =glcm_angle_horizontal */, int gray_level/* = +/) {int I, j;int height, width, widthstep;double factor = 0;//normalization factor if (binimage = = NULL) Return;height = Binimage->height;widt H = binimage->width;widthstep = Binimage->widthstep;int *GLCM = new Int[gray_level*gray_level];d ouble *glcmNorm = n  EW Double[gray_level*gray_level]; Normalized value int *histimage = new Int[width*height]; ZeroMemory (GLCM, sizeof (int) *gray_level*gray_level); ZeroMemory (Glcmnorm, sizeof (double) *gray_level*gray_level); ZeroMemory (histimage, sizeof (int) *width*height);//Grayscale quantization to 0-gray_leveluchar* data = (uchar*) binimage-> Imagedata;for (i=0; iIn the above algorithm implementation, the gray-scale co-occurrence matrix is normalized (mainly considering the value of the results of the non-normalized calculation will be relatively large), a simple test, that the calculated data values should be normal,



Resources:

1. Gray-scale Symbiosis matrix

2, textural Features for Image classification.

3. Calculate gray-scale symbiosis matrix GLCM

KezunhaiSource:Http://blog.csdn.net/kezunhaiWelcome to reprint or share, but be sure to declare the source of the article.

Image feature operator--the principle analysis and implementation of gray-scale symbiosis matrix (eight)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.