diff options
Diffstat (limited to 'SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/reconSCFpyr.m')
-rwxr-xr-x | SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/reconSCFpyr.m | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/reconSCFpyr.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/reconSCFpyr.m deleted file mode 100755 index a86f03d..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/reconSCFpyr.m +++ /dev/null | |||
@@ -1,87 +0,0 @@ | |||
1 | % RES = reconSCFpyr(PYR, INDICES, LEVS, BANDS, TWIDTH) | ||
2 | % | ||
3 | % The inverse of buildSCFpyr: Reconstruct image from its complex steerable pyramid representation, | ||
4 | % in the Fourier domain. | ||
5 | % | ||
6 | % The image is reconstructed by forcing the complex subbands to be analytic | ||
7 | % (zero on half of the 2D Fourier plane, as they are supossed to be unless | ||
8 | % they have being modified), and reconstructing from the real part of those | ||
9 | % analytic subbands. That is equivalent to compute the Hilbert transforms of | ||
10 | % the imaginary parts of the subbands, average them with their real | ||
11 | % counterparts, and then reconstructing from the resulting real subbands. | ||
12 | % | ||
13 | % PYR is a vector containing the N pyramid subbands, ordered from fine | ||
14 | % to coarse. INDICES is an Nx2 matrix containing the sizes of | ||
15 | % each subband. This is compatible with the MatLab Wavelet toolbox. | ||
16 | % | ||
17 | % LEVS (optional) should be a list of levels to include, or the string | ||
18 | % 'all' (default). 0 corresonds to the residual highpass subband. | ||
19 | % 1 corresponds to the finest oriented scale. The lowpass band | ||
20 | % corresponds to number spyrHt(INDICES)+1. | ||
21 | % | ||
22 | % BANDS (optional) should be a list of bands to include, or the string | ||
23 | % 'all' (default). 1 = vertical, rest proceeding anti-clockwise. | ||
24 | % | ||
25 | % TWIDTH is the width of the transition region of the radial lowpass | ||
26 | % function, in octaves (default = 1, which gives a raised cosine for | ||
27 | % the bandpass filters). | ||
28 | |||
29 | % Javier Portilla, 7/04, basing on Eero Simoncelli's Matlab Pyrtools code | ||
30 | % and our common code on texture synthesis (textureSynthesis.m). | ||
31 | |||
32 | function res = reconSCFpyr(pyr, indices, levs, bands, twidth) | ||
33 | |||
34 | %%------------------------------------------------------------ | ||
35 | %% DEFAULTS: | ||
36 | |||
37 | if ~exist('levs'), | ||
38 | levs = 'all'; | ||
39 | end | ||
40 | |||
41 | if ~exist('bands') | ||
42 | bands = 'all'; | ||
43 | end | ||
44 | |||
45 | if ~exist('twidth'), | ||
46 | twidth = 1; | ||
47 | elseif (twidth <= 0) | ||
48 | fprintf(1,'Warning: TWIDTH must be positive. Setting to 1.\n'); | ||
49 | twidth = 1; | ||
50 | end | ||
51 | |||
52 | %%------------------------------------------------------------ | ||
53 | |||
54 | |||
55 | pind = indices; | ||
56 | Nsc = log2(pind(1,1)/pind(end,1)); | ||
57 | Nor = (size(pind,1)-2)/Nsc; | ||
58 | |||
59 | for nsc = 1:Nsc, | ||
60 | firstBnum = (nsc-1)*Nor+2; | ||
61 | |||
62 | %% Re-create analytic subbands | ||
63 | dims = pind(firstBnum,:); | ||
64 | ctr = ceil((dims+0.5)/2); | ||
65 | ang = mkAngle(dims, 0, ctr); | ||
66 | ang(ctr(1),ctr(2)) = -pi/2; | ||
67 | for nor = 1:Nor, | ||
68 | nband = (nsc-1)*Nor+nor+1; | ||
69 | ind = pyrBandIndices(pind,nband); | ||
70 | ch = pyrBand(pyr, pind, nband); | ||
71 | ang0 = pi*(nor-1)/Nor; | ||
72 | xang = mod(ang-ang0+pi, 2*pi) - pi; | ||
73 | amask = 2*(abs(xang) < pi/2) + (abs(xang) == pi/2); | ||
74 | amask(ctr(1),ctr(2)) = 1; | ||
75 | amask(:,1) = 1; | ||
76 | amask(1,:) = 1; | ||
77 | amask = fftshift(amask); | ||
78 | ch = ifft2(amask.*fft2(ch)); % "Analytic" version | ||
79 | %f = 1.000008; % With this factor the reconstruction SNR goes up around 6 dB! | ||
80 | f = 1; | ||
81 | ch = f*0.5*real(ch); % real part | ||
82 | pyr(ind) = ch; | ||
83 | end % nor | ||
84 | end % nsc | ||
85 | |||
86 | res = reconSFpyr(pyr, indices, levs, bands, twidth); | ||
87 | |||