diff options
Diffstat (limited to 'SD-VBS/benchmarks/texture_synthesis/src/matlab/showSpyr.m')
-rwxr-xr-x | SD-VBS/benchmarks/texture_synthesis/src/matlab/showSpyr.m | 188 |
1 files changed, 0 insertions, 188 deletions
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/showSpyr.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/showSpyr.m deleted file mode 100755 index da85715..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/showSpyr.m +++ /dev/null | |||
@@ -1,188 +0,0 @@ | |||
1 | % RANGE = showSpyr (PYR, INDICES, RANGE, GAP, LEVEL_SCALE_FACTOR) | ||
2 | % | ||
3 | % Display a steerable pyramid, specified by PYR and INDICES | ||
4 | % (see buildSpyr), in the current figure. The highpass band is not shown. | ||
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 'auto2'. | ||
16 | % | ||
17 | % GAP (optional, default=1) specifies the gap in pixels to leave | ||
18 | % between subbands. | ||
19 | % | ||
20 | % LEVEL_SCALE_FACTOR indicates the relative scaling between pyramid | ||
21 | % levels. This should be set to the sum of the kernel taps of the | ||
22 | % lowpass filter used to construct the pyramid (default is 2, which is | ||
23 | % correct for L2-normalized filters. | ||
24 | |||
25 | % Eero Simoncelli, 2/97. | ||
26 | |||
27 | function [range] = showSpyr(pyr, pind, range, gap, scale); | ||
28 | |||
29 | nbands = spyrNumBands(pind); | ||
30 | |||
31 | %------------------------------------------------------------ | ||
32 | %% OPTIONAL ARGS: | ||
33 | |||
34 | if (exist('range') ~= 1) | ||
35 | range = 'auto2'; | ||
36 | end | ||
37 | |||
38 | if (exist('gap') ~= 1) | ||
39 | gap = 1; | ||
40 | end | ||
41 | |||
42 | if (exist('scale') ~= 1) | ||
43 | scale = 2; | ||
44 | end | ||
45 | |||
46 | %------------------------------------------------------------ | ||
47 | |||
48 | ht = spyrHt(pind); | ||
49 | nind = size(pind,1); | ||
50 | |||
51 | %% Auto range calculations: | ||
52 | if strcmp(range,'auto1') | ||
53 | range = ones(nind,1); | ||
54 | band = spyrHigh(pyr,pind); | ||
55 | [mn,mx] = range2(band); | ||
56 | for lnum = 1:ht | ||
57 | for bnum = 1:nbands | ||
58 | band = spyrBand(pyr,pind,lnum,bnum)/(scale^(lnum-1)); | ||
59 | range((lnum-1)*nbands+bnum+1) = scale^(lnum-1); | ||
60 | [bmn,bmx] = range2(band); | ||
61 | mn = min(mn, bmn); | ||
62 | mx = max(mx, bmx); | ||
63 | end | ||
64 | end | ||
65 | range = range * [mn mx]; % outer product | ||
66 | band = pyrLow(pyr,pind); | ||
67 | [mn,mx] = range2(band); | ||
68 | range(nind,:) = [mn, mx]; | ||
69 | |||
70 | elseif strcmp(range,'indep1') | ||
71 | range = zeros(nind,2); | ||
72 | for bnum = 1:nind | ||
73 | band = pyrBand(pyr,pind,bnum); | ||
74 | [mn,mx] = range2(band); | ||
75 | range(bnum,:) = [mn mx]; | ||
76 | end | ||
77 | |||
78 | elseif strcmp(range,'auto2') | ||
79 | range = ones(nind,1); | ||
80 | band = spyrHigh(pyr,pind); | ||
81 | sqsum = sum(sum(band.^2)); numpixels = prod(size(band)); | ||
82 | for lnum = 1:ht | ||
83 | for bnum = 1:nbands | ||
84 | band = spyrBand(pyr,pind,lnum,bnum)/(scale^(lnum-1)); | ||
85 | sqsum = sqsum + sum(sum(band.^2)); | ||
86 | numpixels = numpixels + prod(size(band)); | ||
87 | range((lnum-1)*nbands+bnum+1) = scale^(lnum-1); | ||
88 | end | ||
89 | end | ||
90 | stdev = sqrt(sqsum/(numpixels-1)); | ||
91 | range = range * [ -3*stdev 3*stdev ]; % outer product | ||
92 | band = pyrLow(pyr,pind); | ||
93 | av = mean2(band); stdev = sqrt(var2(band)); | ||
94 | range(nind,:) = [av-2*stdev,av+2*stdev]; | ||
95 | |||
96 | elseif strcmp(range,'indep2') | ||
97 | range = zeros(nind,2); | ||
98 | for bnum = 1:(nind-1) | ||
99 | band = pyrBand(pyr,pind,bnum); | ||
100 | stdev = sqrt(var2(band)); | ||
101 | range(bnum,:) = [ -3*stdev 3*stdev ]; | ||
102 | end | ||
103 | band = pyrLow(pyr,pind); | ||
104 | av = mean2(band); stdev = sqrt(var2(band)); | ||
105 | range(nind,:) = [av-2*stdev,av+2*stdev]; | ||
106 | |||
107 | elseif isstr(range) | ||
108 | error(sprintf('Bad RANGE argument: %s',range)) | ||
109 | |||
110 | elseif ((size(range,1) == 1) & (size(range,2) == 2)) | ||
111 | scales = scale.^[0:(ht-1)]; | ||
112 | scales = ones(nbands,1) * scales; %outer product | ||
113 | scales = [1; scales(:); scale^ht]; %tack on highpass and lowpass | ||
114 | range = scales * range; % outer product | ||
115 | band = pyrLow(pyr,pind); | ||
116 | range(nind,:) = range(nind,:) + mean2(band) - mean(range(nind,:)); | ||
117 | |||
118 | end | ||
119 | |||
120 | % CLEAR FIGURE: | ||
121 | clf; | ||
122 | |||
123 | colormap(gray); | ||
124 | cmap = get(gcf,'Colormap'); | ||
125 | nshades = size(cmap,1); | ||
126 | |||
127 | % Find background color index: | ||
128 | clr = get(gcf,'Color'); | ||
129 | bg = 1; | ||
130 | dist = norm(cmap(bg,:)-clr); | ||
131 | for n = 1:nshades | ||
132 | ndist = norm(cmap(n,:)-clr); | ||
133 | if (ndist < dist) | ||
134 | dist = ndist; | ||
135 | bg = n; | ||
136 | end | ||
137 | end | ||
138 | |||
139 | %% Compute positions of subbands: | ||
140 | llpos = ones(nind,2); | ||
141 | |||
142 | if (nbands == 2) | ||
143 | ncols = 1; nrows = 2; | ||
144 | else | ||
145 | ncols = ceil((nbands+1)/2); nrows = ceil(nbands/2); | ||
146 | end | ||
147 | relpos = [ (1-nrows):0, zeros(1,(ncols-1)); ... | ||
148 | zeros(1,nrows), -1:-1:(1-ncols) ]'; | ||
149 | if (nbands > 1) | ||
150 | mvpos = [-1 -1]; | ||
151 | else | ||
152 | mvpos = [0 -1]; | ||
153 | end | ||
154 | basepos = [0 0]; | ||
155 | |||
156 | for lnum = 1:ht | ||
157 | ind1 = (lnum-1)*nbands + 2; | ||
158 | sz = pind(ind1,:)+gap; | ||
159 | basepos = basepos + mvpos .* sz; | ||
160 | if (nbands < 5) % to align edges... | ||
161 | sz = sz + gap*(ht-lnum+1); | ||
162 | end | ||
163 | llpos(ind1:ind1+nbands-1,:) = relpos * diag(sz) + ones(nbands,1)*basepos; | ||
164 | end | ||
165 | |||
166 | % lowpass band | ||
167 | sz = pind(nind-1,:)+gap; | ||
168 | basepos = basepos + mvpos .* sz; | ||
169 | llpos(nind,:) = basepos; | ||
170 | |||
171 | %% Make position list positive, and allocate appropriate image: | ||
172 | llpos = llpos - ones(nind,1)*min(llpos) + 1; | ||
173 | llpos(1,:) = [1 1]; | ||
174 | urpos = llpos + pind - 1; | ||
175 | d_im = bg + zeros(max(urpos)); | ||
176 | |||
177 | %% Paste bands into image, (im-r1)*(nshades-1)/(r2-r1) + 1.5 | ||
178 | for bnum=2:nind | ||
179 | mult = (nshades-1) / (range(bnum,2)-range(bnum,1)); | ||
180 | d_im(llpos(bnum,1):urpos(bnum,1), llpos(bnum,2):urpos(bnum,2)) = ... | ||
181 | mult*pyrBand(pyr,pind,bnum) + (1.5-mult*range(bnum,1)); | ||
182 | end | ||
183 | |||
184 | hh = image(d_im); | ||
185 | axis('off'); | ||
186 | pixelAxes(size(d_im),'full'); | ||
187 | set(hh,'UserData',range); | ||
188 | |||