summaryrefslogtreecommitdiffstats
path: root/SD-VBS/benchmarks/texture_synthesis/src/matlab/reconWpyr.m
diff options
context:
space:
mode:
Diffstat (limited to 'SD-VBS/benchmarks/texture_synthesis/src/matlab/reconWpyr.m')
-rwxr-xr-xSD-VBS/benchmarks/texture_synthesis/src/matlab/reconWpyr.m148
1 files changed, 0 insertions, 148 deletions
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/reconWpyr.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/reconWpyr.m
deleted file mode 100755
index fc31226..0000000
--- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/reconWpyr.m
+++ /dev/null
@@ -1,148 +0,0 @@
1% RES = reconWpyr(PYR, INDICES, FILT, EDGES, LEVS, BANDS)
2%
3% Reconstruct image from its separable orthonormal QMF/wavelet pyramid
4% representation, as created by buildWpyr.
5%
6% PYR is a vector containing the N pyramid subbands, ordered from fine
7% to coarse. INDICES is an Nx2 matrix containing the sizes of
8% each subband. This is compatible with the MatLab Wavelet toolbox.
9%
10% FILT (optional) can be a string naming a standard filter (see
11% namedFilter), or a vector which will be used for (separable)
12% convolution. Default = 'qmf9'. EDGES specifies edge-handling,
13% and defaults to 'reflect1' (see corrDn).
14%
15% LEVS (optional) should be a vector of levels to include, or the string
16% 'all' (default). 1 corresponds to the finest scale. The lowpass band
17% corresponds to wpyrHt(INDICES)+1.
18%
19% BANDS (optional) should be a vector of bands to include, or the string
20% 'all' (default). 1=horizontal, 2=vertical, 3=diagonal. This is only used
21% for pyramids of 2D images.
22
23% Eero Simoncelli, 6/96.
24
25function res = reconWpyr(pyr, ind, filt, edges, levs, bands)
26
27if (nargin < 2)
28 error('First two arguments (PYR INDICES) are required');
29end
30
31%%------------------------------------------------------------
32%% OPTIONAL ARGS:
33
34if (exist('filt') ~= 1)
35 filt = 'qmf9';
36end
37
38if (exist('edges') ~= 1)
39 edges= 'reflect1';
40end
41
42if (exist('levs') ~= 1)
43 levs = 'all';
44end
45
46if (exist('bands') ~= 1)
47 bands = 'all';
48end
49
50%%------------------------------------------------------------
51
52maxLev = 1+wpyrHt(ind);
53if strcmp(levs,'all')
54 levs = [1:maxLev]';
55else
56 if (any(levs > maxLev))
57 error(sprintf('Level numbers must be in the range [1, %d].', maxLev));
58 end
59 levs = levs(:);
60end
61
62if strcmp(bands,'all')
63 bands = [1:3]';
64else
65 if (any(bands < 1) | any(bands > 3))
66 error('Band numbers must be in the range [1,3].');
67 end
68 bands = bands(:);
69end
70
71if isstr(filt)
72 filt = namedFilter(filt);
73end
74
75filt = filt(:);
76hfilt = modulateFlip(filt);
77
78%% For odd-length filters, stagger the sampling lattices:
79if (mod(size(filt,1),2) == 0)
80 stag = 2;
81else
82 stag = 1;
83end
84
85%% Compute size of result image: assumes critical sampling (boundaries correct)
86res_sz = ind(1,:);
87if (res_sz(1) == 1)
88 loind = 2;
89 res_sz(2) = sum(ind(:,2));
90elseif (res_sz(2) == 1)
91 loind = 2;
92 res_sz(1) = sum(ind(:,1));
93else
94 loind = 4;
95 res_sz = ind(1,:) + ind(2,:); %%horizontal + vertical bands.
96 hres_sz = [ind(1,1), res_sz(2)];
97 lres_sz = [ind(2,1), res_sz(2)];
98end
99
100
101%% First, recursively collapse coarser scales:
102if any(levs > 1)
103
104 if (size(ind,1) > loind)
105 nres = reconWpyr( pyr(1+sum(prod(ind(1:loind-1,:)')):size(pyr,1)), ...
106 ind(loind:size(ind,1),:), filt, edges, levs-1, bands);
107 else
108 nres = pyrBand(pyr, ind, loind); % lowpass subband
109 end
110
111 if (res_sz(1) == 1)
112 res = upConv(nres, filt', edges, [1 2], [1 stag], res_sz);
113 elseif (res_sz(2) == 1)
114 res = upConv(nres, filt, edges, [2 1], [stag 1], res_sz);
115 else
116 ires = upConv(nres, filt', edges, [1 2], [1 stag], lres_sz);
117 res = upConv(ires, filt, edges, [2 1], [stag 1], res_sz);
118 end
119
120else
121
122 res = zeros(res_sz);
123
124end
125
126
127%% Add in reconstructed bands from this level:
128if any(levs == 1)
129 if (res_sz(1) == 1)
130 upConv(pyrBand(pyr,ind,1), hfilt', edges, [1 2], [1 2], res_sz, res);
131 elseif (res_sz(2) == 1)
132 upConv(pyrBand(pyr,ind,1), hfilt, edges, [2 1], [2 1], res_sz, res);
133 else
134 if any(bands == 1) % horizontal
135 ires = upConv(pyrBand(pyr,ind,1),filt',edges,[1 2],[1 stag],hres_sz);
136 upConv(ires,hfilt,edges,[2 1],[2 1],res_sz,res); %destructively modify res
137 end
138 if any(bands == 2) % vertical
139 ires = upConv(pyrBand(pyr,ind,2),hfilt',edges,[1 2],[1 2],lres_sz);
140 upConv(ires,filt,edges,[2 1],[stag 1],res_sz,res); %destructively modify res
141 end
142 if any(bands == 3) % diagonal
143 ires = upConv(pyrBand(pyr,ind,3),hfilt',edges,[1 2],[1 2],hres_sz);
144 upConv(ires,hfilt,edges,[2 1],[2 1],res_sz,res); %destructively modify res
145 end
146 end
147end
148