The symbiotic Matrix Method of texture description is based on the repeated appearance of a gray-level structure in the texture. This structure rapidly changes with the distance in the fine texture, in rough textures, the changes are slow.
Assume that the image to be analyzed is a m * n rectangular window in the part of the fine-grained image. The appearance of a gray-scale structure can be described by a matrix of relative frequencies. It depicts two pixels with gray-scale A and B, and the distance between them is D at the direction of, the frequency at which it appears in the window.
How to obtain the symbiotic matrix:
There are two definitions. The first one in the book is the definition of the symmetric matrix, as follows:
The non-symmetric matrix used by my program is defined as follows:
Oh, I think these formulas are not so easy to understand, but the figure below will make you clear at a glance. Diameter = 0, D = 1.
After the symbiotic matrix is generated, you need to use the derived criterion.
There are six types:
1. Energy, or second moment of angle (measure of image uniformity-the more even the image is, the greater the value ):
2. entropy:
3. maximum probability:
4. Contrast (measure of local image changes; typical K = 2, λ = 1 ):
5. Reciprocal difference moment:
6. Correlation (the measurement of the linearity of the image, the structure of the linear direction on the direction Phi will produce a large correlation value in this direction ):
Where μ X, μ Y is the mean, and σ X, σ Y is the standard deviation,
The general algorithm is as follows:
1. Build a symbiotic matrix with given directions and distances.
2. texture feature vectors are constructed using the direction, distance, and six feature values, which generates relevant features.
Below is the MATLAB source code:
Main. m
Clear all; close all;clc;fai%0%d%1%img%imread('lena.jpg '); [m n] = size (IMG); k = 1; for I = 1: 10: m-10 % Take 10*10 images, here I casually wrote, accurate is one by one to take 10*10 for j = 1: 10: N-10 re {k} = comatrix (IMG (I: I + 9, j: J + 9), Fai, d); k = k + 1; endendfor J = s = []; % for I = 1: k-1 S = [s re {I} (j)]; end figure; plot (s) End
Comatrix. m
Function Re = comatrix (D, Fai, d) [m n] = size (d); MA = max (D (:)); MI = min (D (:)); D = D-MI + 1; % unify the minimum value to 1 k = ma-MI + 1; % generate a suitable size co-occurrence matrix P = zeros (K, k ); if Fai = 0 h = 0; W = D; elseif Fai = 45 h = D; W = D; elseif Fai = 90 H = D; W = 0; else h = D; W =-D; end if Fai ~ = 135 for I = 1: M-H for j = 1: N-w p (d (I, j), D (I + H, J + W )) = P (d (I, j), D (I + H, J + W) + 1; end else for I = 1: M-H for J = 1-w: n p (d (I, j), D (I + H, J + W) = P (d (I, j), D (I + H, J + W) + 1; end if sum (P (:))~ = 0 p = P/sum (P (:)); % normalization Matrix end % RE is eight feature values Re = zeros (); Re (1) = Fai; % direction feature re (2) = D; % step feature re (3) = sum (P (:). ^ 2); % energy feature re (4) = max (P (:)); % maximum probability feature miux = sum (double (1: K ). * sum (P (1: K, :)); miuy = sum (double (1: K ). * sum (P (:, 1: K); sigmax = sum (double (1: k)-miux ). ^ 2. * sum (P (1: K, :)); sigmay = sum (double (1: k)-miuy ). ^ 2. * sum (P (:, 1: K); for I = 1: K for j = 1: K if P (I, j )~ = 0 Re (5) = Re (5) + P (I, j) * log2 (P (I, j); % entropy feature end re (6) = Re (6) + (I-j ). ^ 2 * P (I, j); % contrast feature if I ~ = J Re (7) = Re (7) + P (I, j)/ABS (I-j); % reciprocal difference Moment Feature end re (8) = Re (8) + I * j * P (I, j); end if sigmax * sigmay ~ = 0 Re (8) = (RE (8)-miux * miuy)/(sigmax * sigmay); % correlation feature endend
The RE in comatirx. m is the feature vector of the current texture, eight descriptors.
The final result is a curve.
Refer:
Http://matlab.izmiran.ru/help/toolbox/images/graycomatrix.html