Gray-scale symbiosis matrix of images

Source: Internet
Author: User

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.

The following figure shows how to solve a gray-scale symbiosis matrix, with the (GLCM) point as an example, the 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.

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]

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.

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.