summaryrefslogtreecommitdiffstats
path: root/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/buildSCFpyrLevs.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/matlabPyrTools/buildSCFpyrLevs.m
parent47ced4e96bbb782b9e780e8f2cfc637b2c21ff44 (diff)
initial sd-vbs
initial sd-vbs add sd-vbs sd-vbs
Diffstat (limited to 'SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/buildSCFpyrLevs.m')
-rwxr-xr-xSD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/buildSCFpyrLevs.m73
1 files changed, 73 insertions, 0 deletions
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/buildSCFpyrLevs.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/buildSCFpyrLevs.m
new file mode 100755
index 0000000..bd75695
--- /dev/null
+++ b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/buildSCFpyrLevs.m
@@ -0,0 +1,73 @@
1% [PYR, INDICES] = buildSCFpyrLevs(LODFT, LOGRAD, XRCOS, YRCOS, ANGLE, HEIGHT, NBANDS)
2%
3% Recursive function for constructing levels of a steerable pyramid. This
4% is called by buildSCFpyr, and is not usually called directly.
5
6% Original code: Eero Simoncelli, 5/97.
7% Modified by Javier Portilla to generate complex bands in 9/97.
8
9function [pyr,pind] = buildSCFpyrLevs(lodft,log_rad,Xrcos,Yrcos,angle,ht,nbands);
10
11if (ht <= 0)
12
13 lo0 = ifft2(ifftshift(lodft));
14 pyr = real(lo0(:));
15 pind = size(lo0);
16
17else
18
19 bands = zeros(prod(size(lodft)), nbands);
20 bind = zeros(nbands,2);
21
22% log_rad = log_rad + 1;
23 Xrcos = Xrcos - log2(2); % shift origin of lut by 1 octave.
24
25 lutsize = 1024;
26 Xcosn = pi*[-(2*lutsize+1):(lutsize+1)]/lutsize; % [-2*pi:pi]
27 order = nbands-1;
28 %% divide by sqrt(sum_(n=0)^(N-1) cos(pi*n/N)^(2(N-1)) )
29 %% Thanks to Patrick Teo for writing this out :)
30 const = (2^(2*order))*(factorial(order)^2)/(nbands*factorial(2*order));
31
32%
33% Ycosn = sqrt(const) * (cos(Xcosn)).^order;
34%
35 % analityc version: only take one lobe
36 alfa= mod(pi+Xcosn,2*pi)-pi;
37 Ycosn = 2*sqrt(const) * (cos(Xcosn).^order) .* (abs(alfa)<pi/2);
38
39 himask = pointOp(log_rad, Yrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0);
40
41 for b = 1:nbands
42 anglemask = pointOp(angle, Ycosn, Xcosn(1)+pi*(b-1)/nbands, Xcosn(2)-Xcosn(1));
43 banddft = ((-i)^(nbands-1)) .* lodft .* anglemask .* himask;
44 band = ifft2(ifftshift(banddft));
45
46% bands(:,b) = real(band(:));
47 % analytic version: full complex value
48 bands(:,b)=band(:);
49 bind(b,:) = size(band);
50 end
51
52 dims = size(lodft);
53 ctr = ceil((dims+0.5)/2);
54 lodims = ceil((dims-0.5)/2);
55 loctr = ceil((lodims+0.5)/2);
56 lostart = ctr-loctr+1;
57 loend = lostart+lodims-1;
58
59 log_rad = log_rad(lostart(1):loend(1),lostart(2):loend(2));
60 angle = angle(lostart(1):loend(1),lostart(2):loend(2));
61 lodft = lodft(lostart(1):loend(1),lostart(2):loend(2));
62 YIrcos = abs(sqrt(1.0 - Yrcos.^2));
63 lomask = pointOp(log_rad, YIrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0);
64
65 lodft = lomask .* lodft;
66
67 [npyr,nind] = buildSCFpyrLevs(lodft, log_rad, Xrcos, Yrcos, angle, ht-1, nbands);
68
69 pyr = [bands(:); npyr];
70 pind = [bind; nind];
71
72end
73