-
Notifications
You must be signed in to change notification settings - Fork 4
/
getGLRLMfeatures.m
81 lines (63 loc) · 2.09 KB
/
getGLRLMfeatures.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
77
78
79
80
81
function features = getGLRLMfeatures(GLRLM)
% 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(GLRLM); % Size of GLRLM
nRuns = sum(GLRLM(:));
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 GLRLM
pg = sum(GLRLM,2)'; % Gray-Level Run-Number Vector
pr = sum(GLRLM); % Run-Length Run-Number Vector
% COMPUTATION OF TEXTURE FEATURES
% 1. Short Run Emphasis (SRE)
features.SRE = (pr*(cVect.^(-2))')/nRuns;
% 2. Long Run Emphasis (LRE)
features.LRE = (pr*(cVect.^2)')/nRuns;
% 3. Gray-Level Nonuniformity (GLN)
features.GLN = sum(pg.^2)/nRuns;
% 4. Run-Length Nonuniformity (RLN)
features.RLN = sum(pr.^2)/nRuns;
% 5. Run Percentage (RP)
features.RP = nRuns/(pr*cVect');
% 6. Low Gray-Level Run Emphasis (LGRE)
features.LGRE = (pg*(rVect.^(-2))')/nRuns;
% 7. High Gray-Level Run Emphasis (HGRE)
features.HGRE = (pg*(rVect.^2)')/nRuns;
% 8. Short Run Low Gray-Level Emphasis (SRLGE)
features.SRLGE = sum(sum(GLRLM.*(rMat.^(-2)).*(cMat.^(-2))))/nRuns;
% 9. Short Run High Gray-Level Emphasis (SRHGE)
features.SRHGE = sum(sum(GLRLM.*(rMat.^2).*(cMat.^(-2))))/nRuns;
% 10. Long Run Low Gray-Level Emphasis (LRLGE)
features.LRLGE = sum(sum(GLRLM.*(rMat.^(-2)).*(cMat.^2)))/nRuns;
% 11. Long Run High Gray-Level Emphasis (LRHGE)
features.LRHGE = sum(sum(GLRLM.*(rMat.^2).*(cMat.^2)))/nRuns;
% New features
GLRLM = GLRLM./nRuns;
pg = sum(GLRLM,2)'; pr = sum(GLRLM);
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 + (GLRLM(g,r)*g-ug)^2;
end
end
GLV = GLV/(sz(1)*sz(2));
features.GLV = GLV;
% 13. Run-Length Variance (RLV)
RLV = 0;
for g = 1:sz(1)
for r = 1:sz(2)
RLV = RLV + (GLRLM(g,r)*r-ur)^2;
end
end
RLV = RLV/(sz(1)*sz(2));
features.RLV = RLV;
end