-
Notifications
You must be signed in to change notification settings - Fork 4
/
getGLSZMfeatures.m
76 lines (60 loc) · 2 KB
/
getGLSZMfeatures.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
function features = getGLSZMfeatures(GLSZM)
% AUTHOR(S):
% - Lijun Lu <[email protected]>
% - Martin Vallieres <[email protected]>
% -------------------------------------------------------------------------
% HISTORY:
% - Creation: January 2013
% - Revision: May 2015
% - Revision: Oct 2017
% USEFUL MATRICES, VECTORS AND QUANTITIES
sz = size(GLSZM); % Size of GLSZM
nRuns = sum(GLSZM(:));
cVect = 1:sz(2); rVect = 1:sz(1);% Row and column vectors
[cMat,rMat] = meshgrid(cVect,rVect); % Column and row indicators for each entry of the GLSZM
pg = sum(GLSZM,2)';
pr = sum(GLSZM);
% COMPUTATION OF TEXTURE FEATURES
% 1. Small Zone Emphasis (SZE)
features.SZE = (pr*(cVect.^(-2))')/nRuns;
% 2. Large Zone Emphasis (LZE)
features.LZE = (pr*(cVect.^2)')/nRuns;
% 3. Gray-Level Nonuniformity (GLN)
features.GLN = sum(pg.^2)/nRuns;
% 4. Zone-Size Nonuniformity (ZSN)
features.ZSN = sum(pr.^2)/nRuns;
% 5. Zone Percentage (ZP)
features.ZP = nRuns/(pr*cVect');
% 6. Low Gray-Level Zone Emphasis (LGZE)
features.LGZE = (pg*(rVect.^(-2))')/nRuns;
% 7. High Gray-Level Zone Emphasis (HGZE)
features.HGZE = (pg*(rVect.^2)')/nRuns;
% 8. Small Zone Low Gray-Level Emphasis (SZLGE)
features.SZLGE = sum(sum(GLSZM.*(rMat.^(-2)).*(cMat.^(-2))))/nRuns;
% 9. Small Zone High Gray-Level Emphasis (SZHGE)
features.SZHGE = sum(sum(GLSZM.*(rMat.^2).*(cMat.^(-2))))/nRuns;
% 10. Large Zone Low Gray-Level Emphasis (LZLGE)
features.LZLGE = sum(sum(GLSZM.*(rMat.^(-2)).*(cMat.^2)))/nRuns;
% 11. Large Zone High Gray-Level Emphasis (LZHGE)
features.LZHGE = sum(sum(GLSZM.*(rMat.^2).*(cMat.^2)))/nRuns;
% New features
pg = sum(GLSZM,2)'; pr = sum(GLSZM);
ug = (pg*rVect')/(sz(1)*sz(2));
ur = (pr*cVect')/(sz(1)*sz(2));
% 12. Gray-Level Variance (GLV)
GLV = 0;
for g = 1:sz(1)
for r = 1:sz(2)
GLV = GLV + (GLSZM(g,r)*g-ug)^2;
end
end
features.GLV = GLV/(sz(1)*sz(2));
% 13. Zone-Size Variance (ZSV)
ZSV = 0;
for g = 1:sz(1)
for r = 1:sz(2)
ZSV = ZSV + (GLSZM(g,r)*r-ur)^2;
end
end
features.ZSV = ZSV/(sz(1)*sz(2));
end