-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslwt53.m
executable file
·80 lines (70 loc) · 2.33 KB
/
slwt53.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
function coef=slwt53(frame,level)
%slwt53 Lifting 53 wavelet transform
%
%
% Example:
%
% coef=slwt53(frame);
%
% frame(height, width)
%
% -----------------------------------------------------------------
% slwt53.m Minoru Hiki. 06/06/13
[height width]=size(frame);
for i=1:level
hb=ceil(height/2^(i-1));
wb=ceil(width/2^(i-1));
frame(1:hb,1:wb)=trx(frame(1:hb,1:wb));
end
coef=frame;
function coef=trx(frame)
[height width]=size(frame);
frame = double(frame);
% horizontal
if rem(width,2)==0
% predict
frame(:,2:2:width-2)=frame(:,2:2:width-2)-...
floor((frame(:,1:2:width-3)+frame(:,3:2:width-1))/2);
frame(:,width)=frame(:,width)-frame(:,width-1);
% update
frame(:,1)=frame(:,1)+floor((frame(:,2)+1)/2);
frame(:,3:2:width-1)=frame(:,3:2:width-1)+...
floor((frame(:,2:2:width-2)+frame(:,4:2:width)+2)/4);
else
% predict
frame(:,2:2:width-1)=frame(:,2:2:width-1)-...
floor((frame(:,1:2:width-2)+frame(:,3:2:width))/2);
% update
frame(:,1)=frame(:,1)+floor((frame(:,2)+1)/2);
frame(:,3:2:width-2)=frame(:,3:2:width-2)+...
floor((frame(:,2:2:width-3)+frame(:,4:2:width-1)+2)/4);
frame(:,width)=frame(:,width)+...
floor((frame(:,width-1)+1)/2);
end
% vertical
if(rem(height,2)==0)
% predict
frame(2:2:height-2,:)=frame(2:2:height-2,:)-...
floor((frame(1:2:height-3,:)+frame(3:2:height-1,:))/2);
frame(height,:)=frame(height,:)-frame(height-1,:);
% update
frame(1,:)=frame(1,:)+floor((frame(2,:)+1)/2);
frame(3:2:height-1,:)=frame(3:2:height-1,:)+...
floor((frame(2:2:height-2,:)+frame(4:2:height,:)+2)/4);
else
% predict
frame(2:2:height-1,:)=frame(2:2:height-1,:)-...
floor((frame(1:2:height-2,:)+frame(3:2:height,:))/2);
% update
frame(1,:)=frame(1,:)+floor((frame(2,:)+1)/2);
frame(3:2:height-2,:)=frame(3:2:height-2,:)+...
floor((frame(2:2:height-3,:)+frame(4:2:height-1,:)+2)/4);
frame(height,:)=frame(height,:)+...
floor((frame(height-1,:)+1)/2);
end
hb=round(height/2);
wb=round(width/2);
coef(1:hb,1:wb)=frame(1:2:height,1:2:width);
coef(1:hb,wb+1:width)=frame(1:2:height,2:2:width);
coef(hb+1:height,1:wb)=frame(2:2:height,1:2:width);
coef(hb+1:height,wb+1:width)=frame(2:2:height,2:2:width);