summaryrefslogtreecommitdiffstats
path: root/SD-VBS/benchmarks/texture_synthesis/src/matlab/buildWpyr.m
diff options
context:
space:
mode:
authorleochanj105 <leochanj@live.unc.edu>2020-10-19 23:09:30 -0400
committerleochanj105 <leochanj@live.unc.edu>2020-10-20 02:40:39 -0400
commitf618466c25d43f3bae9e40920273bf77de1e1149 (patch)
tree460e739e2165b8a9c37a9c7ab1b60f5874903543 /SD-VBS/benchmarks/texture_synthesis/src/matlab/buildWpyr.m
parent47ced4e96bbb782b9e780e8f2cfc637b2c21ff44 (diff)
initial sd-vbs
initial sd-vbs add sd-vbs sd-vbs
Diffstat (limited to 'SD-VBS/benchmarks/texture_synthesis/src/matlab/buildWpyr.m')
-rwxr-xr-xSD-VBS/benchmarks/texture_synthesis/src/matlab/buildWpyr.m100
1 files changed, 100 insertions, 0 deletions
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/buildWpyr.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/buildWpyr.m
new file mode 100755
index 0000000..22ae32f
--- /dev/null
+++ b/SD-VBS/benchmarks/texture_synthesis/src/matlab/buildWpyr.m
@@ -0,0 +1,100 @@
1% [PYR, INDICES] = buildWpyr(IM, HEIGHT, FILT, EDGES)
2%
3% Construct a separable orthonormal QMF/wavelet pyramid on matrix (or vector) IM.
4%
5% HEIGHT (optional) specifies the number of pyramid levels to build. Default
6% is maxPyrHt(IM,FILT). You can also specify 'auto' to use this value.
7%
8% FILT (optional) can be a string naming a standard filter (see
9% namedFilter), or a vector which will be used for (separable)
10% convolution. Filter can be of even or odd length, but should be symmetric.
11% Default = 'qmf9'. EDGES specifies edge-handling, and
12% defaults to 'reflect1' (see corrDn).
13%
14% PYR is a vector containing the N pyramid subbands, ordered from fine
15% to coarse. INDICES is an Nx2 matrix containing the sizes of
16% each subband. This is compatible with the MatLab Wavelet toolbox.
17
18% Eero Simoncelli, 6/96.
19
20function [pyr,pind] = buildWpyr(im, ht, filt, edges)
21
22if (nargin < 1)
23 error('First argument (IM) is required');
24end
25
26%------------------------------------------------------------
27%% OPTIONAL ARGS:
28
29if (exist('filt') ~= 1)
30 filt = 'qmf9';
31end
32
33if (exist('edges') ~= 1)
34 edges= 'reflect1';
35end
36
37if isstr(filt)
38 filt = namedFilter(filt);
39end
40
41if ( (size(filt,1) > 1) & (size(filt,2) > 1) )
42 error('FILT should be a 1D filter (i.e., a vector)');
43else
44 filt = filt(:);
45end
46
47hfilt = modulateFlip(filt);
48
49% Stagger sampling if filter is odd-length:
50if (mod(size(filt,1),2) == 0)
51 stag = 2;
52else
53 stag = 1;
54end
55
56im_sz = size(im);
57
58max_ht = maxPyrHt(im_sz, size(filt,1));
59if ( (exist('ht') ~= 1) | (ht == 'auto') )
60 ht = max_ht;
61else
62 if (ht > max_ht)
63 error(sprintf('Cannot build pyramid higher than %d levels.',max_ht));
64 end
65end
66
67if (ht <= 0)
68
69 pyr = im(:);
70 pind = im_sz;
71
72else
73
74 if (im_sz(2) == 1)
75 lolo = corrDn(im, filt, edges, [2 1], [stag 1]);
76 hihi = corrDn(im, hfilt, edges, [2 1], [2 1]);
77 elseif (im_sz(1) == 1)
78 lolo = corrDn(im, filt', edges, [1 2], [1 stag]);
79 hihi = corrDn(im, hfilt', edges, [1 2], [1 2]);
80 else
81 lo = corrDn(im, filt, edges, [2 1], [stag 1]);
82 hi = corrDn(im, hfilt, edges, [2 1], [2 1]);
83 lolo = corrDn(lo, filt', edges, [1 2], [1 stag]);
84 lohi = corrDn(hi, filt', edges, [1 2], [1 stag]); % horizontal
85 hilo = corrDn(lo, hfilt', edges, [1 2], [1 2]); % vertical
86 hihi = corrDn(hi, hfilt', edges, [1 2], [1 2]); % diagonal
87 end
88
89 [npyr,nind] = buildWpyr(lolo, ht-1, filt, edges);
90
91 if ((im_sz(1) == 1) | (im_sz(2) == 1))
92 pyr = [hihi(:); npyr];
93 pind = [size(hihi); nind];
94 else
95 pyr = [lohi(:); hilo(:); hihi(:); npyr];
96 pind = [size(lohi); size(hilo); size(hihi); nind];
97 end
98
99end
100