summaryrefslogtreecommitdiffstats
path: root/SD-VBS/benchmarks/texture_synthesis/src/matlab/showSpyr.m
diff options
context:
space:
mode:
Diffstat (limited to 'SD-VBS/benchmarks/texture_synthesis/src/matlab/showSpyr.m')
-rwxr-xr-xSD-VBS/benchmarks/texture_synthesis/src/matlab/showSpyr.m188
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
27function [range] = showSpyr(pyr, pind, range, gap, scale);
28
29nbands = spyrNumBands(pind);
30
31%------------------------------------------------------------
32%% OPTIONAL ARGS:
33
34if (exist('range') ~= 1)
35 range = 'auto2';
36end
37
38if (exist('gap') ~= 1)
39 gap = 1;
40end
41
42if (exist('scale') ~= 1)
43 scale = 2;
44end
45
46%------------------------------------------------------------
47
48ht = spyrHt(pind);
49nind = size(pind,1);
50
51%% Auto range calculations:
52if 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
70elseif 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
78elseif 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
96elseif 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
107elseif isstr(range)
108 error(sprintf('Bad RANGE argument: %s',range))
109
110elseif ((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
118end
119
120% CLEAR FIGURE:
121clf;
122
123colormap(gray);
124cmap = get(gcf,'Colormap');
125nshades = size(cmap,1);
126
127% Find background color index:
128clr = get(gcf,'Color');
129bg = 1;
130dist = norm(cmap(bg,:)-clr);
131for n = 1:nshades
132 ndist = norm(cmap(n,:)-clr);
133 if (ndist < dist)
134 dist = ndist;
135 bg = n;
136 end
137end
138
139%% Compute positions of subbands:
140llpos = ones(nind,2);
141
142if (nbands == 2)
143 ncols = 1; nrows = 2;
144else
145 ncols = ceil((nbands+1)/2); nrows = ceil(nbands/2);
146end
147relpos = [ (1-nrows):0, zeros(1,(ncols-1)); ...
148 zeros(1,nrows), -1:-1:(1-ncols) ]';
149if (nbands > 1)
150 mvpos = [-1 -1];
151else
152 mvpos = [0 -1];
153end
154basepos = [0 0];
155
156for 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;
164end
165
166% lowpass band
167sz = pind(nind-1,:)+gap;
168basepos = basepos + mvpos .* sz;
169llpos(nind,:) = basepos;
170
171%% Make position list positive, and allocate appropriate image:
172llpos = llpos - ones(nind,1)*min(llpos) + 1;
173llpos(1,:) = [1 1];
174urpos = llpos + pind - 1;
175d_im = bg + zeros(max(urpos));
176
177%% Paste bands into image, (im-r1)*(nshades-1)/(r2-r1) + 1.5
178for 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));
182end
183
184hh = image(d_im);
185axis('off');
186pixelAxes(size(d_im),'full');
187set(hh,'UserData',range);
188