forked from ManosijGhosh/Scene-Text-Recognition
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheHOG.m
46 lines (27 loc) · 820 Bytes
/
eHOG.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
function ehog = eHOG(matrix)
w1 = 0;
w2 = 0;
w3 = 0;
w4 = 0;
x = bwboundaries(matrix,'noholes');
list = x{:};
for i = 2:(numel(list)/2)
x1 = list(i,1);
y1 = list(i,2);
x2 = list((i-1),1);
y2 = list((i-1),2);
if ((x1 == x2+1) && (y1 == y2)) || ((x1 == x2+1) && (y1 == y2-1))
w1 = w1+1;
end
if ((x1 == x2) && (y1 == y2-1)) || ((x1 == x2-1) && (y1 == y2-1))
w2 = w2 + 1;
end
if ((x1 == x2-1) && (y1 == y2)) || ((x1 == x2-1) && (y1 == y2+1))
w3 = w3 + 1;
end
if ((x1 == x2) && (y1 == y2+1)) || ((x1 == x2+1) && (y1 == y2+1))
w4 = w4 + 1;
end
end
ehog = (sqrt((w1-w3)^2 + (w2-w4)^2))/((numel(list)/2) - 1);
end