The Lifting Scheme of High Golden Section Transform By Matlab Part I

This is the lifting scheme of 2d high golden section transform matlab codes:

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
91
92
93
94
95
96
97
98
99
function H = hgst2d(X,nlevel)
 
% Author: Jun Li. Copyright (c) 2015, All rights reserved. 
% more info@ http://goldensectiontransform.com/
% the lifting scheme of 2d high golden section transform
% here matrix X is of Fn*Fn where Fn is a fibonacci number Fn>=2.
 
global hj; % only used by function hgst1d(S) below.
global FBH; % only used by function hgst1d(S) below.
 
[xx,yy] = size(X);
 
ind = floor(log(xx*sqrt(5)+1/2)/log((sqrt(5)+1)/2)); % determine index
FBH = filter(1,[1 -1 -1],[1 zeros(1,ind-1)]);
% FBH = Fibonacci sequence -> [1 1 2 3 5 8...];
 
H=X;
for hj=1:nlevel
 
   for j=1:xx
      [ss,dd] = hgst1d(H(j,1:yy)); % row transform
      H(j,1:yy) = [ss,dd];
   end
 
   for k=1:yy
      [ss,dd] = hgst1d(H(1:xx,k)'); % column transform
      H(1:xx,k) = [ss,dd]';
   end
 
   xx = FBH(end-2*hj); % round((3-sqrt(5))/2*xx); 8*8 block: xx=8->3
   yy = FBH(end-2*hj); % round((3-sqrt(5))/2*yy); 8*8 block: yy=8->3
 
end
 
%% 1d high golden section transform lifting scheme
 
function [ss,dd] = hgst1d(S)
 
%% Author: Jun Li. more info@ http://goldensectiontransform.com/
 
global hj;
global FBH;
 
index = 0;
g = 1;
h = 1;
 
hform = hword(length(S));
 
for i=1:length(hform)
 
   index = index + hform(i);
 
   if hform(i) == 2
 
      % ss(i) = (sqrt(FBH(2*hj-1))*S(index-1)+sqrt(FBH(2*hj))*S(index))/sqrt(FBH(2*hj+1));
      % dd(2*i-g) = (sqrt(FBH(2*hj))*S(index-1)-sqrt(FBH(2*hj-1))*S(index))/sqrt(FBH(2*hj+1));
 
      %% we can use lifting scheme here:
 
      ga = sqrt(FBH(2*hj-1)/FBH(2*hj));
      gb = sqrt(FBH(2*hj-1)*FBH(2*hj))/FBH(2*hj+1);
      gc = sqrt(FBH(2*hj+1)/FBH(2*hj));
 
      d1 = S(index-1) - ga*S(index);
      s1 = S(index) + gb*d1;
      ss(i) = gc*s1;
      dd(2*i-g) = d1/gc;
 
      g = g+1;
 
   else % hform(i) == 3
 
      % ss(i) = (sqrt(FBH(2*hj))*S(index-2)+sqrt(FBH(2*hj-1))*S(index-1)+sqrt(FBH(2*hj))*S(index))/sqrt(FBH(2*hj+2));
      % dd(i+h-1) = (sqrt(FBH(2*hj-1))*S(index-2)-2*sqrt(FBH(2*hj))*S(index-1)+sqrt(FBH(2*hj-1))*S(index))/sqrt(2*FBH(2*hj+2));
      % dd(i+h) = (S(index-2)-S(index))/sqrt(2);
 
      %% we can use lifting scheme here:
 
      td1 = S(index-2) - S(index);
      ts1 = S(index) + 1/2*td1;
      tss = sqrt(2)*ts1;
      tdd = td1/sqrt(2);
 
      ha = sqrt(2*FBH(2*hj)/FBH(2*hj-1));
      hb = sqrt(2*FBH(2*hj-1)*FBH(2*hj))/FBH(2*hj+2);
      hc = sqrt(FBH(2*hj+2)/FBH(2*hj-1));
 
      td2 = tss - ha*S(index-1);
      ts2 = S(index-1) + hb*td2;
      ss(i) = hc*ts2;
      dd(i+h-1) = td2/hc;
      dd(i+h) = tdd;
 
      h = h+1;
 
   end
 
end
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
91
92
93
94
95
96
97
98
99
100
function X = ihgst2d(H,nlevel)
 
% Author: Jun Li. Copyright (c) 2015, All rights reserved. 
% more info@ http://goldensectiontransform.com/
% the lifting scheme of inverse 2d high golden section transform
% here matrix H is of Fn*Fn where Fn is a fibonacci number Fn>=2.
 
global hji; % only used by function ihgst1d(S) below.
global FBHI; % only used by function ihgst1d(S) below.
 
[xx,yy] = size(H);
 
ind = floor(log(xx*sqrt(5)+1/2)/log((sqrt(5)+1)/2)); % determine index
FBHI = filter(1,[1 -1 -1],[1 zeros(1,ind-1)]);
% FBHI = Fibonacci sequence -> [1 1 2 3 5 8...];
 
X=H;
for hji=nlevel:-1:1
 
   for j=1:FBHI(end-2*hji+2)
      ss = X(1:FBHI(end-2*hji),j);
      dd = X(FBHI(end-2*hji)+1:FBHI(end-2*hji+2),j);
      X(1:FBHI(end-2*hji+2),j) = ihgst1d(ss',dd')'; % inverse column transform
   end
 
   for k=1:FBHI(end-2*hji+2)
      ss = X(k,1:FBHI(end-2*hji));
      dd = X(k,FBHI(end-2*hji)+1:FBHI(end-2*hji+2));
      X(k,1:FBHI(end-2*hji+2)) = ihgst1d(ss,dd); % inverse row transform
   end
 
end
 
 
%% inverse 1d high golden section transform lifting scheme
 
function S = ihgst1d(ss,dd)
 
%% Author: Jun Li. more info@ http://goldensectiontransform.com/
 
global hji;
global FBHI;
 
N = length(ss) + length(dd);
index = 0;
g = 1;
h = 1;
 
hform = hword(N);
 
for i=1:length(hform)
 
   index = index + hform(i);
 
   if hform(i) == 2
 
      % S(index-1) = (sqrt(FBHI(2*hji-1))*ss(i)+sqrt(FBHI(2*hji))*dd(2*i-g))/sqrt(FBHI(2*hji+1));
      % S(index) = (sqrt(FBHI(2*hji))*ss(i)-sqrt(FBHI(2*hji-1))*dd(2*i-g))/sqrt(FBHI(2*hji+1));
 
      %% we can use lifting scheme here:
 
      ga = sqrt(FBHI(2*hji-1)/FBHI(2*hji));
      gb = sqrt(FBHI(2*hji-1)*FBHI(2*hji))/FBHI(2*hji+1);
      gc = sqrt(FBHI(2*hji+1)/FBHI(2*hji));
 
      d1 = gc*dd(2*i-g);
      s1 = ss(i)/gc;
      S(index) = s1 - gb*d1;
      S(index-1) = d1 + ga*S(index);
 
      g = g+1;
 
   else % hform(i) == 3
 
      % S(index-2) = (sqrt(FBHI(2*hji))*ss(i)+sqrt(FBHI(2*hji-1)/2)*dd(i+h-1))/sqrt(FBHI(2*hji+2))+dd(i+h)/sqrt(2);
      % S(index-1) = (sqrt(FBHI(2*hji-1))*ss(i)-sqrt(2*FBHI(2*hji))*dd(i+h-1))/sqrt(FBHI(2*hji+2));
      % S(index) = (sqrt(FBHI(2*hji))*ss(i)+sqrt(FBHI(2*hji-1)/2)*dd(i+h-1))/sqrt(FBHI(2*hji+2))-dd(i+h)/sqrt(2);
 
      %% we can use lifting scheme here:
 
      ha = sqrt(2*FBHI(2*hji)/FBHI(2*hji-1));
      hb = sqrt(2*FBHI(2*hji-1)*FBHI(2*hji))/FBHI(2*hji+2);
      hc = sqrt(FBHI(2*hji+2)/FBHI(2*hji-1));
 
      tdd = dd(i+h);
      td2 = hc*dd(i+h-1);
      ts2 = ss(i)/hc;
      S(index-1) = ts2 - hb*td2;
      tss = td2 + ha*S(index-1);
 
      td1 = sqrt(2)*tdd;
      ts1 = tss/sqrt(2);
      S(index) = ts1 - 1/2*td1;
      S(index-2) = td1 + S(index);
 
      h = h+1;
 
   end
 
end
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
function hform = hword(n)
 
% Author: Jun Li. Copyright (c) 2015, All rights reserved. 
% more info@ http://goldensectiontransform.com/
% Type-H golden section decomposion of fibonacci number n, 
% e.g. hword(8) = [3 2 3];
 
 
if n == 2
 
 
   hform = [2];
 
elseif n == 3
 
   hform = [3];
 
 
else 
 
next = round((sqrt(5)-1)/2*n); 
 
hform = [hword(n-next),hword(next)];
 
 
end

download pdf

download from https://github.com/jasonli30s

Leave a Reply

Your email address will not be published. Required fields are marked *