-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdc_seq_re.m
54 lines (52 loc) · 1.1 KB
/
dc_seq_re.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
function dc = dc_seq_re(Seq, H, W)
dc_prev = 0;
p = 1;
nB = (H*W)/(8*8);
dc = zeros(1,nB);
for i = 1:nB
D = str2num(Seq(p));
if(D==0)
dc_diff = 0;
else
% Decode V:
% Decode Sign of V:
p = p + 1;
D = str2num(Seq(p));
if(D==1)
Sgn = 'neg';
else
Sgn = 'pos';
end
% Decode log2(Sz):
n = 0;
p = p + 1;
D = str2num(Seq(p));
while(D)
n = n + 1;
p = p + 1;
D = str2num(Seq(p));
end
n = n - 1;
if(n==0)
Sz = 1;
elseif(n>0)
%base = 2^n;
Szr = bin2dec(Seq(p+1:p+n));
Sz = Szr + (2^n);
p = p + n;
else
Sz = 0;
end
abdiff = Sz + 1;
if(Sgn=='pos')
dc_diff = abdiff;
else
dc_diff = -abdiff;
end
% dc_diff = V;
end
dc(i) = dc_diff + dc_prev;
dc_prev = dc(i);
p = p + 1;
end
end