diff options
Diffstat (limited to 'SD-VBS/benchmarks/texture_synthesis/src/matlab/reconWpyr.m')
| -rwxr-xr-x | SD-VBS/benchmarks/texture_synthesis/src/matlab/reconWpyr.m | 148 |
1 files changed, 0 insertions, 148 deletions
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/reconWpyr.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/reconWpyr.m deleted file mode 100755 index fc31226..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/reconWpyr.m +++ /dev/null | |||
| @@ -1,148 +0,0 @@ | |||
| 1 | % RES = reconWpyr(PYR, INDICES, FILT, EDGES, LEVS, BANDS) | ||
| 2 | % | ||
| 3 | % Reconstruct image from its separable orthonormal QMF/wavelet pyramid | ||
| 4 | % representation, as created by buildWpyr. | ||
| 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 | % FILT (optional) can be a string naming a standard filter (see | ||
| 11 | % namedFilter), or a vector which will be used for (separable) | ||
| 12 | % convolution. Default = 'qmf9'. EDGES specifies edge-handling, | ||
| 13 | % and defaults to 'reflect1' (see corrDn). | ||
| 14 | % | ||
| 15 | % LEVS (optional) should be a vector of levels to include, or the string | ||
| 16 | % 'all' (default). 1 corresponds to the finest scale. The lowpass band | ||
| 17 | % corresponds to wpyrHt(INDICES)+1. | ||
| 18 | % | ||
| 19 | % BANDS (optional) should be a vector of bands to include, or the string | ||
| 20 | % 'all' (default). 1=horizontal, 2=vertical, 3=diagonal. This is only used | ||
| 21 | % for pyramids of 2D images. | ||
| 22 | |||
| 23 | % Eero Simoncelli, 6/96. | ||
| 24 | |||
| 25 | function res = reconWpyr(pyr, ind, filt, edges, levs, bands) | ||
| 26 | |||
| 27 | if (nargin < 2) | ||
| 28 | error('First two arguments (PYR INDICES) are required'); | ||
| 29 | end | ||
| 30 | |||
| 31 | %%------------------------------------------------------------ | ||
| 32 | %% OPTIONAL ARGS: | ||
| 33 | |||
| 34 | if (exist('filt') ~= 1) | ||
| 35 | filt = 'qmf9'; | ||
| 36 | end | ||
| 37 | |||
| 38 | if (exist('edges') ~= 1) | ||
| 39 | edges= 'reflect1'; | ||
| 40 | end | ||
| 41 | |||
| 42 | if (exist('levs') ~= 1) | ||
| 43 | levs = 'all'; | ||
| 44 | end | ||
| 45 | |||
| 46 | if (exist('bands') ~= 1) | ||
| 47 | bands = 'all'; | ||
| 48 | end | ||
| 49 | |||
| 50 | %%------------------------------------------------------------ | ||
| 51 | |||
| 52 | maxLev = 1+wpyrHt(ind); | ||
| 53 | if strcmp(levs,'all') | ||
| 54 | levs = [1:maxLev]'; | ||
| 55 | else | ||
| 56 | if (any(levs > maxLev)) | ||
| 57 | error(sprintf('Level numbers must be in the range [1, %d].', maxLev)); | ||
| 58 | end | ||
| 59 | levs = levs(:); | ||
| 60 | end | ||
| 61 | |||
| 62 | if strcmp(bands,'all') | ||
| 63 | bands = [1:3]'; | ||
| 64 | else | ||
| 65 | if (any(bands < 1) | any(bands > 3)) | ||
| 66 | error('Band numbers must be in the range [1,3].'); | ||
| 67 | end | ||
| 68 | bands = bands(:); | ||
| 69 | end | ||
| 70 | |||
| 71 | if isstr(filt) | ||
| 72 | filt = namedFilter(filt); | ||
| 73 | end | ||
| 74 | |||
| 75 | filt = filt(:); | ||
| 76 | hfilt = modulateFlip(filt); | ||
| 77 | |||
| 78 | %% For odd-length filters, stagger the sampling lattices: | ||
| 79 | if (mod(size(filt,1),2) == 0) | ||
| 80 | stag = 2; | ||
| 81 | else | ||
| 82 | stag = 1; | ||
| 83 | end | ||
| 84 | |||
| 85 | %% Compute size of result image: assumes critical sampling (boundaries correct) | ||
| 86 | res_sz = ind(1,:); | ||
| 87 | if (res_sz(1) == 1) | ||
| 88 | loind = 2; | ||
| 89 | res_sz(2) = sum(ind(:,2)); | ||
| 90 | elseif (res_sz(2) == 1) | ||
| 91 | loind = 2; | ||
| 92 | res_sz(1) = sum(ind(:,1)); | ||
| 93 | else | ||
| 94 | loind = 4; | ||
| 95 | res_sz = ind(1,:) + ind(2,:); %%horizontal + vertical bands. | ||
| 96 | hres_sz = [ind(1,1), res_sz(2)]; | ||
| 97 | lres_sz = [ind(2,1), res_sz(2)]; | ||
| 98 | end | ||
| 99 | |||
| 100 | |||
| 101 | %% First, recursively collapse coarser scales: | ||
| 102 | if any(levs > 1) | ||
| 103 | |||
| 104 | if (size(ind,1) > loind) | ||
| 105 | nres = reconWpyr( pyr(1+sum(prod(ind(1:loind-1,:)')):size(pyr,1)), ... | ||
| 106 | ind(loind:size(ind,1),:), filt, edges, levs-1, bands); | ||
| 107 | else | ||
| 108 | nres = pyrBand(pyr, ind, loind); % lowpass subband | ||
| 109 | end | ||
| 110 | |||
| 111 | if (res_sz(1) == 1) | ||
| 112 | res = upConv(nres, filt', edges, [1 2], [1 stag], res_sz); | ||
| 113 | elseif (res_sz(2) == 1) | ||
| 114 | res = upConv(nres, filt, edges, [2 1], [stag 1], res_sz); | ||
| 115 | else | ||
| 116 | ires = upConv(nres, filt', edges, [1 2], [1 stag], lres_sz); | ||
| 117 | res = upConv(ires, filt, edges, [2 1], [stag 1], res_sz); | ||
| 118 | end | ||
| 119 | |||
| 120 | else | ||
| 121 | |||
| 122 | res = zeros(res_sz); | ||
| 123 | |||
| 124 | end | ||
| 125 | |||
| 126 | |||
| 127 | %% Add in reconstructed bands from this level: | ||
| 128 | if any(levs == 1) | ||
| 129 | if (res_sz(1) == 1) | ||
| 130 | upConv(pyrBand(pyr,ind,1), hfilt', edges, [1 2], [1 2], res_sz, res); | ||
| 131 | elseif (res_sz(2) == 1) | ||
| 132 | upConv(pyrBand(pyr,ind,1), hfilt, edges, [2 1], [2 1], res_sz, res); | ||
| 133 | else | ||
| 134 | if any(bands == 1) % horizontal | ||
| 135 | ires = upConv(pyrBand(pyr,ind,1),filt',edges,[1 2],[1 stag],hres_sz); | ||
| 136 | upConv(ires,hfilt,edges,[2 1],[2 1],res_sz,res); %destructively modify res | ||
| 137 | end | ||
| 138 | if any(bands == 2) % vertical | ||
| 139 | ires = upConv(pyrBand(pyr,ind,2),hfilt',edges,[1 2],[1 2],lres_sz); | ||
| 140 | upConv(ires,filt,edges,[2 1],[stag 1],res_sz,res); %destructively modify res | ||
| 141 | end | ||
| 142 | if any(bands == 3) % diagonal | ||
| 143 | ires = upConv(pyrBand(pyr,ind,3),hfilt',edges,[1 2],[1 2],hres_sz); | ||
| 144 | upConv(ires,hfilt,edges,[2 1],[2 1],res_sz,res); %destructively modify res | ||
| 145 | end | ||
| 146 | end | ||
| 147 | end | ||
| 148 | |||
