Repository navigation
Expand file tree
/
Copy pathHTD.m
More file actions
90 lines (76 loc) · 2.4 KB
/
Copy pathHTD.m
File metadata and controls
90 lines (76 loc) · 2.4 KB
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
82
83
84
85
86
87
88
89
90
% Created on Mon May 6 2019
% Authors: Malihe Javidi. Email: m.javidi [at] qiet.ac.ir
% Authors: Mahdi Jampour. Email: jampour [at] icg.tugraz.at
function HTD()
clear; clc;
MyPath = '\Datasets\My_CERUG-EN_IMG\Train\';
Folder = dir(MyPath);
k=0;
Data1 = [];
numClass = 105; % Attention *
for i=1:numClass
disp(i);
Files = dir([MyPath Folder(i+2).name '\']);
sampleNo = length(Files)-2; %size(Files,
for j=1:sampleNo
fprintf('.')
img = imread([MyPath Folder(i+2).name '\' Files(j+2).name]);
k=k+1;
Data1(k, :) = ThickFeat(img);
end
fprintf('\n')
save('\HTDDescriptor\Data_CERUG_Tr.mat' , 'Data1'); % Attention *
end
MaxTot = max(max(Data1));
Data1 = Data1./MaxTot;
save('\HTDDescriptor\Data_CERUG_Tr.mat' , 'Data1'); % Attention *
MyPath = '\Datasets\My_CERUG-EN_IMG\Te_Rand\';
Folder = dir(MyPath);
k=0;
Data1 = [];
numClass = 105; % Attention *
for i=1:numClass
disp(i);
Files = dir([MyPath Folder(i+2).name '\']);
sampleNo = length(Files)-2; %size(Files,
for j=1:sampleNo
fprintf('.')
img = imread([MyPath Folder(i+2).name '\' Files(j+2).name]);
k=k+1;
Data1(k, :) = ThickFeat(img);
end
fprintf('\n')
save('\HTDDescriptor\Data_CERUG_Te.mat' , 'Data1'); % Attention *
end
MaxTot = max(max(Data1));
Data1 = Data1./MaxTot;
save('\HTDDescriptor\Data_CERUG_Te.mat' , 'Data1'); % Attention *
end
function Feat2 = ThickFeat(img)
[R,C,Z] = size(img);
if(Z==3)
img = rgb2gray(img);
end
img = double(imbinarize(img));
Feat = zeros(1, 10);
Feat2 = zeros(1, 9);
for k=1:10
s = k+1;
Ns = 0;
for i=1:R-s
for j=1:C-s
mask = img(i:i+s-1, j:j+s-1);
% Meaning all pixels must be 0
if(sum(sum(mask)) == 0)
Ns = Ns+1;
end
end
end
Feat(1, k) = (Ns);
end
Feat = Feat./(sum(sum(img==0)));
% Compute differential to decrease sensitivity
for i=1:9
Feat2(1, i)=Feat(1, i)-Feat(1, i+1);
end
end