diff options
author | leochanj105 <leochanj@live.unc.edu> | 2020-10-19 23:09:30 -0400 |
---|---|---|
committer | leochanj105 <leochanj@live.unc.edu> | 2020-10-20 02:40:39 -0400 |
commit | f618466c25d43f3bae9e40920273bf77de1e1149 (patch) | |
tree | 460e739e2165b8a9c37a9c7ab1b60f5874903543 /SD-VBS/benchmarks/texture_synthesis/src/matlab/buildGpyr.m | |
parent | 47ced4e96bbb782b9e780e8f2cfc637b2c21ff44 (diff) |
initial sd-vbs
initial sd-vbs
add sd-vbs
sd-vbs
Diffstat (limited to 'SD-VBS/benchmarks/texture_synthesis/src/matlab/buildGpyr.m')
-rwxr-xr-x | SD-VBS/benchmarks/texture_synthesis/src/matlab/buildGpyr.m | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/buildGpyr.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/buildGpyr.m new file mode 100755 index 0000000..3f3d07b --- /dev/null +++ b/SD-VBS/benchmarks/texture_synthesis/src/matlab/buildGpyr.m | |||
@@ -0,0 +1,82 @@ | |||
1 | % [PYR, INDICES] = buildGpyr(IM, HEIGHT, FILT, EDGES) | ||
2 | % | ||
3 | % Construct a Gaussian pyramid on matrix IM. | ||
4 | % | ||
5 | % HEIGHT (optional) specifies the number of pyramid levels to build. Default | ||
6 | % is 1+maxPyrHt(size(IM),size(FILT)). | ||
7 | % You can also specify 'auto' to use this value. | ||
8 | % | ||
9 | % FILT (optional) can be a string naming a standard filter (see | ||
10 | % namedFilter), or a vector which will be used for (separable) | ||
11 | % convolution. Default = 'binom5'. 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 | |||
20 | function [pyr,pind] = buildGpyr(im, ht, filt, edges) | ||
21 | |||
22 | if (nargin < 1) | ||
23 | error('First argument (IM) is required'); | ||
24 | end | ||
25 | |||
26 | im_sz = size(im); | ||
27 | |||
28 | %------------------------------------------------------------ | ||
29 | %% OPTIONAL ARGS: | ||
30 | |||
31 | if (exist('filt') ~= 1) | ||
32 | filt = 'binom5'; | ||
33 | end | ||
34 | |||
35 | if isstr(filt) | ||
36 | filt = namedFilter(filt); | ||
37 | end | ||
38 | |||
39 | if ( (size(filt,1) > 1) & (size(filt,2) > 1) ) | ||
40 | error('FILT should be a 1D filter (i.e., a vector)'); | ||
41 | else | ||
42 | filt = filt(:); | ||
43 | end | ||
44 | |||
45 | max_ht = 1 + maxPyrHt(im_sz, size(filt,1)); | ||
46 | if ( (exist('ht') ~= 1) | (ht == 'auto') ) | ||
47 | ht = max_ht; | ||
48 | else | ||
49 | if (ht > max_ht) | ||
50 | error(sprintf('Cannot build pyramid higher than %d levels.',max_ht)); | ||
51 | end | ||
52 | end | ||
53 | |||
54 | if (exist('edges') ~= 1) | ||
55 | edges= 'reflect1'; | ||
56 | end | ||
57 | |||
58 | %------------------------------------------------------------ | ||
59 | |||
60 | if (ht <= 1) | ||
61 | |||
62 | pyr = im(:); | ||
63 | pind = im_sz; | ||
64 | |||
65 | else | ||
66 | |||
67 | if (im_sz(2) == 1) | ||
68 | lo2 = corrDn(im, filt, edges, [2 1], [1 1]); | ||
69 | elseif (im_sz(1) == 1) | ||
70 | lo2 = corrDn(im, filt', edges, [1 2], [1 1]); | ||
71 | else | ||
72 | lo = corrDn(im, filt', edges, [1 2], [1 1]); | ||
73 | lo2 = corrDn(lo, filt, edges, [2 1], [1 1]); | ||
74 | end | ||
75 | |||
76 | [npyr,nind] = buildGpyr(lo2, ht-1, filt, edges); | ||
77 | |||
78 | pyr = [im(:); npyr]; | ||
79 | pind = [im_sz; nind]; | ||
80 | |||
81 | end | ||
82 | |||