diff options
Diffstat (limited to 'SD-VBS/benchmarks/texture_synthesis/src/matlab/reconSFpyr.m')
| -rwxr-xr-x | SD-VBS/benchmarks/texture_synthesis/src/matlab/reconSFpyr.m | 108 |
1 files changed, 0 insertions, 108 deletions
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/reconSFpyr.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/reconSFpyr.m deleted file mode 100755 index 0e3109e..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/reconSFpyr.m +++ /dev/null | |||
| @@ -1,108 +0,0 @@ | |||
| 1 | % RES = reconSFpyr(PYR, INDICES, LEVS, BANDS, TWIDTH) | ||
| 2 | % | ||
| 3 | % Reconstruct image from its steerable pyramid representation, in the Fourier | ||
| 4 | % domain, as created by buildSFpyr. | ||
| 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 | % LEVS (optional) should be a list of levels to include, or the string | ||
| 11 | % 'all' (default). 0 corresonds to the residual highpass subband. | ||
| 12 | % 1 corresponds to the finest oriented scale. The lowpass band | ||
| 13 | % corresponds to number spyrHt(INDICES)+1. | ||
| 14 | % | ||
| 15 | % BANDS (optional) should be a list of bands to include, or the string | ||
| 16 | % 'all' (default). 1 = vertical, rest proceeding anti-clockwise. | ||
| 17 | % | ||
| 18 | % TWIDTH is the width of the transition region of the radial lowpass | ||
| 19 | % function, in octaves (default = 1, which gives a raised cosine for | ||
| 20 | % the bandpass filters). | ||
| 21 | |||
| 22 | %%% MODIFIED VERSION, 7/04, uses different lookup table for radial frequency! | ||
| 23 | |||
| 24 | % Eero Simoncelli, 5/97. | ||
| 25 | |||
| 26 | function res = reconSFpyr(pyr, pind, levs, bands, twidth) | ||
| 27 | |||
| 28 | %%------------------------------------------------------------ | ||
| 29 | %% DEFAULTS: | ||
| 30 | |||
| 31 | if (exist('levs') ~= 1) | ||
| 32 | levs = 'all'; | ||
| 33 | end | ||
| 34 | |||
| 35 | if (exist('bands') ~= 1) | ||
| 36 | bands = 'all'; | ||
| 37 | end | ||
| 38 | |||
| 39 | if (exist('twidth') ~= 1) | ||
| 40 | twidth = 1; | ||
| 41 | elseif (twidth <= 0) | ||
| 42 | fprintf(1,'Warning: TWIDTH must be positive. Setting to 1.\n'); | ||
| 43 | twidth = 1; | ||
| 44 | end | ||
| 45 | |||
| 46 | %%------------------------------------------------------------ | ||
| 47 | |||
| 48 | nbands = spyrNumBands(pind); | ||
| 49 | |||
| 50 | maxLev = 1+spyrHt(pind); | ||
| 51 | if strcmp(levs,'all') | ||
| 52 | levs = [0:maxLev]'; | ||
| 53 | else | ||
| 54 | if (any(levs > maxLev) | any(levs < 0)) | ||
| 55 | error(sprintf('Level numbers must be in the range [0, %d].', maxLev)); | ||
| 56 | end | ||
| 57 | levs = levs(:); | ||
| 58 | end | ||
| 59 | |||
| 60 | if strcmp(bands,'all') | ||
| 61 | bands = [1:nbands]'; | ||
| 62 | else | ||
| 63 | if (any(bands < 1) | any(bands > nbands)) | ||
| 64 | error(sprintf('Band numbers must be in the range [1,3].', nbands)); | ||
| 65 | end | ||
| 66 | bands = bands(:); | ||
| 67 | end | ||
| 68 | |||
| 69 | %---------------------------------------------------------------------- | ||
| 70 | |||
| 71 | dims = pind(1,:); | ||
| 72 | ctr = ceil((dims+0.5)/2); | ||
| 73 | |||
| 74 | [xramp,yramp] = meshgrid( ([1:dims(2)]-ctr(2))./(dims(2)/2), ... | ||
| 75 | ([1:dims(1)]-ctr(1))./(dims(1)/2) ); | ||
| 76 | angle = atan2(yramp,xramp); | ||
| 77 | log_rad = sqrt(xramp.^2 + yramp.^2); | ||
| 78 | log_rad(ctr(1),ctr(2)) = log_rad(ctr(1),ctr(2)-1); | ||
| 79 | log_rad = log2(log_rad); | ||
| 80 | |||
| 81 | %% Radial transition function (a raised cosine in log-frequency): | ||
| 82 | [Xrcos,Yrcos] = rcosFn(twidth,(-twidth/2),[0 1]); | ||
| 83 | Yrcos = sqrt(Yrcos); | ||
| 84 | YIrcos = sqrt(abs(1.0 - Yrcos.^2)); | ||
| 85 | |||
| 86 | if (size(pind,1) == 2) | ||
| 87 | if (any(levs==1)) | ||
| 88 | resdft = fftshift(fft2(pyrBand(pyr,pind,2))); | ||
| 89 | else | ||
| 90 | resdft = zeros(pind(2,:)); | ||
| 91 | end | ||
| 92 | else | ||
| 93 | resdft = reconSFpyrLevs(pyr(1+prod(pind(1,:)):size(pyr,1)), ... | ||
| 94 | pind(2:size(pind,1),:), ... | ||
| 95 | log_rad, Xrcos, Yrcos, angle, nbands, levs, bands); | ||
| 96 | end | ||
| 97 | |||
| 98 | lo0mask = pointOp(log_rad, YIrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); | ||
| 99 | resdft = resdft .* lo0mask; | ||
| 100 | |||
| 101 | %% residual highpass subband | ||
| 102 | if any(levs == 0) | ||
| 103 | hi0mask = pointOp(log_rad, Yrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); | ||
| 104 | hidft = fftshift(fft2(subMtx(pyr, pind(1,:)))); | ||
| 105 | resdft = resdft + hidft .* hi0mask; | ||
| 106 | end | ||
| 107 | |||
| 108 | res = real(ifft2(ifftshift(resdft))); | ||
