diff options
Diffstat (limited to 'SD-VBS/benchmarks/texture_synthesis/src/matlab/showWpyr.m')
| -rwxr-xr-x | SD-VBS/benchmarks/texture_synthesis/src/matlab/showWpyr.m | 204 |
1 files changed, 0 insertions, 204 deletions
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/showWpyr.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/showWpyr.m deleted file mode 100755 index 510e395..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/showWpyr.m +++ /dev/null | |||
| @@ -1,204 +0,0 @@ | |||
| 1 | % RANGE = showWpyr (PYR, INDICES, RANGE, GAP, LEVEL_SCALE_FACTOR) | ||
| 2 | % | ||
| 3 | % Display a separable QMF/wavelet pyramid, specified by PYR and INDICES | ||
| 4 | % (see buildWpyr), in the current figure. | ||
| 5 | % | ||
| 6 | % RANGE is a 2-vector specifying the values that map to black and | ||
| 7 | % white, respectively. These values are scaled by | ||
| 8 | % LEVEL_SCALE_FACTOR^(lev-1) for bands at each level. Passing a value | ||
| 9 | % of 'auto1' sets RANGE to the min and max values of MATRIX. 'auto2' | ||
| 10 | % sets RANGE to 3 standard deviations below and above 0.0. In both of | ||
| 11 | % these cases, the lowpass band is independently scaled. A value of | ||
| 12 | % 'indep1' sets the range of each subband independently, as in a call | ||
| 13 | % to showIm(subband,'auto1'). Similarly, 'indep2' causes each subband | ||
| 14 | % to be scaled independently as if by showIm(subband,'indep2'). | ||
| 15 | % The default value for RANGE is 'auto1' for 1D images, and 'auto2' for | ||
| 16 | % 2D images. | ||
| 17 | % | ||
| 18 | % GAP (optional, default=1) specifies the gap in pixels to leave | ||
| 19 | % between subbands (2D images only). | ||
| 20 | % | ||
| 21 | % LEVEL_SCALE_FACTOR indicates the relative scaling between pyramid | ||
| 22 | % levels. This should be set to the sum of the kernel taps of the | ||
| 23 | % lowpass filter used to construct the pyramid (default assumes | ||
| 24 | % L2-normalized filters, using a value of 2 for 2D images, sqrt(2) for | ||
| 25 | % 1D images). | ||
| 26 | |||
| 27 | % Eero Simoncelli, 2/97. | ||
| 28 | |||
| 29 | function [range] = showWpyr(pyr, pind, range, gap, scale); | ||
| 30 | |||
| 31 | % Determine 1D or 2D pyramid: | ||
| 32 | if ((pind(1,1) == 1) | (pind(1,2) ==1)) | ||
| 33 | nbands = 1; | ||
| 34 | else | ||
| 35 | nbands = 3; | ||
| 36 | end | ||
| 37 | |||
| 38 | %------------------------------------------------------------ | ||
| 39 | %% OPTIONAL ARGS: | ||
| 40 | |||
| 41 | if (exist('range') ~= 1) | ||
| 42 | if (nbands==1) | ||
| 43 | range = 'auto1'; | ||
| 44 | else | ||
| 45 | range = 'auto2'; | ||
| 46 | end | ||
| 47 | end | ||
| 48 | |||
| 49 | if (exist('gap') ~= 1) | ||
| 50 | gap = 1; | ||
| 51 | end | ||
| 52 | |||
| 53 | if (exist('scale') ~= 1) | ||
| 54 | if (nbands == 1) | ||
| 55 | scale = sqrt(2); | ||
| 56 | else | ||
| 57 | scale = 2; | ||
| 58 | end | ||
| 59 | end | ||
| 60 | |||
| 61 | %------------------------------------------------------------ | ||
| 62 | |||
| 63 | ht = wpyrHt(pind); | ||
| 64 | nind = size(pind,1); | ||
| 65 | |||
| 66 | %% Auto range calculations: | ||
| 67 | if strcmp(range,'auto1') | ||
| 68 | range = zeros(nind,1); | ||
| 69 | mn = 0.0; mx = 0.0; | ||
| 70 | for lnum = 1:ht | ||
| 71 | for bnum = 1:nbands | ||
| 72 | band = wpyrBand(pyr,pind,lnum,bnum)/(scale^(lnum-1)); | ||
| 73 | range((lnum-1)*nbands+bnum) = scale^(lnum-1); | ||
| 74 | [bmn,bmx] = range2(band); | ||
| 75 | mn = min(mn, bmn); mx = max(mx, bmx); | ||
| 76 | end | ||
| 77 | end | ||
| 78 | if (nbands == 1) | ||
| 79 | pad = (mx-mn)/12; % *** MAGIC NUMBER!! | ||
| 80 | mn = mn-pad; mx = mx+pad; | ||
| 81 | end | ||
| 82 | range = range * [mn mx]; % outer product | ||
| 83 | band = pyrLow(pyr,pind); | ||
| 84 | [mn,mx] = range2(band); | ||
| 85 | if (nbands == 1) | ||
| 86 | pad = (mx-mn)/12; % *** MAGIC NUMBER!! | ||
| 87 | mn = mn-pad; mx = mx+pad; | ||
| 88 | end | ||
| 89 | range(nind,:) = [mn, mx]; | ||
| 90 | |||
| 91 | elseif strcmp(range,'indep1') | ||
| 92 | range = zeros(nind,2); | ||
| 93 | for bnum = 1:nind | ||
| 94 | band = pyrBand(pyr,pind,bnum); | ||
| 95 | [mn,mx] = range2(band); | ||
| 96 | if (nbands == 1) | ||
| 97 | pad = (mx-mn)/12; % *** MAGIC NUMBER!! | ||
| 98 | mn = mn-pad; mx = mx+pad; | ||
| 99 | end | ||
| 100 | range(bnum,:) = [mn mx]; | ||
| 101 | end | ||
| 102 | |||
| 103 | elseif strcmp(range,'auto2') | ||
| 104 | range = zeros(nind,1); | ||
| 105 | sqsum = 0; numpixels = 0; | ||
| 106 | for lnum = 1:ht | ||
| 107 | for bnum = 1:nbands | ||
| 108 | band = wpyrBand(pyr,pind,lnum,bnum)/(scale^(lnum-1)); | ||
| 109 | sqsum = sqsum + sum(sum(band.^2)); | ||
| 110 | numpixels = numpixels + prod(size(band)); | ||
| 111 | range((lnum-1)*nbands+bnum) = scale^(lnum-1); | ||
| 112 | end | ||
| 113 | end | ||
| 114 | stdev = sqrt(sqsum/(numpixels-1)); | ||
| 115 | range = range * [ -3*stdev 3*stdev ]; % outer product | ||
| 116 | band = pyrLow(pyr,pind); | ||
| 117 | av = mean2(band); stdev = sqrt(var2(band)); | ||
| 118 | range(nind,:) = [av-2*stdev,av+2*stdev]; | ||
| 119 | |||
| 120 | elseif strcmp(range,'indep2') | ||
| 121 | range = zeros(nind,2); | ||
| 122 | for bnum = 1:(nind-1) | ||
| 123 | band = pyrBand(pyr,pind,bnum); | ||
| 124 | stdev = sqrt(var2(band)); | ||
| 125 | range(bnum,:) = [ -3*stdev 3*stdev ]; | ||
| 126 | end | ||
| 127 | band = pyrLow(pyr,pind); | ||
| 128 | av = mean2(band); stdev = sqrt(var2(band)); | ||
| 129 | range(nind,:) = [av-2*stdev,av+2*stdev]; | ||
| 130 | |||
| 131 | elseif isstr(range) | ||
| 132 | error(sprintf('Bad RANGE argument: %s',range)) | ||
| 133 | |||
| 134 | elseif ((size(range,1) == 1) & (size(range,2) == 2)) | ||
| 135 | scales = scale.^[0:ht]; | ||
| 136 | if (nbands ~= 1) | ||
| 137 | scales = [scales; scales; scales]; | ||
| 138 | end | ||
| 139 | range = scales(:) * range; % outer product | ||
| 140 | band = pyrLow(pyr,pind); | ||
| 141 | range(nind,:) = range(nind,:) + mean2(band) - mean(range(nind,:)); | ||
| 142 | |||
| 143 | end | ||
| 144 | |||
| 145 | % CLEAR FIGURE: | ||
| 146 | clf; | ||
| 147 | |||
| 148 | if (nbands == 1) | ||
| 149 | |||
| 150 | %%%%% 1D signal: | ||
| 151 | for bnum=1:nind | ||
| 152 | band = pyrBand(pyr,pind,bnum); | ||
| 153 | subplot(nind,1,nind-bnum+1); | ||
| 154 | plot(band); | ||
| 155 | axis([1, prod(size(band)), range(bnum,:)]); | ||
| 156 | end | ||
| 157 | |||
| 158 | else | ||
| 159 | |||
| 160 | %%%%% 2D signal: | ||
| 161 | colormap(gray); | ||
| 162 | cmap = get(gcf,'Colormap'); | ||
| 163 | nshades = size(cmap,1); | ||
| 164 | |||
| 165 | % Find background color index: | ||
| 166 | clr = get(gcf,'Color'); | ||
| 167 | bg = 1; | ||
| 168 | dist = norm(cmap(bg,:)-clr); | ||
| 169 | for n = 1:nshades | ||
| 170 | ndist = norm(cmap(n,:)-clr); | ||
| 171 | if (ndist < dist) | ||
| 172 | dist = ndist; | ||
| 173 | bg = n; | ||
| 174 | end | ||
| 175 | end | ||
| 176 | |||
| 177 | %% Compute positions of subbands: | ||
| 178 | llpos = ones(nind,2); | ||
| 179 | for lnum = 1:ht | ||
| 180 | ind1 = nbands*(lnum-1) + 1; | ||
| 181 | xpos = pind(ind1,2) + 1 + gap*(ht-lnum+1); | ||
| 182 | ypos = pind(ind1+1,1) + 1 + gap*(ht-lnum+1); | ||
| 183 | llpos(ind1:ind1+2,:) = [ypos 1; 1 xpos; ypos xpos]; | ||
| 184 | end | ||
| 185 | llpos(nind,:) = [1 1]; %lowpass | ||
| 186 | |||
| 187 | %% Make position list positive, and allocate appropriate image: | ||
| 188 | llpos = llpos - ones(nind,1)*min(llpos) + 1; | ||
| 189 | urpos = llpos + pind - 1; | ||
