A list,

The statistical method of gray co-occurrence matrix (GLDM) was proposed by R.Haralick et al in the early 1970s. It is a broad texture analysis method based on the assumption that the spatial distribution relationship between pixels in an image contains the image texture information.

Grayscale co-occurrence matrix is defined as the probability of grayscale co-occurrence matrix starting from the pixel with grayscale of I and leaving the point with fixed position (distance d and orientation is). In other words, all estimated values can be expressed in the form of a matrix, which is called grayscale co-occurrence matrix. For images with slow texture change, the value on the diagonal of the gray level co-occurrence matrix is larger. For the image with fast texture change, the value on the diagonal of the gray level co-occurrence matrix is small, and the value on both sides of the diagonal is large. Due to the large amount of data in the gray level co-occurrence matrix, it is generally not directly used to distinguish texture features, but some statistics constructed based on it as texture classification features. Haralick once proposed 14 kinds of statistics calculated based on gray level co-occurrence matrix, namely, energy, entropy, contrast, uniformity, correlation, variance, sum average, sum variance, sum entropy, difference variance, difference average, difference entropy, correlation information measure and maximum correlation coefficient.

On the Internet to see a lot of examples of gray level symbiosis matrix generation feeling did not say clearly, or directly on the result or to a pile of code and formula do not understand, then read the introduction of MATLAB to understand, in fact, very simple, carefully read the following three times to understand how to come! (I read the third article, was very nervous, I believe you are ok)

The figure below shows how to solve the gray level co-occurrence matrix. Taking point (1, 1) as an example, the value of GLCM (1, 1) is 1, indicating that only a pair of pixels with gray level 1 are horizontally adjacent. GLCM (1, 2) is 2 because there are two pairs of pixels with gray scales of 1 and 2 horizontally adjacent. (MatLab documentation).



GLCM table is actually the possible combination of all pixels. For example, GLCM (1,1) is the combination of pixel values 1 and 1 in I, GLCM (4,5) is the combination of pixel 4 and pixel 5 in I, and the value of GLCM (I,j) is the number of adjacent paired points with pixel I and pixel J in I. There’s a rule for adjacency: f(x,y),f(x+a,y+b) adjacency, which means only x is separated by a, and y is separated by b, which we consider to be adjacent.

F (x,y) and F (x+1,y+0) are next to each other.

So here it is:

When a=1 and b=0 we say horizontally adjacent: 0 degrees

When a is equal to 1 and b is equal to 1 we say it’s diagonally adjacent, which is 45 degrees

When a is negative 1 and b is 1, 135 degrees

The other angles are similar.

When a=1,b=0: GLCM(1, 1)=1; GLCM(1, 2)=2. GLCM(1, 2)=2. GLCM(1, 2)=2. Ok!

Behind a lot of properties, are in the matrix after the calculation of the calculation on this basis, those are not difficult!

Additional Understanding 2:

The co-occurrence matrix is defined by the joint probability density of pixels at two positions. It not only reflects the distribution characteristics of brightness, but also reflects the location distribution characteristics of pixels with the same brightness or close to brightness. It is a second-order statistical feature of image brightness changes. It is the basis for defining a set of texture features.

Since texture is formed by repeated occurrence of gray scale in spatial position, there will be a certain gray scale relationship between two pixels of a certain distance in the image space, that is, the spatial correlation characteristics of gray scale in the image. Gray co-occurrence matrix is a common method to describe texture by studying the spatial correlation characteristics of gray.

Gray histogram is the statistical result of a certain gray level of a single pixel in an image.

Gray level co-occurrence matrix is obtained by statistical analysis of the condition that two pixels with a certain distance on the image have a certain gray level respectively. Take any point (x, y) in the image (N×N) and the other point (x+a, y+b) that deviates from it, and set the gray value of the point pair as (G1, G2). If the point (x, y) moves on the whole screen, various (G1, G2) values will be obtained. Let the series of gray values be K, then the combination of (g1, G2) has a total of K ^2. Kind of. For the whole picture, the number of occurrences of each (g1, G2) value is counted and then arranged into a square matrix. The total number of occurrences of (g1, G2) values is used to normalize them into the probability of occurrence P (G1, G2). Such square matrix is called gray level co-occurrence matrix. The joint probability matrix under different conditions can be obtained by taking different numerical combinations of the distance difference score (a, b). The value of (a, b) should be selected according to the characteristics of texture periodic distribution. For fine texture, small difference points such as (1,0), (1,1) and (2,0) should be selected. When a=1, b=0, the pixel pair is horizontal, that is, 0 degree scan; When a=0, b=1, the pixel pair is vertical, that is, 90 degree scan; When a=1, b=1, the pixel pair is right diagonal, that is, 45 degree scan; When a=-1, b=-1, the pixel pair is left diagonal, i.e. 135 degree scan. In this way, the probability of the gray levels of two pixels occurring at the same time transforms the spatial coordinates of (x, y) into the description of “gray level pairs” (G1, G2), forming the gray level co-occurrence matrix. The gray level co-occurrence matrix of an image can reflect the comprehensive information of the gray level of the image about the direction, the adjacent interval and the amplitude of change. It is the basis of analyzing the local patterns and their arrangement rules of the image. That feels like it!

2. Characteristic quantity of gray co-occurrence matrix

Gray level co-occurrence matrix eigenvalue

2.1 contrast

How the values of the metric matrix are distributed and how much the local changes in the image reflect the sharpness of the image and the furrow depth of the texture. The deeper the groove of the texture, the greater the contrast, the clearer the effect; On the contrary, the small ratio, shallow groove, fuzzy effect.



2.2 energy

The energy transformation reflects the uniformity of image gray distribution and texture fineness. If the element values of gray co-occurrence matrix are similar, the energy is small and the texture is delicate. If some of these values are large and others are small, the energy value is large. Large energy values indicate a more uniform and regular texture pattern.



2.3 the entropy

The randomness measure of the amount of information contained in an image. When all values in the co-occurrence matrix are equal or the pixel values show the maximum randomness, the entropy reaches the maximum. Therefore, the entropy value indicates the complexity of image gray distribution. The larger the entropy value is, the more complex the image is.



2.4 the inverse variance

The inverse variance reflects the size of the local change of the image texture. If the different regions of the image texture are more uniform and the change is slow, the inverse variance will be larger, and vice versa.



2.5 correlation

It is used to measure the similarity degree of image gray level in row or column direction, so the value reflects the local gray level correlation, and the larger the value is, the greater the correlation is.

Ii. Source code

function varargout = td(varargin)
% TD M-file for td.fig
%      TD, by itself, creates a new TD or raises the existing
%      singleton*.
%
%      H = TD returns the handle to a new TD or the handle to
%      the existing singleton*.
%
%      TD('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in TD.M with the given input arguments.
%
%      TD('Property'.'Value',...). creates anew TD or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before td_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to td_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one % instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Copyright 2002- 2003. The MathWorks, Inc.

% Edit the above text to modify the response to help td

% Last Modified by GUIDE v2. 5 12-May- 2015. 11:29:39

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @td_OpeningFcn, ...
                   'gui_OutputFcn',  @td_OutputFcn, ...
                   'gui_LayoutFcn', [],...'gui_Callback'[]);if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before td is made visible.
function td_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to td (see VARARGIN)

% Choose default command line output for td
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes td wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = td_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes on button press in open1.
function open1_Callback(hObject, eventdata, handles)
% hObject    handle to open1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global im1
[filename,pathname]=uigetfile({'*.jpg';'*.bmp';'*.tif';'*.png'},'select picture'); %      §     §  %      §     §   STR = [the pathname filename]; %         im1 = imread (STR); % axes
axes(handles.axes1);
imshow(im1);


% --- Executes on button press in open2.
function open2_Callback(hObject, eventdata, handles)
% hObject    handle to open2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global im2
[filename,pathname]=uigetfile({'*.jpg';'*.bmp';'*.tif';'*.png'},'select picture'); %      §     §  %      §     §   STR = [the pathname filename]; %         im2 = imread (STR); % axes
axes(handles.axes2); imshow(im2); % -- Executes on button press in... Handles) % hObject handle to (see GCBO) % eventdata reserved - to be defined in afuture version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in junhenghua.
function junhenghua_Callback(hObject, eventdata, handles)
% hObject    handle to junhenghua (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global im1
global im2
%im1=~im1;
%im1=bwmorph(im1,'thin',Inf);
%th1=graythresh(im1);
%im1=im2bw(im1,th1);
im1=histeq(im1);
axes(handles.axes1);
imshow(im1);
%im2=double(im2);
%im2=histeq(im2);
%th2=graythresh(im2);
%im2=im2bw(im2,th2);
im2=histeq(im2);
axes(handles.axes2);
imshow(im2);

% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in huiduhua.
function huiduhua_Callback(hObject, eventdata, handles)
% hObject    handle to huiduhua (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global im1
global im2
%[d1,d2,d3] = size(im1); 
%if(d3 > 1) 
im1=rgb2gray(im1);
%end
%im1= double(im1) / 255; 
%im1= uint8(255 * im1* 0.5 + 0.5); 
%th=graythresh(im1);
%im1=im2bw(im1,th);
axes(handles.axes1);
imshow(im1);
im2=rgb2gray(im2);
%th=graythresh(im2);
%im2=im2bw(im2,th);
axes(handles.axes2);
imshow(im2);

% --- Executes during object creation, after setting all properties.
function text1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to text1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called




% --- Executes on button press in quzao.
function quzao_Callback(hObject, eventdata, handles)
% hObject    handle to quzao (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global im1
global im2
%im1=double(im1);
im1=medfilt2(im1);
axes(handles.axes1);
imshow(im1);
%im2=double(im2);
im2=medfilt2(im2);
axes(handles.axes2);
imshow(im2);
Copy the code

3. Operation results



Fourth, note

Version: 2014 a