diff options
Diffstat (limited to 'SD-VBS/benchmarks/texture_synthesis')
256 files changed, 0 insertions, 19022 deletions
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/ChangeLog b/SD-VBS/benchmarks/texture_synthesis/src/matlab/ChangeLog deleted file mode 100755 index f20c499..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/ChangeLog +++ /dev/null | |||
@@ -1,430 +0,0 @@ | |||
1 | Log of changes made to matlabPyrTools code | ||
2 | (important changes marked with **) | ||
3 | ----------------------------------------------------------------------- | ||
4 | 2004-10-14 Eero Simoncelli <eero@sesto.cns.nyu.edu> | ||
5 | |||
6 | * Made new tarfile (version 1.3) | ||
7 | |||
8 | * Incorporated complex-valued steerable pyramid code (buildSCFpyr, | ||
9 | buildSCFpyrLevs,reconSCFpyr) written by Javier Portilla in 9/97, | ||
10 | and used in our work on texture representation/synthesis | ||
11 | (Portilla&Simoncelli, Int'l Journal of Computer Vision, | ||
12 | 40(1):49-71, Dec 2000). | ||
13 | |||
14 | * Incorporated imGradient.m from personal code. | ||
15 | |||
16 | * reagan.pgm out. feynam.pgm in | ||
17 | |||
18 | 2004-03-20 Eero Simoncelli <eero@sesto.cns.nyu.edu> | ||
19 | |||
20 | * blur.m added (just calls blurDn and then upBlur). | ||
21 | |||
22 | 2003-08-06 Eero Simoncelli <eero@sesto.cns.nyu.edu> | ||
23 | |||
24 | * blurDn.m (filt): Forced correct scaling of filters in 1D | ||
25 | |||
26 | 2003-05-28 Eero Simoncelli <eero@ferrando.cns.nyu.edu> | ||
27 | |||
28 | * incorporated setPyrBand.m from local code | ||
29 | |||
30 | 2002-10-01 Eero Simoncelli <eero.simoncelli@nyu.edu> | ||
31 | |||
32 | * incorporated clip.m from local code | ||
33 | |||
34 | 2002-09-18 Eero Simoncelli <eero.simoncelli@nyu.edu> | ||
35 | |||
36 | * pointOp.m: Added the new 'extrap' option for matlab's interp1 to | ||
37 | make this m-file version more compatible with the mex version. | ||
38 | |||
39 | Wed Aug 28 2002 Eero Simoncelli <eero.simoncelli@nyu.edu> | ||
40 | |||
41 | * var2.m: now returns zero (instead of error) for matrix of size 1. | ||
42 | * function VECTORIZE renamed to VECTIFY, since it was colliding | ||
43 | with a function introduced in standard matlab. | ||
44 | |||
45 | Dec 27 2001 Eero Simoncelli <eero.simoncelli@nyu.edu> | ||
46 | |||
47 | * Modified calls to upConv in reconSpyr.m and reconSpyrLevs.m so | ||
48 | that the returned result is bound. Previously, had relied on the | ||
49 | MEX version of upConv to destructively modify the result array, | ||
50 | users had been getting errors because they were using the m-file | ||
51 | version of upConv. | ||
52 | |||
53 | Wed Sep 19 2001 Eero Simoncelli <eero.simoncelli@nyu.edu> | ||
54 | |||
55 | * buildSFpyrLevs/reconSFpyrLevs: replace use of "i" with sqrt(-1), to | ||
56 | avoid problems if user rebinds it! | ||
57 | |||
58 | Wed Mar 28 10:22:01 2001 Eero Simoncelli <eero.simoncelli@nyu.edu> | ||
59 | |||
60 | * Moved innerProd.m and all associated MEX files from the | ||
61 | matlabLocal source tree into matlabPyrTools. | ||
62 | * Added innerProd to Contents.m | ||
63 | * Updated/clarified WARNINGS in all *.m files that have MEX versions. | ||
64 | |||
65 | Tue Mar 27 11:21:53 2001 Eero Simoncelli <eero.simoncelli@nyu.edu> | ||
66 | |||
67 | * Incorporated Windows MEX files (*.dll) into MEX subdirectory. | ||
68 | Windows users should either copy these into the main directory, | ||
69 | or put the MEX subdirectory in their matlab path. | ||
70 | |||
71 | Fri Mar 23 14:46:16 2001 Eero Simoncelli <eero.simoncelli@nyu.edu> | ||
72 | |||
73 | * buildSFpyrLevs.m, reconSFpyrLevs.m: shift the raised-cosine | ||
74 | lookup table (Xrcos) instead of incrementing the log-radial image | ||
75 | (log_rad). THis is more efficient... | ||
76 | |||
77 | Fri Oct 1 19:37:03 1999 Eero Simoncelli <eero.simoncelli@nyu.edu> | ||
78 | |||
79 | * upConv.m: Did not return correct size result when STOP argument | ||
80 | was passed. Thanks to hertzman@mrl.nyu.edu for pointing this out. | ||
81 | |||
82 | Fri Sep 17 15:53:26 1999 Eero Simoncelli <eero.simoncelli@nyu.edu> | ||
83 | |||
84 | * buildSFpyrLevs.m: Changed lutsize to 1024, giving a slight | ||
85 | increase in accuracy. | ||
86 | |||
87 | Thu Feb 25 18:10:38 1999 Eero Simoncelli <eero.simoncelli@nyu.edu> | ||
88 | |||
89 | * histo1.m: Modified histo.m to be more compatible (but still not | ||
90 | exactly the same) as the MEX file version. | ||
91 | |||
92 | Fri Jun 12 21:15:39 1998 Eero Simoncelli <eero.simoncelli@nyu.edu> | ||
93 | |||
94 | * TUTORIALS pyramids.m upgraded. | ||
95 | |||
96 | Tue Feb 17 13:22:28 1998 Eero Simoncelli <eero.simoncelli@nyu.edu> | ||
97 | |||
98 | * showIm.m: Dims are now printed followed by the zoom factor. | ||
99 | |||
100 | Mon Oct 13 14:49:51 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
101 | |||
102 | * mkSquare.m: Modified to do raised-cosine soft threshold | ||
103 | transitions. | ||
104 | |||
105 | Tue Oct 7 10:13:51 1997 Eero Simoncelli <eero@chrysothemis.cims.nyu.edu> | ||
106 | |||
107 | * upConv.m: Argument order was wrong (this function is not used | ||
108 | anyway, unless you don't compile the MEX code). - Thanks to | ||
109 | farid@psyche.mit.edu for pointing this out. | ||
110 | |||
111 | Thu Sep 25 16:09:49 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
112 | |||
113 | * MEX/wrap.c: Changed #include <malloc.h> to <stdlib.h>, as | ||
114 | suggested by David Brainard. * Incorporated Mac-compiled mex | ||
115 | files, courtesy of David Brainard. | ||
116 | |||
117 | Sat Sep 6 16:10:25 1997 Eero Simoncelli <eero@chrysothemis.cims.nyu.edu> | ||
118 | |||
119 | * MEX/convolve.h: abstracted out type of images with typedef image_type. | ||
120 | Added ansi declarations. | ||
121 | |||
122 | Fri Aug 29 13:49:16 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
123 | |||
124 | ** showIm.m: Modified to behave better under resizing (and printing): | ||
125 | resets axis units to "normalized". | ||
126 | |||
127 | Thu Aug 28 22:56:52 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
128 | |||
129 | ** MEX/edges.c: reflect1, reflect2, repeat, extend upgraded to work | ||
130 | properly for non-symmetric filters. reflect2 and extend were also | ||
131 | broken for upConv. Added qreflect2 to handle even-length QMF's | ||
132 | which broke under the reflect2 modification. | ||
133 | * Added example code to TUTORIALS/matlabPyrTools to illustrate the | ||
134 | boundary-handling behavior... | ||
135 | |||
136 | Thu Aug 21 13:34:17 1997 Eero Simoncelli <eero@chrysothemis.cims.nyu.edu> | ||
137 | |||
138 | * var2, skew2, kurt2: modified to return complex values for complex images. | ||
139 | * imStats.m: now gives an error for complex args. | ||
140 | |||
141 | Thu Aug 14 15:24:29 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
142 | |||
143 | * Modified shift.m: negated the meaning of the offset parameter, | ||
144 | such that RES=shift(MTX,OFFSET) means RES(POS)=MTX(POS-OFFSET) | ||
145 | (this is more intuitive). | ||
146 | |||
147 | Thu Jul 10 17:06:52 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
148 | |||
149 | * Modified MEX/Makefile-* to be consistent with matlab5: | ||
150 | - call mex instead of cmex | ||
151 | - use -V4 flag (creating matlab v4 compatible binaries) | ||
152 | |||
153 | * showIm.m (xlbl_offset): Modified to use "points" units, so that | ||
154 | printed images look correct. Still slightly busted for arbitrary figure | ||
155 | window sizes and for printing. | ||
156 | |||
157 | * Modified upConv.c: does not return ANYTHING if you pass a result | ||
158 | argument (this had been causing occasional problems with matlab's | ||
159 | memory manager). | ||
160 | |||
161 | Mon Jun 30 12:09:30 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
162 | |||
163 | * reconSFpyr.m (res): now returns real part (oops). | ||
164 | |||
165 | * reconSpyrLevs.m (maxLev): got rid of superfluous nbands argument | ||
166 | (can be calculated from bfilts). | ||
167 | |||
168 | Mon May 26 12:29:54 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
169 | |||
170 | * showIm.m/pgmWrite.m: Modified 'auto3'-scaling to use a | ||
171 | histogram. This gives a significant speedup. | ||
172 | |||
173 | * fixed a few minor bugs in the TUTORIALS, having to do with | ||
174 | matching image sizes to the machine speed... | ||
175 | |||
176 | Sat May 10 17:27:25 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
177 | |||
178 | * pgmWrite.m: fixed auto-scaling bug. Added new scaling | ||
179 | calculations, parallel to those of imShow. | ||
180 | |||
181 | Fri May 9 09:02:56 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
182 | |||
183 | * buildSFpyr.m: Changed NBANDS argument to be ORDER, which is one | ||
184 | less than the number of orientation bands. This is consistent | ||
185 | with the derivative order, and the labels on the spNFilters files. | ||
186 | |||
187 | Tue May 6 19:08:18 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
188 | |||
189 | ** Added buildSFpyr, reconSFpyr: Steerable pyramids constructed | ||
190 | in the Fourier domain. Radial functions tile, with a | ||
191 | raised-cosine falloff. Angular functions are | ||
192 | cos(theta-k\pi/(K+1))^K, where K is the order (number of bands | ||
193 | minus 1). Compared to the convolution version: | ||
194 | + Reconstruction is exact (within floating point errors) | ||
195 | + Can produce any number of orientation bands. | ||
196 | - Typically slower. | ||
197 | - Boundary-handling must be circular. | ||
198 | Could be made much more efficient by taking advantage of symmetries in | ||
199 | the fft! | ||
200 | |||
201 | * Added example usage of Fourier steerable pyramid to TUTORIALS/pyramids.m | ||
202 | |||
203 | * steer.m: fixed for harmonic lists including zero. | ||
204 | |||
205 | Sun May 4 15:16:10 1997 Eero Simoncelli <eero@ferrando.cns.nyu.edu> | ||
206 | |||
207 | * MEX/Makefile-linux: created. | ||
208 | |||
209 | * spyrHt, spyrNumBands: Modified to return 0 for pyramids of height 0. | ||
210 | |||
211 | * reconWpyr.m: utilize desctructive addition in calls to upConv. | ||
212 | |||
213 | * reconSpyr.m: Added error check to ensure consistancy between | ||
214 | pyramid and filter file. Utilize destructive addition in upConv | ||
215 | call on highpass band. Modified to work properly with pyramids of | ||
216 | height 0. | ||
217 | |||
218 | Mon Apr 28 13:38:10 1997 Eero Simoncelli <eero@ferrando.cns.nyu.edu> | ||
219 | |||
220 | * lplot.m: modified to handle complex vectors, use standard MatLab | ||
221 | indices, and show minimal axes. Added xrange parameter to allow | ||
222 | adjustment of X axis labeling. | ||
223 | |||
224 | Sun Apr 27 20:20:41 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
225 | |||
226 | * var2, skew2, kurt2: enhanced to work on complex matrices. | ||
227 | |||
228 | Sat Apr 26 11:16:12 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
229 | |||
230 | * Changed parent directory (and distribution) name: | ||
231 | matlabImTools -> matlabPyrTools | ||
232 | |||
233 | * namedFilter.m: Added two more Daubechies filters, and modified | ||
234 | names to match the reference (e.g., daub2 is now a 4-tap filter). | ||
235 | |||
236 | * Added vectorize.m: trivial function to pack matrix into vector (i.e., | ||
237 | computes mtx(:)). | ||
238 | |||
239 | * Added upBlur.m: Upsample and blur (parallels blurDn). | ||
240 | |||
241 | Sun Apr 13 14:23:38 1997 Eero Simoncelli <eero@chrysothemis.cims.nyu.edu> | ||
242 | |||
243 | * TUTORIALS/pyramids.m: Added plots of Fourier spectra for Wavelet bases. | ||
244 | |||
245 | * make-tar-file: switched from compress to gzip for the | ||
246 | distribution tarfile. | ||
247 | |||
248 | * namedFilter.m: Added a few even-length QMF's from Johnston80. | ||
249 | |||
250 | Fri Apr 11 19:16:21 1997 Eero Simoncelli <eero@chrysothemis.cims.nyu.edu> | ||
251 | |||
252 | * buildWpyr.m, reconWpyr.m: Modified slightly, so that subsampling | ||
253 | lattice is better for even-length filters. | ||
254 | |||
255 | * TUTORIALS/pyramids.m: Substantially overhauled. | ||
256 | |||
257 | Thu Apr 10 15:20:23 1997 Eero Simoncelli <eero@chrysothemis.cims.nyu.edu> | ||
258 | |||
259 | * blurDn.m: added this function to downsample an image by a factor | ||
260 | 2^L. | ||
261 | |||
262 | * Fixed minor bug in upConv.m: errors in image size checking. | ||
263 | |||
264 | Mon Apr 7 13:25:37 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
265 | |||
266 | * Changed TUTORIALS/matlabImTools.m to use histo.mex instead of | ||
267 | matlab's hist. | ||
268 | |||
269 | Wed Apr 2 13:20:55 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
270 | |||
271 | ** Incorporated Denis Pelli's ThinkC and MetroWorks projects for | ||
272 | Macintosh versions of the MEX code, along with MEX binaries. These | ||
273 | are included as an HQX'ed self-extracting archive | ||
274 | (Macintosh-MEX.sit.hqx), in the MEX subdirectory. | ||
275 | |||
276 | Tue Apr 1 15:35:31 1997 Eero Simoncelli <eero@chrysothemis.cims.nyu.edu> | ||
277 | |||
278 | * edges.c: modified by Denis Pelli to support THINK C. * edges.c: | ||
279 | |||
280 | * histo.c, upConv.c, corrDn.c: minor changes in error message | ||
281 | printouts, to work around bugs in THINK C. | ||
282 | |||
283 | * Included Denis Pelli's MacReadMe file in the MEX subdirectory, | ||
284 | which gives instructions for MEX file compilation on a MacIntosh | ||
285 | (PPC or 68k). | ||
286 | |||
287 | * wrap.c, convolve.c, edges.c: added explicit int function | ||
288 | declarations, and return values. | ||
289 | |||
290 | * range2.m/range2.c: A MEX function for fast min/max computation. | ||
291 | Adjusted entropy2.m, histo.m, imStats.m, pgmWrite.m, showIm.m, | ||
292 | showLpyr.m, showSpyr.m, showWpyr.m to call it. | ||
293 | |||
294 | Thu Mar 27 17:23:05 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
295 | |||
296 | ** histo.m/histo.c: Added MEX function HISTO, a fast replacement | ||
297 | for matlab's HIST function. Modified histoMatch.m, entropy2.m to | ||
298 | call it. | ||
299 | |||
300 | * Changed main directory name to matlabImTools. | ||
301 | |||
302 | * Added TUTORIALS/README file. | ||
303 | |||
304 | Wed Mar 19 14:19:51 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
305 | |||
306 | * Changed directory name: MEX_SRC -> MEX | ||
307 | |||
308 | Wed Mar 12 17:00:03 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
309 | |||
310 | * mkGaussian.m: fixed another (X,Y) bug: both dimensions and | ||
311 | cov/mean are now specified in [y,x] order. | ||
312 | |||
313 | Tue Mar 11 19:08:17 1997 Eero Simoncelli <eero@chrysothemis.cims.nyu.edu> | ||
314 | |||
315 | * showSpyr.m: Fixed a bug that was dropping display of one | ||
316 | orientation band when there were more than 2 of them! | ||
317 | |||
318 | Mon Mar 10 19:08:24 1997 Eero Simoncelli <eero@chrysothemis.cims.nyu.edu> | ||
319 | |||
320 | * Added shift.m | ||
321 | |||
322 | * makeSteerMtx -> steerDir2HarmMtx | ||
323 | |||
324 | * Added TUTORIALS/matlab-EPS.m: examples using the code in this | ||
325 | distribution. | ||
326 | |||
327 | Sun Mar 9 17:49:18 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
328 | |||
329 | ** showIm.m: | ||
330 | - args: changed order so that NSHADES is last. | ||
331 | - TITLES: Can now pass a string for IM, which will be evaluated | ||
332 | in the global environment to get the matrix. The string is | ||
333 | used as a title. MATLAB v.5 ONLY!!! | ||
334 | - Added 'auto3' RANGE value, that scales based on percentiles. | ||
335 | THis is more robust to outliers than 'auto2' or 'auto1'. | ||
336 | |||
337 | * pixelAxes.m: Made a more serious attempt to reverse-engineer | ||
338 | Mathworks' image pixelization. It is improved, but still makes | ||
339 | occasional errors. | ||
340 | |||
341 | * Added skew2.m. | ||
342 | |||
343 | Fri Mar 7 10:11:07 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
344 | |||
345 | * pixelAxes.m: Modified to take an optional | ||
346 | ZOOM argument. Fixed dimension ordering bug | ||
347 | (positions are reported (x,y), but mtx dims are (y,x)!) | ||
348 | |||
349 | * showIm.m: Added an optional ZOOM argument. | ||
350 | |||
351 | Thu Mar 6 14:17:19 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
352 | |||
353 | * Added showLpyr, showWpyr, showSpyr. Modified | ||
354 | TUTORIALS/pyramids.m to use them. | ||
355 | |||
356 | * added pixelAxes.m: Adjusts size (in pixels) of currently | ||
357 | displayed image to be a multiple of the matrix dimensions, | ||
358 | thus eliminating display aliasing artifacts. | ||
359 | This is now called by all the "show" commands. | ||
360 | |||
361 | Mon Mar 3 17:33:25 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
362 | |||
363 | * Fixed bug in pgmWrite (dimensions were written in reverse order). | ||
364 | |||
365 | * Fixed bug in showIm (X and Y coords were swapped on label display). | ||
366 | |||
367 | * Fixed bug in reconLpyr (swapped X and Y coords on int_sz) | ||
368 | |||
369 | * Changed calls to "reshape" to pass dimensions individually -- | ||
370 | older version of matlab do not accept the reshape(mtx,[y x]) form. | ||
371 | |||
372 | * Fixed bug in mkDisc: sz a scalar. | ||
373 | |||
374 | * Added ifftshift.m | ||
375 | |||
376 | Fri Feb 28 11:07:20 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
377 | |||
378 | * Re-worked TUTORIALS/pyramids.m | ||
379 | |||
380 | * buildGpyr and buildLpyr now use 1+maxPyrHt for default height. | ||
381 | |||
382 | * Fixed buildGpyr to work on 1D signals. | ||
383 | |||
384 | ** Gaussian/Laplacian/Wavelet pyramid build and recon functions: | ||
385 | - work properly with new corrDn/upConv. | ||
386 | - use separable convolutions | ||
387 | - use destructive modification ability of upConv (less memory | ||
388 | allocation) | ||
389 | |||
390 | * modulateFlipShift -> modulateFlip. | ||
391 | |||
392 | * added lpyrHt, wpyrHt, spyrHt to return number of levels in a pyramid. | ||
393 | |||
394 | Thu Feb 27 15:39:53 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
395 | |||
396 | * Changed angular coordinate systems to CLOCKWISE in mkRamp, | ||
397 | mkTheta, mkSine, mkSquare. This is unnatural for screen viewing, | ||
398 | but consistent with an origin in the upper left corner of the | ||
399 | image, which is the way one addresses the underlying matrix. | ||
400 | |||
401 | * mkSine and mkSquare can now take a frequency vector or the | ||
402 | period and direction args | ||
403 | |||
404 | Tue Feb 25 11:58:33 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
405 | |||
406 | ** Rewrote corrDn/upConv C routines: | ||
407 | - more efficient | ||
408 | - changed START parameters to have [1 1] origin, consistent with | ||
409 | matlab | ||
410 | - added STOP parameters | ||
411 | - upConv allows destructive modification of a result arg | ||
412 | - changed order of other params (sorry) | ||
413 | - wrote test file conv_test.m | ||
414 | * wrote zconv2.m | ||
415 | |||
416 | Wed Aug 19 20:39:15 1996 Eero Simoncelli (eero@tarpon.cis.upenn.edu) | ||
417 | |||
418 | ** Added "pointOp" function (MUCH faster than interp1). | ||
419 | ** Added "histoMatch" function. | ||
420 | |||
421 | Fri Aug 2 00:56:31 1996 Eero Simoncelli (eero@tarpon.cis.upenn.edu) | ||
422 | |||
423 | * Changed all function/file-names to be of the form "fooBar". * | ||
424 | Fixed entropy2.m (busted due to typo). | ||
425 | |||
426 | Original convolution code was written in Spring 1986, and comes from | ||
427 | OBVIUS (Object-Based Vision and Image Understanding System), an | ||
428 | interactive image-processing system written in Common Lisp (with calls | ||
429 | to C code). | ||
430 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/Contents.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/Contents.m deleted file mode 100755 index d19f067..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/Contents.m +++ /dev/null | |||
@@ -1,107 +0,0 @@ | |||
1 | % Image and Multi-scale Pyramid Tools | ||
2 | % Version 1.3, October 2004. | ||
3 | % Created: Early Spring, 1996. Eero Simoncelli, eero.simoncelli@nyu.edu | ||
4 | % | ||
5 | % See README file for brief description. | ||
6 | % See ChangeLog file for latest modifications. | ||
7 | % See TUTORIALS subdirectory for demonstrations. | ||
8 | % Type "help <command-name>" for documentation on individual commands. | ||
9 | % ----------------------------------------------------------------- | ||
10 | % Synthetic Images (matrices): | ||
11 | % mkImpulse - Make an image containing an impulse. | ||
12 | % mkRamp - Make an image containing a ramp function. | ||
13 | % mkR - Make an image containing distance from the origin. | ||
14 | % mkAngle - Make an image containing angle about origin. | ||
15 | % mkDisc - Make an image containing a disk image. | ||
16 | % mkGaussian - Make an image containing a Gaussian function. | ||
17 | % mkZonePlate - Make an image containing a zone plate (cos(r^2)). | ||
18 | % mkAngularSine - Make an image containing an angular sine wave (pinwheel). | ||
19 | % mkSine - Make an image containing a sine grating. | ||
20 | % mkSquare - Make an image containing a square grating. | ||
21 | % mkFract - Make an image containing fractal (1/f) noise. | ||
22 | % | ||
23 | % Point Operations: | ||
24 | % clip - clip values to a range. | ||
25 | % pointOp - Lookup table (much faster than interp1) [MEX file] | ||
26 | % histo - Efficient histogram computation [MEX file] | ||
27 | % histoMatch - Modify matrix elements to match specified histogram stats. | ||
28 | % | ||
29 | % Convolution (first two are significantly faster): | ||
30 | % corrDn - Correlate & downsample with boundary-handling [MEX file] | ||
31 | % upConv - Upsample & convolve with boundary-handling [MEX file] | ||
32 | % blurDn - Blur and subsample a signal/image. | ||
33 | % upBlur - Upsample and blur a signal/image. | ||
34 | % blur - Multi-scale blurring, calls blurDn and then upBlur. | ||
35 | % cconv2 - Circular convolution. | ||
36 | % rconv2 - Convolution with reflected boundaries. | ||
37 | % zconv2 - Convolution assuming zeros beyond image boundaries. | ||
38 | % | ||
39 | % General pyramids: | ||
40 | % pyrLow - Access lowpass subband from (any type of) pyramid | ||
41 | % pyrBand - Access a subband from (any type of) pyramid | ||
42 | % setPyrBand - Insert an image into (any type of) pyramid as a subband | ||
43 | % pyrBandIndices - Returns indices for given band in a pyramid vector | ||
44 | % maxPyrHt - compute maximum number of scales in a pyramid | ||
45 | % | ||
46 | % Gaussian/Laplacian Pyramids: | ||
47 | % buildGpyr - Build a Gaussian pyramid of an input signal/image. | ||
48 | % buildLpyr - Build a Laplacian pyramid of an input signal/image. | ||
49 | % reconLpyr - Reconstruct (invert) the Laplacian pyramid transform. | ||
50 | % | ||
51 | % Separable orthonormal QMF/wavelet Pyramids: | ||
52 | % buildWpyr - Build a separable wavelet representation of an input signal/image. | ||
53 | % reconWpyr - Reconstruct (invert) the wavelet transform. | ||
54 | % wpyrBand - Extract a single band of the wavelet representation. | ||
55 | % wpyrLev - Extract (packed) subbands at a particular level | ||
56 | % wpyrHt - Number of levels (height) of a wavelet pyramid. | ||
57 | % | ||
58 | % Steerable Pyramids: | ||
59 | % buildSpyr - Build a steerable pyramid representation of an input image. | ||
60 | % reconSpyr - Reconstruct (invert) the steerable pyramid transform. | ||
61 | % buildSFpyr - Build a steerable pyramid representation in the Fourier domain. | ||
62 | % reconSFpyr - Reconstruct (invert) the (Fourier domain) steerable pyramid transform. | ||
63 | % spyrBand - Extract a single band from a steerable pyramid. | ||
64 | % spyrHigh - Highpass residual band. | ||
65 | % spyrLev - A whole level (i.e., all images at a given scale) of a steerable pyramid. | ||
66 | % spyrHt - Number of levels (height) of a steerable pyramid. | ||
67 | % spyrNumBands - Number of orientation bands in a steerable pyramid. | ||
68 | % | ||
69 | % Steerable filters / derivatives: | ||
70 | % imGradient - Compute gradient of image using directionally accurete filters. | ||
71 | % steer - Steer filters (or responses). | ||
72 | % steer2HarmMtx - Construct a matrix mapping direcional basis to angular harmonics. | ||
73 | % | ||
74 | % Filters: | ||
75 | % binomialFilter - returns a filter of binomial coefficients. | ||
76 | % namedFilter - some typical Laplacian/Wavelet pyramid filters | ||
77 | % spNFilters - Set of Nth order steerable pyramid filters. | ||
78 | % derivNFiltersS - Matched set of S-tap 1D derivatives, orders 0 to N. | ||
79 | % | ||
80 | % Display: | ||
81 | % showIm - Display a matrix (real or complex) as grayscale image(s). | ||
82 | % Displays dimensions, subsampling, and range of pixel values. | ||
83 | % showLpyr - Display a Laplacian pyramid. | ||
84 | % showWpyr - Display a separable wavelet pyramid. | ||
85 | % showSpyr - Display a steerable pyramid. | ||
86 | % lplot - "lollipop" plot. | ||
87 | % nextFig - Make next figure window current. | ||
88 | % pixelAxes - Make image display use an integer number of pixels | ||
89 | % per sample to avoid resampling artifacts. | ||
90 | % | ||
91 | % Statistics (for 2D Matrices): | ||
92 | % range2 - Min and max of image (matrix) [MEX file] | ||
93 | % mean2 - Sample mean of an image (matrix). | ||
94 | % var2 - Sample variance of an image (matrix). | ||
95 | % skew2 - Sample skew (3rd moment / variance^1.5) of an image (matrix). | ||
96 | % kurt2 - Sample kurtosis (4th moment / variance^2) of an image (matrix). | ||
97 | % entropy2 - Sample entropy of an image (matrix). | ||
98 | % imStats - Report sample statistics of an image, or pair of images. | ||
99 | % | ||
100 | % Miscellaneous: | ||
101 | % pgmRead - Load a "pgm" image into a MatLab matrix [try einstein.pgm,feynman.pgm] | ||
102 | % pgmWrite - Write a MatLab matrix to a "pgm" image file. | ||
103 | % shift - circular shift a 2D matrix by an arbitrary amount. | ||
104 | % vectify - pack matrix into column vector (i.e., function to compute mtx(:)). | ||
105 | % ifftshift - inverse of MatLab's FFTSHIFT (differs for odd-length dimensions) | ||
106 | % rcosFn - return a lookup table of a raised-cosine threshold fn. | ||
107 | % innerProd - Compute M'*M efficiently (i.e., do not copy) [MEX file] | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/-MacReadMe b/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/-MacReadMe deleted file mode 100755 index 898dc0c..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/-MacReadMe +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | MacReadMe How to compile a MEX file for Macintosh (Based on a similar note written by David Brainard and Denis Pelli to accompany the Psychophysics Toolbox.) A MEX file (short for "MATLAB extension") contains code that implements a new MATLAB function, allowing users to use the full power of the C language and the Macintosh hardware and operating system in implementing a new MATLAB function. This document explains how to produce a MEX file that is "fat" (i.e. will run as native code on both 68K and PowerPC Macs) and is compatible with both MATLAB 4 and 5. 1) To produce a MATLAB MEX file with PowerPC code you must have the Metrowerks CodeWarrior C compiler (version 10 or better, abbreviated as CW below). To produce 68K code we still use the Symantec THINK C compiler (version from Symantec C++ 8 CD-ROM release 5), but we will soon be switching to Metrowerks CodeWarrior. (See note A below.) 2) Place a copy of the MATLAB 4:Extern folder, supplied by Mathworks, on your compiler's search path. We suggest that you name the copy "MEX V4". (See notes B and C, below.) 3) Build any of the MEX files simply by opening its project file and asking your compiler to "Build Code Resource" (in THINK C) or to "Make" it (in CW). For each MEX file, e.g. histo.mex, there are two associated projects, e.g. histo.µ for CW, and histo.¹.4 for THINK C. To build a "fat" MEX, that runs native on both 68K and PowerPC, you should first compile in THINK C, and then in CW. (See note A, below.) Denis Pelli April 2, 1997 Notes A) The Mathworks support only the THINK C compiler to make 68K MEX code for MATLAB version 4 and only the CW compiler to make PPC MEX files for MATLAB 4 and both 68K and PPC for MATLAB 5. This archive includes THINK and CW projects. To build a fat MEX file for MATLAB 4, first "make" the THINK C version (e.g. histo.¹.4), producing a file with a .rsrc extension (e.g. histo.µ.rsrc). This is the 68K MEX file. When you then "make" histo.µ, the CW project incorporates the .rsrc file and generates a "fat" MEX file that will run native (i.e. fast) on both 68K and PowerPC. To make a 68K-only MEX file, simply rename, e.g., histo.µ.rsrc to histo.mex after you make the THINK project, and set the file type and creator to match the other MEX files. THINK C is slow and hard to work with. Symantec hasn't significantly upgraded in it many years. There is an error in the math.h header (version from Symantec C++ 8 CD-ROM release 5). We fix that error by some tricky preprocessor defines and undefines in the THINK C Prefix in each of the THINK projects. B) The easiest way to put a folder on your compilerÕs search path is simply to put the folder in the same folder as the compiler itself. If you want to use both CW and THINK C, then put the folder under CW, make an alias of it, and put the alias in THINK C's "Aliases" folder. C) Happily, MATLAB 5 is capable of running both V4 and V5 MEX files. Thus we are currently distributing sources that compile into V4 MEX files. The resulting MEX files run both under V4 and V5. In the future we will drop support for V4 and THINK C. (See note A above.) \ No newline at end of file | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/.AppleDouble/.Parent b/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/.AppleDouble/.Parent deleted file mode 100755 index f242a99..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/.AppleDouble/.Parent +++ /dev/null | |||
Binary files differ | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/.FBCIndex b/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/.FBCIndex deleted file mode 100755 index 848736b..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/.FBCIndex +++ /dev/null | |||
Binary files differ | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/.FBCLockFolder/.FBCSemaphoreFile b/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/.FBCLockFolder/.FBCSemaphoreFile deleted file mode 100755 index ab2c684..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/.FBCLockFolder/.FBCSemaphoreFile +++ /dev/null | |||
Binary files differ | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/Makefile-linux b/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/Makefile-linux deleted file mode 100755 index 726dd31..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/Makefile-linux +++ /dev/null | |||
@@ -1,39 +0,0 @@ | |||
1 | MLAB = /usr/local/matlab5.1 | ||
2 | |||
3 | MXSFX = mexlx | ||
4 | MEX = ${MLAB}/bin/mex | ||
5 | |||
6 | MFLAGS = -V4 | ||
7 | INC = -I ${MLAB}/extern/include | ||
8 | LIB = -L ${MLAB}/extern/lib | ||
9 | |||
10 | CC = gcc -Wall -pedantic | ||
11 | C_OPTIMIZE_SWITCH = -O2 ## For GCC | ||
12 | CFLAGS = ${C_OPTIMIZE_SWITCH} ${INC} ${LIB} | ||
13 | |||
14 | all: corrDn.${MXSFX} upConv.${MXSFX} pointOp.${MXSFX} \ | ||
15 | histo.${MXSFX} range2.${MXSFX} | ||
16 | |||
17 | clean: | ||
18 | /bin/rm *.o | ||
19 | |||
20 | corrDn.${MXSFX}: corrDn.o wrap.o convolve.o edges.o | ||
21 | ${MEX} ${MFLAGS} corrDn.o wrap.o convolve.o edges.o | ||
22 | |||
23 | upConv.${MXSFX}: upConv.o wrap.o convolve.o edges.o | ||
24 | ${MEX} ${MFLAGS} upConv.o wrap.o convolve.o edges.o | ||
25 | |||
26 | pointOp.${MXSFX}: pointOp.o | ||
27 | ${MEX} ${MFLAGS} pointOp.o | ||
28 | |||
29 | histo.${MXSFX}: histo.o | ||
30 | ${MEX} ${MFLAGS} histo.o | ||
31 | |||
32 | range2.${MXSFX}: range2.o | ||
33 | ${MEX} ${MFLAGS} range2.o | ||
34 | |||
35 | convolve.o wrap.o edges.o: convolve.h | ||
36 | |||
37 | %.o : %.c | ||
38 | ${CC} -c ${CFLAGS} $< | ||
39 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/Makefile-ml6-linux b/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/Makefile-ml6-linux deleted file mode 100755 index f596ad7..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/Makefile-ml6-linux +++ /dev/null | |||
@@ -1,39 +0,0 @@ | |||
1 | MLAB = /usr/local/matlab6.0 | ||
2 | |||
3 | MXSFX = mexglx | ||
4 | MEX = ${MLAB}/bin/mex | ||
5 | |||
6 | MFLAGS = -V4 | ||
7 | INC = -I ${MLAB}/extern/include | ||
8 | LIB = -L ${MLAB}/extern/lib | ||
9 | |||
10 | CC = gcc -Wall -pedantic | ||
11 | C_OPTIMIZE_SWITCH = -O2 ## For GCC | ||
12 | CFLAGS = ${C_OPTIMIZE_SWITCH} ${INC} ${LIB} | ||
13 | |||
14 | all: corrDn.${MXSFX} upConv.${MXSFX} pointOp.${MXSFX} \ | ||
15 | histo.${MXSFX} range2.${MXSFX} | ||
16 | |||
17 | clean: | ||
18 | /bin/rm *.o | ||
19 | |||
20 | corrDn.${MXSFX}: corrDn.o wrap.o convolve.o edges.o | ||
21 | ${MEX} ${MFLAGS} corrDn.o wrap.o convolve.o edges.o | ||
22 | |||
23 | upConv.${MXSFX}: upConv.o wrap.o convolve.o edges.o | ||
24 | ${MEX} ${MFLAGS} upConv.o wrap.o convolve.o edges.o | ||
25 | |||
26 | pointOp.${MXSFX}: pointOp.o | ||
27 | ${MEX} ${MFLAGS} pointOp.o | ||
28 | |||
29 | histo.${MXSFX}: histo.o | ||
30 | ${MEX} ${MFLAGS} histo.o | ||
31 | |||
32 | range2.${MXSFX}: range2.o | ||
33 | ${MEX} ${MFLAGS} range2.o | ||
34 | |||
35 | convolve.o wrap.o edges.o: convolve.h | ||
36 | |||
37 | %.o : %.c | ||
38 | ${CC} -c ${CFLAGS} $< | ||
39 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/Makefile-osx b/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/Makefile-osx deleted file mode 100755 index 352d15b..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/Makefile-osx +++ /dev/null | |||
@@ -1,39 +0,0 @@ | |||
1 | MLAB = /share/wotan/matlab13 | ||
2 | |||
3 | MXSFX = mexosx | ||
4 | MEX = ${MLAB}/bin/mex | ||
5 | |||
6 | MFLAGS = | ||
7 | INC = -I ${MLAB}/extern/include | ||
8 | LIB = -L ${MLAB}/extern/lib | ||
9 | |||
10 | CC = cc -Wall -pedantic -no-cpp-precomp | ||
11 | C_OPTIMIZE_SWITCH = -O2 ## For GCC | ||
12 | CFLAGS = ${C_OPTIMIZE_SWITCH} ${INC} ${LIB} | ||
13 | |||
14 | all: corrDn.${MXSFX} upConv.${MXSFX} pointOp.${MXSFX} \ | ||
15 | histo.${MXSFX} range2.${MXSFX} | ||
16 | |||
17 | clean: | ||
18 | /bin/rm *.o | ||
19 | |||
20 | corrDn.${MXSFX}: corrDn.o wrap.o convolve.o edges.o | ||
21 | ${MEX} ${MFLAGS} corrDn.o wrap.o convolve.o edges.o | ||
22 | |||
23 | upConv.${MXSFX}: upConv.o wrap.o convolve.o edges.o | ||
24 | ${MEX} ${MFLAGS} upConv.o wrap.o convolve.o edges.o | ||
25 | |||
26 | pointOp.${MXSFX}: pointOp.o | ||
27 | ${MEX} ${MFLAGS} pointOp.o | ||
28 | |||
29 | histo.${MXSFX}: histo.o | ||
30 | ${MEX} ${MFLAGS} histo.o | ||
31 | |||
32 | range2.${MXSFX}: range2.o | ||
33 | ${MEX} ${MFLAGS} range2.o | ||
34 | |||
35 | convolve.o wrap.o edges.o: convolve.h | ||
36 | |||
37 | %.o : %.c | ||
38 | ${CC} -c ${CFLAGS} $< | ||
39 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/Makefile-solaris b/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/Makefile-solaris deleted file mode 100755 index 2be2bdb..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/Makefile-solaris +++ /dev/null | |||
@@ -1,38 +0,0 @@ | |||
1 | MLAB = /export/home/Solaris2/matlab5.1 | ||
2 | |||
3 | MXSFX = mexsol | ||
4 | MEX = ${MLAB}/bin/mex | ||
5 | |||
6 | MFLAGS = -V4 | ||
7 | INC = -I ${MLAB}/extern/include | ||
8 | LIB = -L ${MLAB}/extern/lib | ||
9 | |||
10 | CC = gcc -Wall -pedantic | ||
11 | C_OPTIMIZE_SWITCH = -O2 ## For GCC | ||
12 | CFLAGS = ${C_OPTIMIZE_SWITCH} ${INC} ${LIB} | ||
13 | |||
14 | all: corrDn.${MXSFX} upConv.${MXSFX} pointOp.${MXSFX} \ | ||
15 | histo.${MXSFX} range2.${MXSFX} | ||
16 | |||
17 | clean: | ||
18 | /bin/rm *.o | ||
19 | |||
20 | corrDn.${MXSFX}: corrDn.o wrap.o convolve.o edges.o | ||
21 | ${MEX} ${MFLAGS} corrDn.o wrap.o convolve.o edges.o | ||
22 | |||
23 | upConv.${MXSFX}: upConv.o wrap.o convolve.o edges.o | ||
24 | ${MEX} ${MFLAGS} upConv.o wrap.o convolve.o edges.o | ||
25 | |||
26 | pointOp.${MXSFX}: pointOp.o | ||
27 | ${MEX} ${MFLAGS} pointOp.o | ||
28 | |||
29 | histo.${MXSFX}: histo.o | ||
30 | ${MEX} ${MFLAGS} histo.o | ||
31 | |||
32 | range2.${MXSFX}: range2.o | ||
33 | ${MEX} ${MFLAGS} range2.o | ||
34 | |||
35 | convolve.o wrap.o edges.o: convolve.h | ||
36 | |||
37 | %.o : %.c | ||
38 | ${CC} -c ${CFLAGS} $< | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/Makefile-sun4 b/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/Makefile-sun4 deleted file mode 100755 index 432b181..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/Makefile-sun4 +++ /dev/null | |||
@@ -1,39 +0,0 @@ | |||
1 | MLAB = /home/alberich/matlab4 | ||
2 | |||
3 | MXSFX = mex4 | ||
4 | MEX = ${MLAB}/bin/cmex | ||
5 | |||
6 | MFLAGS = | ||
7 | INC = -I ${MLAB}/extern/include | ||
8 | LIB = -L ${MLAB}/extern/lib/sun4 | ||
9 | |||
10 | CC = gcc | ||
11 | C_OPTIMIZE_SWITCH = -O2 ## For GCC | ||
12 | CFLAGS = ${C_OPTIMIZE_SWITCH} ${INC} ${LIB} | ||
13 | |||
14 | all: corrDn.${MXSFX} upConv.${MXSFX} pointOp.${MXSFX} \ | ||
15 | histo.${MXSFX} range2.${MXSFX} | ||
16 | |||
17 | clean: | ||
18 | /bin/rm *.o | ||
19 | |||
20 | corrDn.${MXSFX}: corrDn.o wrap.o convolve.o edges.o | ||
21 | ${MEX} ${MFLAGS} corrDn.o wrap.o convolve.o edges.o | ||
22 | |||
23 | upConv.${MXSFX}: upConv.o wrap.o convolve.o edges.o | ||
24 | ${MEX} ${MFLAGS} upConv.o wrap.o convolve.o edges.o | ||
25 | |||
26 | pointOp.${MXSFX}: pointOp.o | ||
27 | ${MEX} ${MFLAGS} pointOp.o | ||
28 | |||
29 | histo.${MXSFX}: histo.o | ||
30 | ${MEX} ${MFLAGS} histo.o | ||
31 | |||
32 | range2.${MXSFX}: range2.o | ||
33 | ${MEX} ${MFLAGS} range2.o | ||
34 | |||
35 | convolve.o wrap.o edges.o: convolve.h | ||
36 | |||
37 | %.o : %.c | ||
38 | ${CC} -c ${CFLAGS} $< | ||
39 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/convolve.c b/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/convolve.c deleted file mode 100755 index 60a11a4..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/convolve.c +++ /dev/null | |||
@@ -1,325 +0,0 @@ | |||
1 | /* | ||
2 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
3 | ;;; File: convolve.c | ||
4 | ;;; Author: Eero Simoncelli | ||
5 | ;;; Description: General convolution code for 2D images | ||
6 | ;;; Creation Date: Spring, 1987. | ||
7 | ;;; MODIFICATIONS: | ||
8 | ;;; 10/89: approximately optimized the choice of register vars on SPARCS. | ||
9 | ;;; 6/96: Switched array types to double float. | ||
10 | ;;; 2/97: made more robust and readable. Added STOP arguments. | ||
11 | ;;; 8/97: Bug: when calling internal_reduce with edges in {reflect1,repeat, | ||
12 | ;;; extend} and an even filter dimension. Solution: embed the filter | ||
13 | ;;; in the upper-left corner of a filter with odd Y and X dimensions. | ||
14 | ;;; ---------------------------------------------------------------- | ||
15 | ;;; Object-Based Vision and Image Understanding System (OBVIUS), | ||
16 | ;;; Copyright 1988, Vision Science Group, Media Laboratory, | ||
17 | ;;; Massachusetts Institute of Technology. | ||
18 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
19 | */ | ||
20 | |||
21 | #include <stdio.h> | ||
22 | #include <math.h> | ||
23 | #include "convolve.h" | ||
24 | |||
25 | /* | ||
26 | -------------------------------------------------------------------- | ||
27 | Correlate FILT with IMAGE, subsampling according to START, STEP, and | ||
28 | STOP parameters, with values placed into RESULT array. RESULT | ||
29 | dimensions should be ceil((stop-start)/step). TEMP should be a | ||
30 | pointer to a temporary double array the size of the filter. | ||
31 | EDGES is a string specifying how to handle boundaries -- see edges.c. | ||
32 | The convolution is done in 9 sections, where the border sections use | ||
33 | specially computed edge-handling filters (see edges.c). The origin | ||
34 | of the filter is assumed to be (floor(x_fdim/2), floor(y_fdim/2)). | ||
35 | ------------------------------------------------------------------------ */ | ||
36 | |||
37 | /* abstract out the inner product computation */ | ||
38 | #define INPROD(XCNR,YCNR) \ | ||
39 | { \ | ||
40 | sum=0.0; \ | ||
41 | for (im_pos=YCNR*x_dim+XCNR, filt_pos=0, x_filt_stop=x_fdim; \ | ||
42 | x_filt_stop<=filt_size; \ | ||
43 | im_pos+=(x_dim-x_fdim), x_filt_stop+=x_fdim) \ | ||
44 | for (; \ | ||
45 | filt_pos<x_filt_stop; \ | ||
46 | filt_pos++, im_pos++) \ | ||
47 | sum+= image[im_pos]*temp[filt_pos]; \ | ||
48 | result[res_pos] = sum; \ | ||
49 | } | ||
50 | |||
51 | int internal_reduce(image, x_dim, y_dim, filt, temp, x_fdim, y_fdim, | ||
52 | x_start, x_step, x_stop, y_start, y_step, y_stop, | ||
53 | result, edges) | ||
54 | register image_type *image, *temp; | ||
55 | register int x_fdim, x_dim; | ||
56 | register image_type *result; | ||
57 | register int x_step, y_step; | ||
58 | int x_start, y_start; | ||
59 | int x_stop, y_stop; | ||
60 | image_type *filt; | ||
61 | int y_dim, y_fdim; | ||
62 | char *edges; | ||
63 | { | ||
64 | register double sum; | ||
65 | register int filt_pos, im_pos, x_filt_stop; | ||
66 | register int x_pos, filt_size = x_fdim*y_fdim; | ||
67 | register int y_pos, res_pos; | ||
68 | register int y_ctr_stop = y_dim - ((y_fdim==1)?0:y_fdim); | ||
69 | register int x_ctr_stop = x_dim - ((x_fdim==1)?0:x_fdim); | ||
70 | register int x_res_dim = (x_stop-x_start+x_step-1)/x_step; | ||
71 | int x_ctr_start = ((x_fdim==1)?0:1); | ||
72 | int y_ctr_start = ((y_fdim==1)?0:1); | ||
73 | int x_fmid = x_fdim/2; | ||
74 | int y_fmid = y_fdim/2; | ||
75 | int base_res_pos; | ||
76 | fptr reflect = edge_function(edges); /* look up edge-handling function */ | ||
77 | |||
78 | if (!reflect) return(-1); | ||
79 | |||
80 | /* shift start/stop coords to filter upper left hand corner */ | ||
81 | x_start -= x_fmid; y_start -= y_fmid; | ||
82 | x_stop -= x_fmid; y_stop -= y_fmid; | ||
83 | |||
84 | if (x_stop < x_ctr_stop) x_ctr_stop = x_stop; | ||
85 | if (y_stop < y_ctr_stop) y_ctr_stop = y_stop; | ||
86 | |||
87 | for (res_pos=0, y_pos=y_start; /* TOP ROWS */ | ||
88 | y_pos<y_ctr_start; | ||
89 | y_pos+=y_step) | ||
90 | { | ||
91 | for (x_pos=x_start; /* TOP-LEFT CORNER */ | ||
92 | x_pos<x_ctr_start; | ||
93 | x_pos+=x_step, res_pos++) | ||
94 | { | ||
95 | (*reflect)(filt,x_fdim,y_fdim,x_pos-1,y_pos-1,temp,REDUCE); | ||
96 | INPROD(0,0) | ||
97 | } | ||
98 | |||
99 | (*reflect)(filt,x_fdim,y_fdim,0,y_pos-1,temp,REDUCE); | ||
100 | for (; /* TOP EDGE */ | ||
101 | x_pos<x_ctr_stop; | ||
102 | x_pos+=x_step, res_pos++) | ||
103 | INPROD(x_pos,0) | ||
104 | |||
105 | for (; /* TOP-RIGHT CORNER */ | ||
106 | x_pos<x_stop; | ||
107 | x_pos+=x_step, res_pos++) | ||
108 | { | ||
109 | (*reflect)(filt,x_fdim,y_fdim,x_pos-x_ctr_stop+1,y_pos-1,temp,REDUCE); | ||
110 | INPROD(x_ctr_stop,0) | ||
111 | } | ||
112 | } /* end TOP ROWS */ | ||
113 | |||
114 | y_ctr_start = y_pos; /* hold location of top */ | ||
115 | for (base_res_pos=res_pos, x_pos=x_start; /* LEFT EDGE */ | ||
116 | x_pos<x_ctr_start; | ||
117 | x_pos+=x_step, base_res_pos++) | ||
118 | { | ||
119 | (*reflect)(filt,x_fdim,y_fdim,x_pos-1,0,temp,REDUCE); | ||
120 | for (y_pos=y_ctr_start, res_pos=base_res_pos; | ||
121 | y_pos<y_ctr_stop; | ||
122 | y_pos+=y_step, res_pos+=x_res_dim) | ||
123 | INPROD(0,y_pos) | ||
124 | } | ||
125 | |||
126 | (*reflect)(filt,x_fdim,y_fdim,0,0,temp,REDUCE); | ||
127 | for (; /* CENTER */ | ||
128 | x_pos<x_ctr_stop; | ||
129 | x_pos+=x_step, base_res_pos++) | ||
130 | for (y_pos=y_ctr_start, res_pos=base_res_pos; | ||
131 | y_pos<y_ctr_stop; | ||
132 | y_pos+=y_step, res_pos+=x_res_dim) | ||
133 | INPROD(x_pos,y_pos) | ||
134 | |||
135 | for (; /* RIGHT EDGE */ | ||
136 | x_pos<x_stop; | ||
137 | x_pos+=x_step, base_res_pos++) | ||
138 | { | ||
139 | (*reflect)(filt,x_fdim,y_fdim,x_pos-x_ctr_stop+1,0,temp,REDUCE); | ||
140 | for (y_pos=y_ctr_start, res_pos=base_res_pos; | ||
141 | y_pos<y_ctr_stop; | ||
142 | y_pos+=y_step, res_pos+=x_res_dim) | ||
143 | INPROD(x_ctr_stop,y_pos) | ||
144 | } | ||
145 | |||
146 | for (res_pos-=(x_res_dim-1); | ||
147 | y_pos<y_stop; /* BOTTOM ROWS */ | ||
148 | y_pos+=y_step) | ||
149 | { | ||
150 | for (x_pos=x_start; /* BOTTOM-LEFT CORNER */ | ||
151 | x_pos<x_ctr_start; | ||
152 | x_pos+=x_step, res_pos++) | ||
153 | { | ||
154 | (*reflect)(filt,x_fdim,y_fdim,x_pos-1,y_pos-y_ctr_stop+1,temp,REDUCE); | ||
155 | INPROD(0,y_ctr_stop) | ||
156 | } | ||
157 | |||
158 | (*reflect)(filt,x_fdim,y_fdim,0,y_pos-y_ctr_stop+1,temp,REDUCE); | ||
159 | for (; /* BOTTOM EDGE */ | ||
160 | x_pos<x_ctr_stop; | ||
161 | x_pos+=x_step, res_pos++) | ||
162 | INPROD(x_pos,y_ctr_stop) | ||
163 | |||
164 | for (; /* BOTTOM-RIGHT CORNER */ | ||
165 | x_pos<x_stop; | ||
166 | x_pos+=x_step, res_pos++) | ||
167 | { | ||
168 | (*reflect)(filt,x_fdim,y_fdim,x_pos-x_ctr_stop+1,y_pos-y_ctr_stop+1,temp,REDUCE); | ||
169 | INPROD(x_ctr_stop,y_ctr_stop) | ||
170 | } | ||
171 | } /* end BOTTOM */ | ||
172 | return(0); | ||
173 | } /* end of internal_reduce */ | ||
174 | |||
175 | |||
176 | /* | ||
177 | -------------------------------------------------------------------- | ||
178 | Upsample IMAGE according to START,STEP, and STOP parameters and then | ||
179 | convolve with FILT, adding values into RESULT array. IMAGE | ||
180 | dimensions should be ceil((stop-start)/step). See | ||
181 | description of internal_reduce (above). | ||
182 | |||
183 | WARNING: this subroutine destructively modifies the RESULT array! | ||
184 | ------------------------------------------------------------------------ */ | ||
185 | |||
186 | /* abstract out the inner product computation */ | ||
187 | #define INPROD2(XCNR,YCNR) \ | ||
188 | { \ | ||
189 | val = image[im_pos]; \ | ||
190 | for (res_pos=YCNR*x_dim+XCNR, filt_pos=0, x_filt_stop=x_fdim; \ | ||
191 | x_filt_stop<=filt_size; \ | ||
192 | res_pos+=(x_dim-x_fdim), x_filt_stop+=x_fdim) \ | ||
193 | for (; \ | ||
194 | filt_pos<x_filt_stop; \ | ||
195 | filt_pos++, res_pos++) \ | ||
196 | result[res_pos] += val*temp[filt_pos]; \ | ||
197 | } | ||
198 | |||
199 | int internal_expand(image,filt,temp,x_fdim,y_fdim, | ||
200 | x_start,x_step,x_stop,y_start,y_step,y_stop, | ||
201 | result,x_dim,y_dim,edges) | ||
202 | register image_type *result, *temp; | ||
203 | register int x_fdim, x_dim; | ||
204 | register int x_step, y_step; | ||
205 | register image_type *image; | ||
206 | int x_start, y_start; | ||
207 | image_type *filt; | ||
208 | int y_fdim, y_dim; | ||
209 | char *edges; | ||
210 | { | ||
211 | register double val; | ||
212 | register int filt_pos, res_pos, x_filt_stop; | ||
213 | register int x_pos, filt_size = x_fdim*y_fdim; | ||
214 | register int y_pos, im_pos; | ||
215 | register int x_ctr_stop = x_dim - ((x_fdim==1)?0:x_fdim); | ||
216 | int y_ctr_stop = (y_dim - ((y_fdim==1)?0:y_fdim)); | ||
217 | int x_ctr_start = ((x_fdim==1)?0:1); | ||
218 | int y_ctr_start = ((y_fdim==1)?0:1); | ||
219 | int x_fmid = x_fdim/2; | ||
220 | int y_fmid = y_fdim/2; | ||
221 | int base_im_pos, x_im_dim = (x_stop-x_start+x_step-1)/x_step; | ||
222 | fptr reflect = edge_function(edges); /* look up edge-handling function */ | ||
223 | |||
224 | if (!reflect) return(-1); | ||
225 | |||
226 | /* shift start/stop coords to filter upper left hand corner */ | ||
227 | x_start -= x_fmid; y_start -= y_fmid; | ||
228 | x_stop -= x_fmid; y_stop -= y_fmid; | ||
229 | |||
230 | if (x_stop < x_ctr_stop) x_ctr_stop = x_stop; | ||
231 | if (y_stop < y_ctr_stop) y_ctr_stop = y_stop; | ||
232 | |||
233 | for (im_pos=0, y_pos=y_start; /* TOP ROWS */ | ||
234 | y_pos<y_ctr_start; | ||
235 | y_pos+=y_step) | ||
236 | { | ||
237 | for (x_pos=x_start; /* TOP-LEFT CORNER */ | ||
238 | x_pos<x_ctr_start; | ||
239 | x_pos+=x_step, im_pos++) | ||
240 | { | ||
241 | (*reflect)(filt,x_fdim,y_fdim,x_pos-1,y_pos-1,temp,EXPAND); | ||
242 | INPROD2(0,0) | ||
243 | } | ||
244 | |||
245 | (*reflect)(filt,x_fdim,y_fdim,0,y_pos-1,temp,EXPAND); | ||
246 | for (; /* TOP EDGE */ | ||
247 | x_pos<x_ctr_stop; | ||
248 | x_pos+=x_step, im_pos++) | ||
249 | INPROD2(x_pos,0) | ||
250 | |||
251 | for (; /* TOP-RIGHT CORNER */ | ||
252 | x_pos<x_stop; | ||
253 | x_pos+=x_step, im_pos++) | ||
254 | { | ||
255 | (*reflect)(filt,x_fdim,y_fdim,x_pos-x_ctr_stop+1,y_pos-1,temp,EXPAND); | ||
256 | INPROD2(x_ctr_stop,0) | ||
257 | } | ||
258 | } /* end TOP ROWS */ | ||
259 | |||
260 | y_ctr_start = y_pos; /* hold location of top */ | ||
261 | for (base_im_pos=im_pos, x_pos=x_start; /* LEFT EDGE */ | ||
262 | x_pos<x_ctr_start; | ||
263 | x_pos+=x_step, base_im_pos++) | ||
264 | { | ||
265 | (*reflect)(filt,x_fdim,y_fdim,x_pos-1,0,temp,EXPAND); | ||
266 | for (y_pos=y_ctr_start, im_pos=base_im_pos; | ||
267 | y_pos<y_ctr_stop; | ||
268 | y_pos+=y_step, im_pos+=x_im_dim) | ||
269 | INPROD2(0,y_pos) | ||
270 | } | ||
271 | |||
272 | (*reflect)(filt,x_fdim,y_fdim,0,0,temp,EXPAND); | ||
273 | for (; /* CENTER */ | ||
274 | x_pos<x_ctr_stop; | ||
275 | x_pos+=x_step, base_im_pos++) | ||
276 | for (y_pos=y_ctr_start, im_pos=base_im_pos; | ||
277 | y_pos<y_ctr_stop; | ||
278 | y_pos+=y_step, im_pos+=x_im_dim) | ||
279 | INPROD2(x_pos,y_pos) | ||
280 | |||
281 | for (; /* RIGHT EDGE */ | ||
282 | x_pos<x_stop; | ||
283 | x_pos+=x_step, base_im_pos++) | ||
284 | { | ||
285 | (*reflect)(filt,x_fdim,y_fdim,x_pos-x_ctr_stop+1,0,temp,EXPAND); | ||
286 | for (y_pos=y_ctr_start, im_pos=base_im_pos; | ||
287 | y_pos<y_ctr_stop; | ||
288 | y_pos+=y_step, im_pos+=x_im_dim) | ||
289 | INPROD2(x_ctr_stop,y_pos) | ||
290 | } | ||
291 | |||
292 | for (im_pos-=(x_im_dim-1); | ||
293 | y_pos<y_stop; /* BOTTOM ROWS */ | ||
294 | y_pos+=y_step) | ||
295 | { | ||
296 | for (x_pos=x_start; /* BOTTOM-LEFT CORNER */ | ||
297 | x_pos<x_ctr_start; | ||
298 | x_pos+=x_step, im_pos++) | ||
299 | { | ||
300 | (*reflect)(filt,x_fdim,y_fdim,x_pos-1,y_pos-y_ctr_stop+1,temp,EXPAND); | ||
301 | INPROD2(0,y_ctr_stop) | ||
302 | } | ||
303 | |||
304 | (*reflect)(filt,x_fdim,y_fdim,0,y_pos-y_ctr_stop+1,temp,EXPAND); | ||
305 | for (; /* BOTTOM EDGE */ | ||
306 | x_pos<x_ctr_stop; | ||
307 | x_pos+=x_step, im_pos++) | ||
308 | INPROD2(x_pos,y_ctr_stop) | ||
309 | |||
310 | for (; /* BOTTOM-RIGHT CORNER */ | ||
311 | x_pos<x_stop; | ||
312 | x_pos+=x_step, im_pos++) | ||
313 | { | ||
314 | (*reflect)(filt,x_fdim,y_fdim,x_pos-x_ctr_stop+1,y_pos-y_ctr_stop+1,temp,EXPAND); | ||
315 | INPROD2(x_ctr_stop,y_ctr_stop) | ||
316 | } | ||
317 | } /* end BOTTOM */ | ||
318 | return(0); | ||
319 | } /* end of internal_expand */ | ||
320 | |||
321 | |||
322 | /* Local Variables: */ | ||
323 | /* buffer-read-only: t */ | ||
324 | /* End: */ | ||
325 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/convolve.h b/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/convolve.h deleted file mode 100755 index 48d55f7..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/convolve.h +++ /dev/null | |||
@@ -1,55 +0,0 @@ | |||
1 | /* | ||
2 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
3 | ;;; File: convolve.h | ||
4 | ;;; Author: Simoncelli | ||
5 | ;;; Description: Header file for convolve.c | ||
6 | ;;; Creation Date: | ||
7 | ;;; ---------------------------------------------------------------- | ||
8 | ;;; Object-Based Vision and Image Understanding System (OBVIUS), | ||
9 | ;;; Copyright 1988, Vision Science Group, Media Laboratory, | ||
10 | ;;; Massachusetts Institute of Technology. | ||
11 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
12 | */ | ||
13 | |||
14 | #include <stdio.h> | ||
15 | #include <stdlib.h> | ||
16 | |||
17 | #define ABS(x) (((x)>=0) ? (x) : (-(x))) | ||
18 | #define ROOT2 1.4142135623730951 | ||
19 | #define REDUCE 0 | ||
20 | #define EXPAND 1 | ||
21 | #define IS == | ||
22 | #define ISNT != | ||
23 | #define AND && | ||
24 | #define OR || | ||
25 | |||
26 | typedef int (*fptr)(); | ||
27 | |||
28 | typedef struct | ||
29 | { | ||
30 | char *name; | ||
31 | fptr func; | ||
32 | } EDGE_HANDLER; | ||
33 | |||
34 | typedef double image_type; | ||
35 | |||
36 | fptr edge_function(char *edges); | ||
37 | int internal_reduce(image_type *image, int x_idim, int y_idim, | ||
38 | image_type *filt, image_type *temp, int x_fdim, int y_fdim, | ||
39 | int x_start, int x_step, int x_stop, | ||
40 | int y_start, int y_step, int y_stop, | ||
41 | image_type *result, char *edges); | ||
42 | int internal_expand(image_type *image, | ||
43 | image_type *filt, image_type *temp, int x_fdim, int y_fdim, | ||
44 | int x_start, int x_step, int x_stop, | ||
45 | int y_start, int y_step, int y_stop, | ||
46 | image_type *result, int x_rdim, int y_rdim, char *edges); | ||
47 | int internal_wrap_reduce(image_type *image, int x_idim, int y_idim, | ||
48 | image_type *filt, int x_fdim, int y_fdim, | ||
49 | int x_start, int x_step, int x_stop, | ||
50 | int y_start, int y_step, int y_stop, | ||
51 | image_type *result); | ||
52 | int internal_wrap_expand(image_type *image, image_type *filt, int x_fdim, int y_fdim, | ||
53 | int x_start, int x_step, int x_stop, | ||
54 | int y_start, int y_step, int y_stop, | ||
55 | image_type *result, int x_rdim, int y_rdim); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/convolve.mexglx b/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/convolve.mexglx deleted file mode 100755 index 2dea157..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/convolve.mexglx +++ /dev/null | |||
Binary files differ | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/corrDn.c b/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/corrDn.c deleted file mode 100755 index c74df1f..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/corrDn.c +++ /dev/null | |||
@@ -1,145 +0,0 @@ | |||
1 | /* | ||
2 | RES = corrDn(IM, FILT, EDGES, STEP, START, STOP); | ||
3 | >>> See corrDn.m for documentation <<< | ||
4 | This is a matlab interface to the internal_reduce function. | ||
5 | EPS, 7/96. | ||
6 | */ | ||
7 | |||
8 | #define V4_COMPAT | ||
9 | #include <matrix.h> /* Matlab matrices */ | ||
10 | #include <mex.h> | ||
11 | |||
12 | #include "convolve.h" | ||
13 | |||
14 | #define notDblMtx(it) (!mxIsNumeric(it) || !mxIsDouble(it) || mxIsSparse(it) || mxIsComplex(it)) | ||
15 | |||
16 | void mexFunction(int nlhs, /* Num return vals on lhs */ | ||
17 | mxArray *plhs[], /* Matrices on lhs */ | ||
18 | int nrhs, /* Num args on rhs */ | ||
19 | const mxArray *prhs[] /* Matrices on rhs */ | ||
20 | ) | ||
21 | { | ||
22 | double *image,*filt, *temp, *result; | ||
23 | int x_fdim, y_fdim, x_idim, y_idim; | ||
24 | int x_rdim, y_rdim; | ||
25 | int x_start = 1; | ||
26 | int x_step = 1; | ||
27 | int y_start = 1; | ||
28 | int y_step = 1; | ||
29 | int x_stop, y_stop; | ||
30 | mxArray *arg; | ||
31 | double *mxMat; | ||
32 | char edges[15] = "reflect1"; | ||
33 | |||
34 | if (nrhs<2) mexErrMsgTxt("requres at least 2 args."); | ||
35 | |||
36 | /* ARG 1: IMAGE */ | ||
37 | arg = prhs[0]; | ||
38 | if notDblMtx(arg) mexErrMsgTxt("IMAGE arg must be a non-sparse double float matrix."); | ||
39 | image = mxGetPr(arg); | ||
40 | x_idim = (int) mxGetM(arg); /* X is inner index! */ | ||
41 | y_idim = (int) mxGetN(arg); | ||
42 | |||
43 | /* ARG 2: FILTER */ | ||
44 | arg = prhs[1]; | ||
45 | if notDblMtx(arg) mexErrMsgTxt("FILTER arg must be non-sparse double float matrix."); | ||
46 | filt = mxGetPr(arg); | ||
47 | x_fdim = (int) mxGetM(arg); | ||
48 | y_fdim = (int) mxGetN(arg); | ||
49 | |||
50 | if ((x_fdim > x_idim) || (y_fdim > y_idim)) | ||
51 | { | ||
52 | mexPrintf("Filter: [%d %d], Image: [%d %d]\n",x_fdim,y_fdim,x_idim,y_idim); | ||
53 | mexErrMsgTxt("FILTER dimensions larger than IMAGE dimensions."); | ||
54 | } | ||
55 | |||
56 | /* ARG 3 (optional): EDGES */ | ||
57 | if (nrhs>2) | ||
58 | { | ||
59 | if (!mxIsChar(prhs[2])) | ||
60 | mexErrMsgTxt("EDGES arg must be a string."); | ||
61 | mxGetString(prhs[2],edges,15); | ||
62 | } | ||
63 | |||
64 | /* ARG 4 (optional): STEP */ | ||
65 | if (nrhs>3) | ||
66 | { | ||
67 | arg = prhs[3]; | ||
68 | if notDblMtx(arg) mexErrMsgTxt("STEP arg must be a double float matrix."); | ||
69 | if (mxGetM(arg) * mxGetN(arg) != 2) | ||
70 | mexErrMsgTxt("STEP arg must contain two elements."); | ||
71 | mxMat = mxGetPr(arg); | ||
72 | x_step = (int) mxMat[0]; | ||
73 | y_step = (int) mxMat[1]; | ||
74 | if ((x_step<1) || (y_step<1)) | ||
75 | mexErrMsgTxt("STEP values must be greater than zero."); | ||
76 | } | ||
77 | |||
78 | /* ARG 5 (optional): START */ | ||
79 | if (nrhs>4) | ||
80 | { | ||
81 | arg = prhs[4]; | ||
82 | if notDblMtx(arg) mexErrMsgTxt("START arg must be a double float matrix."); | ||
83 | if (mxGetM(arg) * mxGetN(arg) != 2) | ||
84 | mexErrMsgTxt("START arg must contain two elements."); | ||
85 | mxMat = mxGetPr(arg); | ||
86 | x_start = (int) mxMat[0]; | ||
87 | y_start = (int) mxMat[1]; | ||
88 | if ((x_start<1) || (x_start>x_idim) || | ||
89 | (y_start<1) || (y_start>y_idim)) | ||
90 | mexErrMsgTxt("START values must lie between 1 and the image dimensions."); | ||
91 | } | ||
92 | x_start--; /* convert from Matlab to standard C indexes */ | ||
93 | y_start--; | ||
94 | |||
95 | /* ARG 6 (optional): STOP */ | ||
96 | if (nrhs>5) | ||
97 | { | ||
98 | if notDblMtx(prhs[5]) mexErrMsgTxt("STOP arg must be double float matrix."); | ||
99 | if (mxGetM(prhs[5]) * mxGetN(prhs[5]) != 2) | ||
100 | mexErrMsgTxt("STOP arg must contain two elements."); | ||
101 | mxMat = mxGetPr(prhs[5]); | ||
102 | x_stop = (int) mxMat[0]; | ||
103 | y_stop = (int) mxMat[1]; | ||
104 | if ((x_stop<x_start) || (x_stop>x_idim) || | ||
105 | (y_stop<y_start) || (y_stop>y_idim)) | ||
106 | mexErrMsgTxt("STOP values must lie between START and the image dimensions."); | ||
107 | } | ||
108 | else | ||
109 | { | ||
110 | x_stop = x_idim; | ||
111 | y_stop = y_idim; | ||
112 | } | ||
113 | |||
114 | x_rdim = (x_stop-x_start+x_step-1) / x_step; | ||
115 | y_rdim = (y_stop-y_start+y_step-1) / y_step; | ||
116 | |||
117 | /* mxFreeMatrix(plhs[0]); */ | ||
118 | plhs[0] = (mxArray *) mxCreateDoubleMatrix(x_rdim,y_rdim,mxREAL); | ||
119 | if (plhs[0] == NULL) mexErrMsgTxt("Cannot allocate result matrix"); | ||
120 | result = mxGetPr(plhs[0]); | ||
121 | |||
122 | temp = mxCalloc(x_fdim*y_fdim, sizeof(double)); | ||
123 | if (temp == NULL) | ||
124 | mexErrMsgTxt("Cannot allocate necessary temporary space"); | ||
125 | |||
126 | /* | ||
127 | printf("i(%d, %d), f(%d, %d), r(%d, %d), X(%d, %d, %d), Y(%d, %d, %d), %s\n", | ||
128 | x_idim,y_idim,x_fdim,y_fdim,x_rdim,y_rdim, | ||
129 | x_start,x_step,x_stop,y_start,y_step,y_stop,edges); | ||
130 | */ | ||
131 | |||
132 | if (strcmp(edges,"circular") == 0) | ||
133 | internal_wrap_reduce(image, x_idim, y_idim, filt, x_fdim, y_fdim, | ||
134 | x_start, x_step, x_stop, y_start, y_step, y_stop, | ||
135 | result); | ||
136 | else internal_reduce(image, x_idim, y_idim, filt, temp, x_fdim, y_fdim, | ||
137 | x_start, x_step, x_stop, y_start, y_step, y_stop, | ||
138 | result, edges); | ||
139 | |||
140 | mxFree((char *) temp); | ||
141 | return; | ||
142 | } | ||
143 | |||
144 | |||
145 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/edges.c b/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/edges.c deleted file mode 100755 index 98b377d..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/edges.c +++ /dev/null | |||
@@ -1,647 +0,0 @@ | |||
1 | /* | ||
2 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
3 | ;;; File: edges.c | ||
4 | ;;; Author: Eero Simoncelli | ||
5 | ;;; Description: Boundary handling routines for use with convolve.c | ||
6 | ;;; Creation Date: Spring 1987. | ||
7 | ;;; MODIFIED, 6/96, to operate on double float arrays. | ||
8 | ;;; MODIFIED by dgp, 4/1/97, to support THINK C. | ||
9 | ;;; MODIFIED, 8/97: reflect1, reflect2, repeat, extend upgraded to | ||
10 | ;;; work properly for non-symmetric filters. Added qreflect2 to handle | ||
11 | ;;; even-length QMF's which broke under the reflect2 modification. | ||
12 | ;;; ---------------------------------------------------------------- | ||
13 | ;;; Object-Based Vision and Image Understanding System (OBVIUS), | ||
14 | ;;; Copyright 1988, Vision Science Group, Media Laboratory, | ||
15 | ;;; Massachusetts Institute of Technology. | ||
16 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
17 | */ | ||
18 | |||
19 | /* This file contains functions which determine how edges are to be | ||
20 | handled when performing convolutions of images with linear filters. | ||
21 | Any edge handling function which is local and linear may be defined, | ||
22 | except (unfortunately) constants cannot be added. So to treat the | ||
23 | edges as if the image is surrounded by a gray field, you must paste it | ||
24 | into a gray image, convolve, and crop it out... The main convolution | ||
25 | functions are called internal_reduce and internal_expand and are | ||
26 | defined in the file convolve.c. The idea is that the convolution | ||
27 | function calls the edge handling function which computes a new filter | ||
28 | based on the old filter and the distance to the edge of the image. | ||
29 | For example, reflection is done by reflecting the filter through the | ||
30 | appropriate axis and summing. Currently defined functions are listed | ||
31 | below. | ||
32 | */ | ||
33 | |||
34 | |||
35 | #include <stdio.h> | ||
36 | #include <math.h> | ||
37 | #include <string.h> | ||
38 | #include "convolve.h" | ||
39 | |||
40 | #define sgn(a) ( ((a)>0)?1:(((a)<0)?-1:0) ) | ||
41 | #define clip(a,mn,mx) ( ((a)<(mn))?(mn):(((a)>=(mx))?(mx-1):(a)) ) | ||
42 | |||
43 | int reflect1(), reflect2(), qreflect2(), repeat(), zero(), Extend(), nocompute(); | ||
44 | int ereflect(), predict(); | ||
45 | |||
46 | /* Lookup table matching a descriptive string to the edge-handling function */ | ||
47 | #if !THINK_C | ||
48 | static EDGE_HANDLER edge_foos[] = | ||
49 | { | ||
50 | { "dont-compute", nocompute }, /* zero output for filter touching edge */ | ||
51 | { "zero", zero }, /* zero outside of image */ | ||
52 | { "repeat", repeat }, /* repeat edge pixel */ | ||
53 | { "reflect1", reflect1 }, /* reflect about edge pixels */ | ||
54 | { "reflect2", reflect2 }, /* reflect image, including edge pixels */ | ||
55 | { "qreflect2", qreflect2 }, /* reflect image, including edge pixels | ||
56 | for even-length QMF decompositions */ | ||
57 | { "extend", Extend }, /* extend (reflect & invert) */ | ||
58 | { "ereflect", ereflect }, /* orthogonal QMF reflection */ | ||
59 | }; | ||
60 | #else | ||
61 | /* | ||
62 | This is really stupid, but THINK C won't allow initialization of static variables in | ||
63 | a code resource with string addresses. So we do it this way. | ||
64 | The 68K code for a MATLAB 4 MEX file can only be created by THINK C. | ||
65 | However, for MATLAB 5, we'll be able to use Metrowerks CodeWarrior for both 68K and PPC, so this | ||
66 | cludge can be dropped when we drop support for MATLAB 4. | ||
67 | Denis Pelli, 4/1/97. | ||
68 | */ | ||
69 | static EDGE_HANDLER edge_foos[8]; | ||
70 | |||
71 | void InitializeTable(EDGE_HANDLER edge_foos[]) | ||
72 | { | ||
73 | static int i=0; | ||
74 | |||
75 | if(i>0) return; | ||
76 | edge_foos[i].name="dont-compute"; | ||
77 | edge_foos[i++].func=nocompute; | ||
78 | edge_foos[i].name="zero"; | ||
79 | edge_foos[i++].func=zero; | ||
80 | edge_foos[i].name="repeat"; | ||
81 | edge_foos[i++].func=repeat; | ||
82 | edge_foos[i].name="reflect1"; | ||
83 | edge_foos[i++].func=reflect1; | ||
84 | edge_foos[i].name="reflect2"; | ||
85 | edge_foos[i++].func=reflect2; | ||
86 | edge_foos[i].name="qreflect2"; | ||
87 | edge_foos[i++].func=qreflect2; | ||
88 | edge_foos[i].name="extend"; | ||
89 | edge_foos[i++].func=Extend; | ||
90 | edge_foos[i].name="ereflect"; | ||
91 | edge_foos[i++].func=ereflect; | ||
92 | } | ||
93 | #endif | ||
94 | |||
95 | /* | ||
96 | Function looks up an edge handler id string in the structure above, and | ||
97 | returns the associated function | ||
98 | */ | ||
99 | fptr edge_function(char *edges) | ||
100 | { | ||
101 | int i; | ||
102 | |||
103 | #if THINK_C | ||
104 | InitializeTable(edge_foos); | ||
105 | #endif | ||
106 | for (i = 0; i<sizeof(edge_foos)/sizeof(EDGE_HANDLER); i++) | ||
107 | if (strcmp(edges,edge_foos[i].name) IS 0) | ||
108 | return(edge_foos[i].func); | ||
109 | printf("Error: '%s' is not the name of a valid edge-handler!\n",edges); | ||
110 | for (i=0; i<sizeof(edge_foos)/sizeof(EDGE_HANDLER); i++) | ||
111 | { | ||
112 | if (i IS 0) printf(" Options are: "); | ||
113 | else printf(", "); | ||
114 | printf("%s",edge_foos[i].name); | ||
115 | } | ||
116 | printf("\n"); | ||
117 | return(0); | ||
118 | } | ||
119 | |||
120 | /* | ||
121 | ---------------- EDGE HANDLER ARGUMENTS ------------------------ | ||
122 | filt - array of filter taps. | ||
123 | x_dim, y_dim - x and y dimensions of filt. | ||
124 | x_pos - position of filter relative to the horizontal image edges. Negative | ||
125 | values indicate left edge, positive indicate right edge. Zero | ||
126 | indicates that the filter is not touching either edge. An absolute | ||
127 | value of 1 indicates that the edge tap of the filter is over the | ||
128 | edge pixel of the image. | ||
129 | y_pos - analogous to x_pos. | ||
130 | result - array where the resulting filter will go. The edge | ||
131 | of this filter will be aligned with the image for application... | ||
132 | r_or_e - equal to one of the two constants EXPAND or REDUCE. | ||
133 | -------------------------------------------------------------------- | ||
134 | */ | ||
135 | |||
136 | |||
137 | /* -------------------------------------------------------------------- | ||
138 | nocompute() - Return zero for values where filter hangs over the edge. | ||
139 | */ | ||
140 | |||
141 | int nocompute(filt,x_dim,y_dim,x_pos,y_pos,result,r_or_e) | ||
142 | register double *filt, *result; | ||
143 | register int x_dim; | ||
144 | int y_dim, x_pos, y_pos, r_or_e; | ||
145 | { | ||
146 | register int i; | ||
147 | register int size = x_dim*y_dim; | ||
148 | |||
149 | if ( (x_pos>1) OR (x_pos<-1) OR (y_pos>1) OR (y_pos<-1) ) | ||
150 | for (i=0; i<size; i++) result[i] = 0.0; | ||
151 | else | ||
152 | for (i=0; i<size; i++) result[i] = filt[i]; | ||
153 | |||
154 | return(0); | ||
155 | } | ||
156 | |||
157 | /* -------------------------------------------------------------------- | ||
158 | zero() - Zero outside of image. Discontinuous, but adds zero energy. */ | ||
159 | |||
160 | int zero(filt,x_dim,y_dim,x_pos,y_pos,result,r_or_e) | ||
161 | register double *filt, *result; | ||
162 | register int x_dim; | ||
163 | int y_dim, x_pos, y_pos, r_or_e; | ||
164 | { | ||
165 | register int y_filt,x_filt, y_res,x_res; | ||
166 | int filt_sz = x_dim*y_dim; | ||
167 | int x_start = ((x_pos>0)?(x_pos-1):((x_pos<0)?(x_pos+1):0)); | ||
168 | int y_start = x_dim * ((y_pos>0)?(y_pos-1):((y_pos<0)?(y_pos+1):0)); | ||
169 | int i; | ||
170 | |||
171 | for (i=0; i<filt_sz; i++) result[i] = 0.0; | ||
172 | |||
173 | for (y_filt=0, y_res=y_start; | ||
174 | y_filt<filt_sz; | ||
175 | y_filt+=x_dim, y_res+=x_dim) | ||
176 | if ((y_res >= 0) AND (y_res < filt_sz)) | ||
177 | for (x_filt=y_filt, x_res=x_start; | ||
178 | x_filt<y_filt+x_dim; | ||
179 | x_filt++, x_res++) | ||
180 | if ((x_res >= 0) AND (x_res < x_dim)) | ||
181 | result[y_res+x_res] = filt[x_filt]; | ||
182 | return(0); | ||
183 | } | ||
184 | |||
185 | |||
186 | /* -------------------------------------------------------------------- | ||
187 | reflect1() - Reflection through the edge pixels. Continuous, but | ||
188 | discontinuous first derivative. This is the right thing to do if you | ||
189 | are subsampling by 2, since it maintains parity (even pixels positions | ||
190 | remain even, odd ones remain odd). | ||
191 | */ | ||
192 | |||
193 | int reflect1(filt,x_dim,y_dim,x_pos,y_pos,result,r_or_e) | ||
194 | register double *filt, *result; | ||
195 | register int x_dim; | ||
196 | int y_dim, x_pos, y_pos, r_or_e; | ||
197 | { | ||
198 | int filt_sz = x_dim*y_dim; | ||
199 | register int y_filt,x_filt, y_res, x_res; | ||
200 | register int x_base = (x_pos>0)?(x_dim-1):0; | ||
201 | register int y_base = x_dim * ((y_pos>0)?(y_dim-1):0); | ||
202 | int x_overhang = (x_pos>0)?(x_pos-1):((x_pos<0)?(x_pos+1):0); | ||
203 | int y_overhang = x_dim * ((y_pos>0)?(y_pos-1):((y_pos<0)?(y_pos+1):0)); | ||
204 | int i; | ||
205 | int mx_pos = (x_pos<0)?(x_dim/2):((x_dim-1)/2); | ||
206 | int my_pos = x_dim * ((y_pos<0)?(y_dim/2):((y_dim-1)/2)); | ||
207 | |||
208 | for (i=0; i<filt_sz; i++) result[i] = 0.0; | ||
209 | |||
210 | if (r_or_e IS REDUCE) | ||
211 | for (y_filt=0, y_res=y_overhang-y_base; | ||
212 | y_filt<filt_sz; | ||
213 | y_filt+=x_dim, y_res+=x_dim) | ||
214 | for (x_filt=y_filt, x_res=x_overhang-x_base; | ||
215 | x_filt<y_filt+x_dim; | ||
216 | x_filt++, x_res++) | ||
217 | result[ABS(y_base-ABS(y_res)) + ABS(x_base-ABS(x_res))] | ||
218 | += filt[x_filt]; | ||
219 | else { | ||
220 | y_overhang = ABS(y_overhang); | ||
221 | x_overhang = ABS(x_overhang); | ||
222 | for (y_res=y_base, y_filt = y_base-y_overhang; | ||
223 | y_filt > y_base-filt_sz; | ||
224 | y_filt-=x_dim, y_res-=x_dim) | ||
225 | { | ||
226 | for (x_res=x_base, x_filt=x_base-x_overhang; | ||
227 | x_filt > x_base-x_dim; | ||
228 | x_res--, x_filt--) | ||
229 | result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_filt)+ABS(x_filt)]; | ||
230 | if ((x_overhang ISNT mx_pos) AND (x_pos ISNT 0)) | ||
231 | for (x_res=x_base, x_filt=x_base-2*mx_pos+x_overhang; | ||
232 | x_filt > x_base-x_dim; | ||
233 | x_res--, x_filt--) | ||
234 | result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_filt)+ABS(x_filt)]; | ||
235 | } | ||
236 | if ((y_overhang ISNT my_pos) AND (y_pos ISNT 0)) | ||
237 | for (y_res=y_base, y_filt = y_base-2*my_pos+y_overhang; | ||
238 | y_filt > y_base-filt_sz; | ||
239 | y_filt-=x_dim, y_res-=x_dim) | ||
240 | { | ||
241 | for (x_res=x_base, x_filt=x_base-x_overhang; | ||
242 | x_filt > x_base-x_dim; | ||
243 | x_res--, x_filt--) | ||
244 | result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_filt)+ABS(x_filt)]; | ||
245 | if ((x_overhang ISNT mx_pos) AND (x_pos ISNT 0)) | ||
246 | for (x_res=x_base, x_filt=x_base-2*mx_pos+x_overhang; | ||
247 | x_filt > x_base-x_dim; | ||
248 | x_res--, x_filt--) | ||
249 | result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_filt)+ABS(x_filt)]; | ||
250 | } | ||
251 | } | ||
252 | |||
253 | return(0); | ||
254 | } | ||
255 | |||
256 | /* -------------------------------------------------------------------- | ||
257 | reflect2() - Reflect image at boundary. The edge pixel is repeated, | ||
258 | then the next pixel, etc. Continuous, but discontinuous first | ||
259 | derivative. | ||
260 | */ | ||
261 | |||
262 | int reflect2(filt,x_dim,y_dim,x_pos,y_pos,result,r_or_e) | ||
263 | register double *filt, *result; | ||
264 | register int x_dim; | ||
265 | int y_dim, x_pos, y_pos, r_or_e; | ||
266 | { | ||
267 | int filt_sz = x_dim*y_dim; | ||
268 | register int y_filt,x_filt, y_res, x_res; | ||
269 | register int x_base = (x_pos>0)?(x_dim-1):0; | ||
270 | register int y_base = x_dim * ((y_pos>0)?(y_dim-1):0); | ||
271 | int x_overhang = (x_pos>0)?(x_pos-1):((x_pos<0)?(x_pos+1):0); | ||
272 | int y_overhang = x_dim * ((y_pos>0)?(y_pos-1):((y_pos<0)?(y_pos+1):0)); | ||
273 | int i; | ||
274 | int mx_pos = (x_pos<0)?(x_dim/2):((x_dim-1)/2); | ||
275 | int my_pos = x_dim * ((y_pos<0)?(y_dim/2):((y_dim-1)/2)); | ||
276 | |||
277 | for (i=0; i<filt_sz; i++) result[i] = 0.0; | ||
278 | |||
279 | if (r_or_e IS REDUCE) | ||
280 | for (y_filt=0, y_res = (y_overhang-y_base) - ((y_pos>0)?x_dim:0); | ||
281 | y_filt<filt_sz; | ||
282 | y_filt+=x_dim, y_res+=x_dim) | ||
283 | { | ||
284 | if (y_res IS 0) y_res+=x_dim; | ||
285 | for (x_filt=y_filt, x_res = (x_overhang-x_base) - ((x_pos>0)?1:0); | ||
286 | x_filt<y_filt+x_dim; | ||
287 | x_filt++, x_res++) | ||
288 | { | ||
289 | if (x_res IS 0) x_res++; | ||
290 | result[ABS(y_base-ABS(y_res)+x_dim) + ABS(x_base-ABS(x_res)+1)] | ||
291 | += filt[x_filt]; | ||
292 | } | ||
293 | } | ||
294 | else { | ||
295 | y_overhang = ABS(y_overhang); | ||
296 | x_overhang = ABS(x_overhang); | ||
297 | for (y_res=y_base, y_filt = y_base-y_overhang; | ||
298 | y_filt > y_base-filt_sz; | ||
299 | y_filt-=x_dim, y_res-=x_dim) | ||
300 | { | ||
301 | for (x_res=x_base, x_filt=x_base-x_overhang; | ||
302 | x_filt > x_base-x_dim; | ||
303 | x_res--, x_filt--) | ||
304 | result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_filt)+ABS(x_filt)]; | ||
305 | if (x_pos ISNT 0) | ||
306 | for (x_res=x_base, x_filt=x_base-2*mx_pos+x_overhang-1; | ||
307 | x_filt > x_base-x_dim; | ||
308 | x_res--, x_filt--) | ||
309 | result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_filt)+ABS(x_filt)]; | ||
310 | } | ||
311 | if (y_pos ISNT 0) | ||
312 | for (y_res=y_base, y_filt = y_base-2*my_pos+y_overhang-x_dim; | ||
313 | y_filt > y_base-filt_sz; | ||
314 | y_filt-=x_dim, y_res-=x_dim) | ||
315 | { | ||
316 | for (x_res=x_base, x_filt=x_base-x_overhang; | ||
317 | x_filt > x_base-x_dim; | ||
318 | x_res--, x_filt--) | ||
319 | result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_filt)+ABS(x_filt)]; | ||
320 | if (x_pos ISNT 0) | ||
321 | for (x_res=x_base, x_filt=x_base-2*mx_pos+x_overhang-1; | ||
322 | x_filt > x_base-x_dim; | ||
323 | x_res--, x_filt--) | ||
324 | result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_filt)+ABS(x_filt)]; | ||
325 | } | ||
326 | } | ||
327 | |||
328 | return(0); | ||
329 | } | ||
330 | |||
331 | |||
332 | /* -------------------------------------------------------------------- | ||
333 | qreflect2() - Modified version of reflect2 that works properly for | ||
334 | even-length QMF filters. | ||
335 | */ | ||
336 | |||
337 | int qreflect2(filt,x_dim,y_dim,x_pos,y_pos,result,r_or_e) | ||
338 | double *filt, *result; | ||
339 | int x_dim, y_dim, x_pos, y_pos, r_or_e; | ||
340 | { | ||
341 | reflect2(filt,x_dim,y_dim,x_pos,y_pos,result,0); | ||
342 | return(0); | ||
343 | } | ||
344 | |||
345 | /* -------------------------------------------------------------------- | ||
346 | repeat() - repeat edge pixel. Continuous, with discontinuous first | ||
347 | derivative. | ||
348 | */ | ||
349 | |||
350 | int repeat(filt,x_dim,y_dim,x_pos,y_pos,result,r_or_e) | ||
351 | register double *filt, *result; | ||
352 | register int x_dim; | ||
353 | int y_dim, x_pos, y_pos, r_or_e; | ||
354 | { | ||
355 | register int y_filt,x_filt, y_res,x_res, y_tmp, x_tmp; | ||
356 | register int x_base = (x_pos>0)?(x_dim-1):0; | ||
357 | register int y_base = x_dim * ((y_pos>0)?(y_dim-1):0); | ||
358 | int x_overhang = ((x_pos>0)?(x_pos-1):((x_pos<0)?(x_pos+1):0)); | ||
359 | int y_overhang = x_dim * ((y_pos>0)?(y_pos-1):((y_pos<0)?(y_pos+1):0)); | ||
360 | int filt_sz = x_dim*y_dim; | ||
361 | int mx_pos = (x_dim/2); | ||
362 | int my_pos = x_dim * (y_dim/2); | ||
363 | int i; | ||
364 | |||
365 | for (i=0; i<filt_sz; i++) result[i] = 0.0; | ||
366 | |||
367 | if (r_or_e IS REDUCE) | ||
368 | for (y_filt=0, y_res=y_overhang; | ||
369 | y_filt<filt_sz; | ||
370 | y_filt+=x_dim, y_res+=x_dim) | ||
371 | for (x_filt=y_filt, x_res=x_overhang; | ||
372 | x_filt<y_filt+x_dim; | ||
373 | x_filt++, x_res++) | ||
374 | /* Clip the index: */ | ||
375 | result[((y_res>=0)?((y_res<filt_sz)?y_res:(filt_sz-x_dim)):0) | ||
376 | + ((x_res>=0)?((x_res<x_dim)?x_res:(x_dim-1)):0)] | ||
377 | += filt[x_filt]; | ||
378 | else { | ||
379 | if ((y_base-y_overhang) ISNT my_pos) | ||
380 | for (y_res=y_base, y_filt=y_base-ABS(y_overhang); | ||
381 | y_filt > y_base-filt_sz; | ||
382 | y_filt-=x_dim, y_res-=x_dim) | ||
383 | if ((x_base-x_overhang) ISNT mx_pos) | ||
384 | for (x_res=x_base, x_filt=x_base-ABS(x_overhang); | ||
385 | x_filt > x_base-x_dim; | ||
386 | x_res--, x_filt--) | ||
387 | result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_filt)+ABS(x_filt)]; | ||
388 | else /* ((x_base-x_overhang) IS mx_pos) */ | ||
389 | for (x_res=x_base, x_filt=x_base-ABS(x_overhang); | ||
390 | x_filt > x_base-x_dim; | ||
391 | x_filt--, x_res--) | ||
392 | for(x_tmp=x_filt; x_tmp > x_base-x_dim; x_tmp--) | ||
393 | result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_filt)+ABS(x_tmp)]; | ||
394 | else /* ((y_base-y_overhang) IS my_pos) */ | ||
395 | for (y_res=y_base, y_filt=y_base-ABS(y_overhang); | ||
396 | y_filt > y_base-filt_sz; | ||
397 | y_filt-=x_dim, y_res-=x_dim) | ||
398 | for (y_tmp=y_filt; y_tmp > y_base-filt_sz; y_tmp-=x_dim) | ||
399 | if ((x_base-x_overhang) ISNT mx_pos) | ||
400 | for (x_res=x_base, x_filt=x_base-ABS(x_overhang); | ||
401 | x_filt > x_base-x_dim; | ||
402 | x_filt--, x_res--) | ||
403 | result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_tmp)+ABS(x_filt)]; | ||
404 | else /* ((x_base-x_overhang) IS mx_pos) */ | ||
405 | for (x_res=x_base, x_filt=x_base-ABS(x_overhang); | ||
406 | x_filt > x_base-x_dim; | ||
407 | x_filt--, x_res--) | ||
408 | for (x_tmp=x_filt; x_tmp > x_base-x_dim; x_tmp--) | ||
409 | result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_tmp)+ABS(x_tmp)]; | ||
410 | } /* End, if r_or_e IS EXPAND */ | ||
411 | |||
412 | return(0); | ||
413 | } | ||
414 | |||
415 | /* -------------------------------------------------------------------- | ||
416 | extend() - Extend image by reflecting and inverting about edge pixel | ||
417 | value. Maintains continuity in intensity AND first derivative (but | ||
418 | not higher derivs). | ||
419 | */ | ||
420 | |||
421 | int Extend(filt,x_dim,y_dim,x_pos,y_pos,result,r_or_e) | ||
422 | register double *filt, *result; | ||
423 | register int x_dim; | ||
424 | int y_dim, x_pos, y_pos, r_or_e; | ||
425 | { | ||
426 | int filt_sz = x_dim*y_dim; | ||
427 | register int y_filt,x_filt, y_res,x_res, y_tmp, x_tmp; | ||
428 | register int x_base = (x_pos>0)?(x_dim-1):0; | ||
429 | register int y_base = x_dim * ((y_pos>0)?(y_dim-1):0); | ||
430 | int x_overhang = (x_pos>0)?(x_pos-1):((x_pos<0)?(x_pos+1):0); | ||
431 | int y_overhang = x_dim * ((y_pos>0)?(y_pos-1):((y_pos<0)?(y_pos+1):0)); | ||
432 | int mx_pos = (x_pos<0)?(x_dim/2):((x_dim-1)/2); | ||
433 | int my_pos = x_dim * ((y_pos<0)?(y_dim/2):((y_dim-1)/2)); | ||
434 | int i; | ||
435 | |||
436 | for (i=0; i<filt_sz; i++) result[i] = 0.0; | ||
437 | |||
438 | /* Modeled on reflect1() */ | ||
439 | if (r_or_e IS REDUCE) | ||
440 | for (y_filt=0, y_res=y_overhang; | ||
441 | y_filt<filt_sz; | ||
442 | y_filt+=x_dim, y_res+=x_dim) | ||
443 | if ((y_res>=0) AND (y_res<filt_sz)) | ||
444 | for (x_filt=y_filt, x_res=x_overhang; | ||
445 | x_filt<y_filt+x_dim; | ||
446 | x_filt++, x_res++) | ||
447 | if ((x_res>=0) AND (x_res<x_dim)) | ||
448 | result[y_res+x_res] += filt[x_filt]; | ||
449 | else | ||
450 | { | ||
451 | result[y_res+ABS(x_base-ABS(x_res-x_base))] -= filt[x_filt]; | ||
452 | result[y_res+x_base] += 2*filt[x_filt]; | ||
453 | } | ||
454 | else | ||
455 | for (x_filt=y_filt, x_res=x_overhang; | ||
456 | x_filt<y_filt+x_dim; | ||
457 | x_filt++, x_res++) | ||
458 | if ((x_res>=0) AND (x_res<x_dim)) | ||
459 | { | ||
460 | result[ABS(y_base-ABS(y_res-y_base))+x_res] -= filt[x_filt]; | ||
461 | result[y_base+x_res] += 2*filt[x_filt]; | ||
462 | } | ||
463 | else | ||
464 | { | ||
465 | result[ABS(y_base-ABS(y_res-y_base))+ABS(x_base-ABS(x_res-x_base))] | ||
466 | -= filt[x_filt]; | ||
467 | result[y_base+x_base] += 2*filt[x_filt]; | ||
468 | } | ||
469 | else { /* r_or_e ISNT REDUCE */ | ||
470 | y_overhang = ABS(y_overhang); | ||
471 | x_overhang = ABS(x_overhang); | ||
472 | for (y_res=y_base, y_filt = y_base-y_overhang; | ||
473 | y_filt > y_base-filt_sz; | ||
474 | y_filt-=x_dim, y_res-=x_dim) | ||
475 | { | ||
476 | for (x_res=x_base, x_filt=x_base-x_overhang; | ||
477 | x_filt > x_base-x_dim; | ||
478 | x_res--, x_filt--) | ||
479 | result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_filt)+ABS(x_filt)]; | ||
480 | if (x_pos ISNT 0) | ||
481 | if (x_overhang ISNT mx_pos) | ||
482 | for (x_res=x_base, x_filt=x_base-2*mx_pos+x_overhang; | ||
483 | x_filt > x_base-x_dim; | ||
484 | x_res--, x_filt--) | ||
485 | result[ABS(y_res)+ABS(x_res)] -= filt[ABS(y_filt)+ABS(x_filt)]; | ||
486 | else /* x_overhang IS mx_pos */ | ||
487 | for (x_res=x_base, x_filt=x_base-2*mx_pos+x_overhang-1; | ||
488 | x_filt > x_base-x_dim; | ||
489 | x_res--, x_filt--) | ||
490 | for (x_tmp=x_filt; x_tmp > x_base-x_dim; x_tmp--) | ||
491 | result[ABS(y_res)+ABS(x_res)] += 2*filt[ABS(y_filt)+ABS(x_tmp)]; | ||
492 | } | ||
493 | if (y_pos ISNT 0) | ||
494 | if (y_overhang ISNT my_pos) | ||
495 | for (y_res=y_base, y_filt = y_base-2*my_pos+y_overhang; | ||
496 | y_filt > y_base-filt_sz; | ||
497 | y_filt-=x_dim, y_res-=x_dim) | ||
498 | { | ||
499 | for (x_res=x_base, x_filt=x_base-x_overhang; | ||
500 | x_filt > x_base-x_dim; | ||
501 | x_res--, x_filt--) | ||
502 | result[ABS(y_res)+ABS(x_res)] -= filt[ABS(y_filt)+ABS(x_filt)]; | ||
503 | if ((x_pos ISNT 0) AND (x_overhang ISNT mx_pos)) | ||
504 | for (x_res=x_base, x_filt=x_base-2*mx_pos+x_overhang; | ||
505 | x_filt > x_base-x_dim; | ||
506 | x_res--, x_filt--) | ||
507 | result[ABS(y_res)+ABS(x_res)] -= filt[ABS(y_filt)+ABS(x_filt)]; | ||
508 | } | ||
509 | else /* y_overhang IS my_pos */ | ||
510 | for (y_res=y_base, y_filt = y_base-2*my_pos+y_overhang-x_dim; | ||
511 | y_filt > y_base-filt_sz; | ||
512 | y_res-=x_dim, y_filt-=x_dim) | ||
513 | for (y_tmp=y_filt; y_tmp > y_base-filt_sz; y_tmp-=x_dim) | ||
514 | { | ||
515 | for (x_res=x_base, x_filt=x_base-x_overhang; | ||
516 | x_filt > x_base-x_dim; | ||
517 | x_res--, x_filt--) | ||
518 | result[ABS(y_res)+ABS(x_res)] += 2*filt[ABS(y_tmp)+ABS(x_filt)]; | ||
519 | if ((x_pos ISNT 0) AND (x_overhang IS mx_pos)) | ||
520 | for (x_res=x_base, x_filt=x_base-2*mx_pos+x_overhang-1; | ||
521 | x_filt > x_base-x_dim; | ||
522 | x_res--, x_filt--) | ||
523 | for (x_tmp=x_filt; x_tmp > x_base-x_dim; x_tmp--) | ||
524 | result[ABS(y_res)+ABS(x_res)] += 2*filt[ABS(y_tmp)+ABS(x_tmp)]; | ||
525 | } | ||
526 | } /* r_or_e ISNT REDUCE */ | ||
527 | |||
528 | return(0); | ||
529 | } | ||
530 | |||
531 | /* -------------------------------------------------------------------- | ||
532 | predict() - Simple prediction. Like zero, but multiplies the result | ||
533 | by the reciprocal of the percentage of filter being used. (i.e. if | ||
534 | 50% of the filter is hanging over the edge of the image, multiply the | ||
535 | taps being used by 2). */ | ||
536 | |||
537 | int predict(filt,x_dim,y_dim,x_pos,y_pos,result,r_or_e) | ||
538 | register double *filt, *result; | ||
539 | register int x_dim; | ||
540 | int y_dim, x_pos, y_pos, r_or_e; | ||
541 | { | ||
542 | register int y_filt,x_filt, y_res,x_res; | ||
543 | register double taps_used = 0.0; /* int *** */ | ||
544 | register double fraction = 0.0; | ||
545 | int filt_sz = x_dim*y_dim; | ||
546 | int x_start = ((x_pos>0)?(x_pos-1):((x_pos<0)?(x_pos+1):0)); | ||
547 | int y_start = x_dim * ((y_pos>0)?(y_pos-1):((y_pos<0)?(y_pos+1):0)); | ||
548 | int i; | ||
549 | |||
550 | for (i=0; i<filt_sz; i++) result[i] = 0.0; | ||
551 | |||
552 | for (y_filt=0, y_res=y_start; | ||
553 | y_filt<filt_sz; | ||
554 | y_filt+=x_dim, y_res+=x_dim) | ||
555 | if ((y_res >= 0) AND (y_res < filt_sz)) | ||
556 | for (x_filt=y_filt, x_res=x_start; | ||
557 | x_filt<y_filt+x_dim; | ||
558 | x_filt++, x_res++) | ||
559 | if ((x_res >= 0) AND (x_res < x_dim)) | ||
560 | { | ||
561 | result[y_res+x_res] = filt[x_filt]; | ||
562 | taps_used += ABS(filt[x_filt]); | ||
563 | } | ||
564 | |||
565 | if (r_or_e IS REDUCE) | ||
566 | { | ||
567 | /* fraction = ( (double) filt_sz ) / ( (double) taps_used ); */ | ||
568 | for (i=0; i<filt_sz; i++) fraction += ABS(filt[i]); | ||
569 | fraction = ( fraction / taps_used ); | ||
570 | for (i=0; i<filt_sz; i++) result[i] *= fraction; | ||
571 | } | ||
572 | return(0); | ||
573 | } | ||
574 | |||
575 | |||
576 | /* -------------------------------------------------------------------- | ||
577 | Reflect, multiplying tap of filter which is at the edge of the image | ||
578 | by root 2. This maintains orthogonality of odd-length linear-phase | ||
579 | QMF filters, but it is not useful for most applications, since it | ||
580 | alters the DC level. */ | ||
581 | |||
582 | int ereflect(filt,x_dim,y_dim,x_pos,y_pos,result,r_or_e) | ||
583 | register double *filt, *result; | ||
584 | register int x_dim; | ||
585 | int y_dim, x_pos, y_pos, r_or_e; | ||
586 | { | ||
587 | register int y_filt,x_filt, y_res,x_res; | ||
588 | register int x_base = (x_pos>0)?(x_dim-1):0; | ||
589 | register int y_base = x_dim * ((y_pos>0)?(y_dim-1):0); | ||
590 | int filt_sz = x_dim*y_dim; | ||
591 | int x_overhang = (x_pos>1)?(x_pos-x_dim):((x_pos<-1)?(x_pos+1):0); | ||
592 | int y_overhang = x_dim * ( (y_pos>1)?(y_pos-y_dim):((y_pos<-1)?(y_pos+1):0) ); | ||
593 | int i; | ||
594 | double norm,onorm; | ||
595 | |||
596 | for (i=0; i<filt_sz; i++) result[i] = 0.0; | ||
597 | |||
598 | /* reflect at boundary */ | ||
599 | for (y_filt=0, y_res=y_overhang; | ||
600 | y_filt<filt_sz; | ||
601 | y_filt+=x_dim, y_res+=x_dim) | ||
602 | for (x_filt=y_filt, x_res=x_overhang; | ||
603 | x_filt<y_filt+x_dim; | ||
604 | x_filt++, x_res++) | ||
605 | result[ABS(y_base-ABS(y_res)) + ABS(x_base-ABS(x_res))] | ||
606 | += filt[x_filt]; | ||
607 | |||
608 | /* now multiply edge by root 2 */ | ||
609 | if (x_pos ISNT 0) | ||
610 | for (y_filt=x_base; y_filt<filt_sz; y_filt+=x_dim) | ||
611 | result[y_filt] *= ROOT2; | ||
612 | if (y_pos ISNT 0) | ||
613 | for (x_filt=y_base; x_filt<y_base+x_dim; x_filt++) | ||
614 | result[x_filt] *= ROOT2; | ||
615 | |||
616 | /* now normalize to norm of original filter */ | ||
617 | for (norm=0.0,i=0; i<filt_sz; i++) | ||
618 | norm += (result[i]*result[i]); | ||
619 | norm=sqrt(norm); | ||
620 | |||
621 | for (onorm=0.0,i=0; i<filt_sz; i++) | ||
622 | onorm += (filt[i]*filt[i]); | ||
623 | onorm = sqrt(onorm); | ||
624 | |||
625 | norm = norm/onorm; | ||
626 | for (i=0; i<filt_sz; i++) | ||
627 | result[i] /= norm; | ||
628 | return(0); | ||
629 | } | ||
630 | |||
631 | |||
632 | /* ------- printout stuff for testing ------------------------------ | ||
633 | printf("Xpos: %d, Ypos: %d", x_pos, y_pos); | ||
634 | for (y_filt=0; y_filt<y_dim; y_filt++) | ||
635 | { | ||
636 | printf("\n"); | ||
637 | for (x_filt=0; x_filt<x_dim; x_filt++) | ||
638 | printf("%6.1f", result[y_filt*x_dim+x_filt]); | ||
639 | } | ||
640 | printf("\n"); | ||
641 | */ | ||
642 | |||
643 | |||
644 | |||
645 | /* Local Variables: */ | ||
646 | /* buffer-read-only: t */ | ||
647 | /* End: */ | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/edges.mexa64 b/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/edges.mexa64 deleted file mode 100755 index 4839d1e..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/edges.mexa64 +++ /dev/null | |||
Binary files differ | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/histo.c b/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/histo.c deleted file mode 100755 index 43a99c7..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/histo.c +++ /dev/null | |||
@@ -1,140 +0,0 @@ | |||
1 | /* | ||
2 | [N, X] = histo(MTX, NBINS_OR_BINSIZE, BIN_CENTER) | ||
3 | >>> See histo.m for documentation <<< | ||
4 | EPS, ported from OBVIUS, 3/97. | ||
5 | */ | ||
6 | |||
7 | #define V4_COMPAT | ||
8 | #include <matrix.h> /* Matlab matrices */ | ||
9 | #include <mex.h> | ||
10 | |||
11 | #include <stddef.h> /* NULL */ | ||
12 | #include <math.h> /* ceil */ | ||
13 | |||
14 | #define notDblMtx(it) (!mxIsNumeric(it) || !mxIsDouble(it) || mxIsSparse(it) || mxIsComplex(it)) | ||
15 | |||
16 | #define PAD 0.49999 /* A hair below 1/2, to avoid roundoff errors */ | ||
17 | #define MAXBINS 20000 | ||
18 | |||
19 | void mexFunction(int nlhs, /* Num return vals on lhs */ | ||
20 | mxArray *plhs[], /* Matrices on lhs */ | ||
21 | int nrhs, /* Num args on rhs */ | ||
22 | const mxArray *prhs[] /* Matrices on rhs */ | ||
23 | ) | ||
24 | { | ||
25 | register double temp; | ||
26 | register int binnum, i, size; | ||
27 | register double *im, binsize; | ||
28 | register double origin, *hist, mn, mx, mean; | ||
29 | register int nbins; | ||
30 | double *bincenters; | ||
31 | mxArray *arg; | ||
32 | double *mxMat; | ||
33 | |||
34 | if (nrhs < 1 ) mexErrMsgTxt("requires at least 1 argument."); | ||
35 | |||
36 | /* ARG 1: MATRIX */ | ||
37 | arg = prhs[0]; | ||
38 | if notDblMtx(arg) mexErrMsgTxt("MTX arg must be a real non-sparse matrix."); | ||
39 | im = mxGetPr(arg); | ||
40 | size = (int) mxGetM(arg) * mxGetN(arg); | ||
41 | |||
42 | /* FIND min, max, mean values of MTX */ | ||
43 | mn = *im; mx = *im; binsize = 0; | ||
44 | for (i=1; i<size; i++) | ||
45 | { | ||
46 | temp = im[i]; | ||
47 | if (temp < mn) | ||
48 | mn = temp; | ||
49 | else if (temp > mx) | ||
50 | mx = temp; | ||
51 | binsize += temp; | ||
52 | } | ||
53 | mean = binsize / size; | ||
54 | |||
55 | /* ARG 3: BIN_CENTER */ | ||
56 | if (nrhs > 2) | ||
57 | { | ||
58 | arg = prhs[2]; | ||
59 | if notDblMtx(arg) mexErrMsgTxt("BIN_CENTER arg must be a real scalar."); | ||
60 | if (mxGetM(arg) * mxGetN(arg) != 1) | ||
61 | mexErrMsgTxt("BIN_CENTER must be a real scalar."); | ||
62 | mxMat= mxGetPr(arg); | ||
63 | origin = *mxMat; | ||
64 | } | ||
65 | else | ||
66 | origin = mean; | ||
67 | |||
68 | /* ARG 2: If positive, NBINS. If negative, -BINSIZE. */ | ||
69 | if (nrhs > 1) | ||
70 | { | ||
71 | arg = prhs[1]; | ||
72 | if notDblMtx(arg) mexErrMsgTxt("NBINS_OR_BINSIZE arg must be a real scalar."); | ||
73 | if (mxGetM(arg) * mxGetN(arg) != 1) | ||
74 | mexErrMsgTxt("NBINS_OR_BINSIZE must be a real scalar."); | ||
75 | mxMat= mxGetPr(arg); | ||
76 | binsize = *mxMat; | ||
77 | } | ||
78 | else | ||
79 | { | ||
80 | binsize = 101; /* DEFAULT: 101 bins */ | ||
81 | } | ||
82 | |||
83 | /* -------------------------------------------------- | ||
84 | Adjust origin, binsize, nbins such that | ||
85 | mx <= origin + (nbins-1)*binsize + PAD*binsize | ||
86 | mn >= origin - PAD*binsize | ||
87 | -------------------------------------------------- */ | ||
88 | if (binsize < 0) /* user specified BINSIZE */ | ||
89 | { | ||
90 | binsize = -binsize; | ||
91 | origin -= binsize * ceil((origin-mn-PAD*binsize)/binsize); | ||
92 | nbins = (int) ceil((mx-origin-PAD*binsize)/binsize) + 1; | ||
93 | } | ||
94 | else /* user specified NBINS */ | ||
95 | { | ||
96 | nbins = (int) (binsize + 0.5); /* round to int */ | ||
97 | if (nbins == 0) | ||
98 | mexErrMsgTxt("NBINS must be greater than zero."); | ||
99 | binsize = (mx-mn)/(nbins-1+2*PAD); /* start with lower bound */ | ||
100 | i = ceil((origin-mn-binsize/2)/binsize); | ||
101 | if ( mn < (origin-i*binsize-PAD*binsize) ) | ||
102 | binsize = (origin-mn)/(i+PAD); | ||
103 | else if ( mx > (origin+(nbins-1-i)*binsize+PAD*binsize) ) | ||
104 | binsize = (mx-origin)/((nbins-1-i)+PAD); | ||
105 | origin -= binsize * ceil((origin-mn-PAD*binsize)/binsize); | ||
106 | } | ||
107 | |||
108 | if (nbins > MAXBINS) | ||
109 | { | ||
110 | mexPrintf("nbins: %d, MAXBINS: %d\n",nbins,MAXBINS); | ||
111 | mexErrMsgTxt("Number of histo bins has exceeded maximum"); | ||
112 | } | ||
113 | |||
114 | /* Allocate hist and xvals */ | ||
115 | plhs[0] = (mxArray *) mxCreateDoubleMatrix(1,nbins,mxREAL); | ||
116 | if (plhs[0] == NULL) mexErrMsgTxt("Error allocating result matrix"); | ||
117 | hist = mxGetPr(plhs[0]); | ||
118 | |||
119 | if (nlhs > 1) | ||
120 | { | ||
121 | plhs[1] = (mxArray *) mxCreateDoubleMatrix(1,nbins,mxREAL); | ||
122 | if (plhs[1] == NULL) mexErrMsgTxt("Error allocating result matrix"); | ||
123 | bincenters = mxGetPr(plhs[1]); | ||
124 | for (i=0, temp=origin; i<nbins; i++, temp+=binsize) | ||
125 | bincenters[i] = temp; | ||
126 | } | ||
127 | |||
128 | for (i=0; i<size; i++) | ||
129 | { | ||
130 | binnum = (int) ((im[i] - origin)/binsize + 0.5); | ||
131 | if ((binnum < nbins) && (binnum >= 0)) | ||
132 | (hist[binnum]) += 1.0; | ||
133 | else | ||
134 | printf("HISTO warning: value %f outside of range [%f,%f]\n", | ||
135 | im[i], origin-0.5*binsize, origin+(nbins-0.5)*binsize); | ||
136 | } | ||
137 | |||
138 | return; | ||
139 | } | ||
140 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/innerProd.c b/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/innerProd.c deleted file mode 100755 index 8fa1224..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/innerProd.c +++ /dev/null | |||
@@ -1,52 +0,0 @@ | |||
1 | /* | ||
2 | RES = innerProd(MAT); | ||
3 | Computes mat'*mat | ||
4 | Odelia Schwartz, 8/97. | ||
5 | */ | ||
6 | |||
7 | #define V4_COMPAT | ||
8 | #include <matrix.h> | ||
9 | |||
10 | #include <stdio.h> | ||
11 | #include <ctype.h> | ||
12 | #include <math.h> | ||
13 | #include <strings.h> | ||
14 | #include <stdlib.h> | ||
15 | |||
16 | void mexFunction(int nlhs, /* Num return vals on lhs */ | ||
17 | mxArray *plhs[], /* Matrices on lhs */ | ||
18 | int nrhs, /* Num args on rhs */ | ||
19 | const mxArray *prhs[] /* Matrices on rhs */ | ||
20 | ) | ||
21 | { | ||
22 | register double *res, *mat, tmp; | ||
23 | register int len, wid, i, k, j, jlen, ilen, imat, jmat; | ||
24 | mxArray *arg; | ||
25 | |||
26 | /* get matrix input argument */ | ||
27 | /* should be matrix in which num rows >= num columns */ | ||
28 | arg=prhs[0]; | ||
29 | mat= mxGetPr(arg); | ||
30 | len = (int) mxGetM(arg); | ||
31 | wid = (int) mxGetN(arg); | ||
32 | if ( wid > len ) | ||
33 | printf("innerProd: Warning: width %d is greater than length %d.\n",wid,len); | ||
34 | plhs[0] = (mxArray *) mxCreateDoubleMatrix(wid,wid,mxREAL); | ||
35 | if (plhs[0] == NULL) | ||
36 | mexErrMsgTxt(sprintf("Error allocating %dx%d result matrix",wid,wid)); | ||
37 | res = mxGetPr(plhs[0]); | ||
38 | |||
39 | for(i=0, ilen=0; i<wid; i++, ilen+=len) | ||
40 | { | ||
41 | for(j=i, jlen=ilen; j<wid; j++, jlen+=len) | ||
42 | { | ||
43 | tmp = 0.0; | ||
44 | for(k=0, imat=ilen, jmat=jlen; k<len; k++, imat++, jmat++) | ||
45 | tmp += mat[imat]*mat[jmat]; | ||
46 | res[i*wid+j] = tmp; | ||
47 | res[j*wid+i] = tmp; | ||
48 | } | ||
49 | } | ||
50 | return; | ||
51 | |||
52 | } | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/innerProd.dll b/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/innerProd.dll deleted file mode 100755 index 40ac896..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/innerProd.dll +++ /dev/null | |||
Binary files differ | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/innerProd.mexa64 b/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/innerProd.mexa64 deleted file mode 100755 index e31a97e..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/innerProd.mexa64 +++ /dev/null | |||
Binary files differ | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/innerProd.mexglx b/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/innerProd.mexglx deleted file mode 100755 index 749a5b5..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/innerProd.mexglx +++ /dev/null | |||
Binary files differ | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/innerProd.mexlx b/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/innerProd.mexlx deleted file mode 100755 index 151b08f..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/innerProd.mexlx +++ /dev/null | |||
Binary files differ | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/innerProd.mexmac b/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/innerProd.mexmac deleted file mode 100755 index 6e11fcd..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/innerProd.mexmac +++ /dev/null | |||
Binary files differ | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/innerProd.mexsol b/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/innerProd.mexsol deleted file mode 100755 index d761ed8..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/innerProd.mexsol +++ /dev/null | |||
Binary files differ | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/pointOp.c b/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/pointOp.c deleted file mode 100755 index 6ffcb45..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/pointOp.c +++ /dev/null | |||
@@ -1,126 +0,0 @@ | |||
1 | /* | ||
2 | RES = pointOp(IM, LUT, ORIGIN, INCREMENT, WARNINGS) | ||
3 | >>> See pointOp.m for documentation <<< | ||
4 | EPS, ported from OBVIUS, 7/96. | ||
5 | */ | ||
6 | |||
7 | #define V4_COMPAT | ||
8 | #include <matrix.h> /* Matlab matrices */ | ||
9 | #include <mex.h> | ||
10 | |||
11 | #include <stddef.h> /* NULL */ | ||
12 | |||
13 | #define notDblMtx(it) (!mxIsNumeric(it) || !mxIsDouble(it) || mxIsSparse(it) || mxIsComplex(it)) | ||
14 | |||
15 | void internal_pointop(); | ||
16 | |||
17 | void mexFunction(int nlhs, /* Num return vals on lhs */ | ||
18 | mxArray *plhs[], /* Matrices on lhs */ | ||
19 | int nrhs, /* Num args on rhs */ | ||
20 | const mxArray *prhs[] /* Matrices on rhs */ | ||
21 | ) | ||
22 | { | ||
23 | double *image, *lut, *res; | ||
24 | double origin, increment; | ||
25 | int x_dim, y_dim, lx_dim, ly_dim; | ||
26 | int warnings = 1; | ||
27 | mxArray *arg; | ||
28 | double *mxMat; | ||
29 | |||
30 | if (nrhs < 4 ) mexErrMsgTxt("requres at least 4 args."); | ||
31 | |||
32 | /* ARG 1: IMAGE */ | ||
33 | arg = prhs[0]; | ||
34 | if notDblMtx(arg) mexErrMsgTxt("IMAGE arg must be a real non-sparse matrix."); | ||
35 | image = mxGetPr(arg); | ||
36 | x_dim = (int) mxGetM(arg); /* X is inner index! */ | ||
37 | y_dim = (int) mxGetN(arg); | ||
38 | |||
39 | /* ARG 2: Lookup table */ | ||
40 | arg = prhs[1]; | ||
41 | if notDblMtx(arg) mexErrMsgTxt("LUT arg must be a real non-sparse matrix."); | ||
42 | lut = mxGetPr(arg); | ||
43 | lx_dim = (int) mxGetM(arg); /* X is inner index! */ | ||
44 | ly_dim = (int) mxGetN(arg); | ||
45 | if ( (lx_dim != 1) && (ly_dim != 1) ) | ||
46 | mexErrMsgTxt("Lookup table must be a row or column vector."); | ||
47 | |||
48 | /* ARG 3: ORIGIN */ | ||
49 | arg = prhs[2]; | ||
50 | if notDblMtx(arg) mexErrMsgTxt("ORIGIN arg must be a real scalar."); | ||
51 | if (mxGetM(arg) * mxGetN(arg) != 1) | ||
52 | mexErrMsgTxt("ORIGIN arg must be a real scalar."); | ||
53 | mxMat = mxGetPr(arg); | ||
54 | origin = *mxMat; | ||
55 | |||
56 | /* ARG 4: INCREMENT */ | ||
57 | arg = prhs[3]; | ||
58 | if notDblMtx(arg) mexErrMsgTxt("INCREMENT arg must be a real scalar."); | ||
59 | if (mxGetM(arg) * mxGetN(arg) != 1) | ||
60 | mexErrMsgTxt("INCREMENT arg must be a real scalar."); | ||
61 | mxMat = mxGetPr(arg); | ||
62 | increment = *mxMat; | ||
63 | |||
64 | /* ARG 5: WARNINGS */ | ||
65 | if (nrhs>4) | ||
66 | { | ||
67 | arg = prhs[4]; | ||
68 | if notDblMtx(arg) mexErrMsgTxt("WARINGS arg must be a real scalar."); | ||
69 | if (mxGetM(arg) * mxGetN(arg) != 1) | ||
70 | mexErrMsgTxt("WARNINGS arg must be a real scalar."); | ||
71 | mxMat = mxGetPr(arg); | ||
72 | warnings = (int) *mxMat; | ||
73 | } | ||
74 | |||
75 | plhs[0] = (mxArray *) mxCreateDoubleMatrix(x_dim,y_dim,mxREAL); | ||
76 | if (plhs[0] == NULL) mexErrMsgTxt("Cannot allocate result matrix"); | ||
77 | res = mxGetPr(plhs[0]); | ||
78 | |||
79 | internal_pointop(image, res, x_dim*y_dim, lut, lx_dim*ly_dim, | ||
80 | origin, increment, warnings); | ||
81 | return; | ||
82 | } | ||
83 | |||
84 | |||
85 | /* Use linear interpolation on a lookup table. | ||
86 | Taken from OBVIUS. EPS, Spring, 1987. | ||
87 | */ | ||
88 | void internal_pointop (im, res, size, lut, lutsize, origin, increment, warnings) | ||
89 | register double *im, *res, *lut; | ||
90 | register double origin, increment; | ||
91 | register int size, lutsize, warnings; | ||
92 | { | ||
93 | register int i, index; | ||
94 | register double pos; | ||
95 | register int l_unwarned = warnings; | ||
96 | register int r_unwarned = warnings; | ||
97 | |||
98 | lutsize = lutsize - 2; /* Maximum index value */ | ||
99 | if (increment > 0) | ||
100 | for (i=0; i<size; i++) | ||
101 | { | ||
102 | pos = (im[i] - origin) / increment; | ||
103 | index = (int) pos; /* Floor */ | ||
104 | if (index < 0) | ||
105 | { | ||
106 | index = 0; | ||
107 | if (l_unwarned) | ||
108 | { | ||
109 | mexPrintf("Warning: Extrapolating to left of lookup table...\n"); | ||
110 | l_unwarned = 0; | ||
111 | } | ||
112 | } | ||
113 | else if (index > lutsize) | ||
114 | { | ||
115 | index = lutsize; | ||
116 | if (r_unwarned) | ||
117 | { | ||
118 | mexPrintf("Warning: Extrapolating to right of lookup table...\n"); | ||
119 | r_unwarned = 0; | ||
120 | } | ||
121 | } | ||
122 | res[i] = lut[index] + (lut[index+1] - lut[index]) * (pos - index); | ||
123 | } | ||
124 | else | ||
125 | for (i=0; i<size; i++) res[i] = *lut; | ||
126 | } | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/range2.c b/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/range2.c deleted file mode 100755 index b84f4e1..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/range2.c +++ /dev/null | |||
@@ -1,56 +0,0 @@ | |||
1 | /* | ||
2 | [MIN, MAX] = range2(MTX) | ||
3 | >>> See range2.m for documentation <<< | ||
4 | EPS, 3/97. | ||
5 | */ | ||
6 | |||
7 | #define V4_COMPAT | ||
8 | #include <matrix.h> /* Matlab matrices */ | ||
9 | #include <mex.h> | ||
10 | |||
11 | #include <stddef.h> /* NULL */ | ||
12 | |||
13 | #define notDblMtx(it) (!mxIsNumeric(it) || !mxIsDouble(it) || mxIsSparse(it) || mxIsComplex(it)) | ||
14 | |||
15 | void mexFunction(int nlhs, /* Num return vals on lhs */ | ||
16 | mxArray *plhs[], /* Matrices on lhs */ | ||
17 | int nrhs, /* Num args on rhs */ | ||
18 | const mxArray *prhs[] /* Matrices on rhs */ | ||
19 | ) | ||
20 | { | ||
21 | register double temp, mn, mx; | ||
22 | register double *mtx; | ||
23 | register int i, size; | ||
24 | mxArray *arg; | ||
25 | |||
26 | if (nrhs != 1) mexErrMsgTxt("requires 1 argument."); | ||
27 | |||
28 | /* ARG 1: MATRIX */ | ||
29 | arg = prhs[0]; | ||
30 | if notDblMtx(arg) mexErrMsgTxt("MTX arg must be a real non-sparse matrix."); | ||
31 | mtx = mxGetPr(arg); | ||
32 | size = (int) mxGetM(arg) * mxGetN(arg); | ||
33 | |||
34 | /* FIND min, max values of MTX */ | ||
35 | mn = *mtx; mx = *mtx; | ||
36 | for (i=1; i<size; i++) | ||
37 | { | ||
38 | temp = mtx[i]; | ||
39 | if (temp < mn) | ||
40 | mn = temp; | ||
41 | else if (temp > mx) | ||
42 | mx = temp; | ||
43 | } | ||
44 | |||
45 | plhs[0] = (mxArray *) mxCreateDoubleMatrix(1,1,mxREAL); | ||
46 | if (plhs[0] == NULL) mexErrMsgTxt("Error allocating result matrix"); | ||
47 | plhs[1] = (mxArray *) mxCreateDoubleMatrix(1,1,mxREAL); | ||
48 | if (plhs[1] == NULL) mexErrMsgTxt("Error allocating result matrix"); | ||
49 | mtx = mxGetPr(plhs[0]); | ||
50 | mtx[0] = mn; | ||
51 | mtx = mxGetPr(plhs[1]); | ||
52 | mtx[0] = mx; | ||
53 | |||
54 | return; | ||
55 | } | ||
56 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/upConv.c b/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/upConv.c deleted file mode 100755 index 3708f8a..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/upConv.c +++ /dev/null | |||
@@ -1,195 +0,0 @@ | |||
1 | /* | ||
2 | RES = upConv(IM, FILT, EDGES, STEP, START, STOP, RES); | ||
3 | >>> See upConv.m for documentation <<< | ||
4 | This is a matlab interface to the internal_expand function. | ||
5 | EPS, 7/96. | ||
6 | */ | ||
7 | |||
8 | #define V4_COMPAT | ||
9 | #include <matrix.h> /* Matlab matrices */ | ||
10 | #include <mex.h> | ||
11 | |||
12 | #include "convolve.h" | ||
13 | |||
14 | #define notDblMtx(it) (!mxIsNumeric(it) || !mxIsDouble(it) || mxIsSparse(it) || mxIsComplex(it)) | ||
15 | |||
16 | void mexFunction(int nlhs, /* Num return vals on lhs */ | ||
17 | mxArray *plhs[], /* Matrices on lhs */ | ||
18 | int nrhs, /* Num args on rhs */ | ||
19 | const mxArray *prhs[] /* Matrices on rhs */ | ||
20 | ) | ||
21 | { | ||
22 | double *image,*filt, *temp, *result, *orig_filt; | ||
23 | int x_fdim, y_fdim, x_idim, y_idim; | ||
24 | int orig_x = 0, orig_y, x, y; | ||
25 | int x_rdim, y_rdim; | ||
26 | int x_start = 1; | ||
27 | int x_step = 1; | ||
28 | int y_start = 1; | ||
29 | int y_step = 1; | ||
30 | int x_stop, y_stop; | ||
31 | mxArray *arg; | ||
32 | double *mxMat; | ||
33 | char edges[15] = "reflect1"; | ||
34 | |||
35 | if (nrhs<2) mexErrMsgTxt("requres at least 2 args."); | ||
36 | |||
37 | /* ARG 1: IMAGE */ | ||
38 | arg = prhs[0]; | ||
39 | if notDblMtx(arg) mexErrMsgTxt("IMAGE arg must be a non-sparse double float matrix."); | ||
40 | image = mxGetPr(arg); | ||
41 | x_idim = (int) mxGetM(arg); /* X is inner index! */ | ||
42 | y_idim = (int) mxGetN(arg); | ||
43 | |||
44 | /* ARG 2: FILTER */ | ||
45 | arg = prhs[1]; | ||
46 | if notDblMtx(arg) mexErrMsgTxt("FILTER arg must be non-sparse double float matrix."); filt = mxGetPr(arg); | ||
47 | x_fdim = (int) mxGetM(arg); | ||
48 | y_fdim = (int) mxGetN(arg); | ||
49 | |||
50 | /* ARG 3 (optional): EDGES */ | ||
51 | if (nrhs>2) | ||
52 | { | ||
53 | if (!mxIsChar(prhs[2])) | ||
54 | mexErrMsgTxt("EDGES arg must be a string."); | ||
55 | mxGetString(prhs[2],edges,15); | ||
56 | } | ||
57 | |||
58 | /* ARG 4 (optional): STEP */ | ||
59 | if (nrhs>3) | ||
60 | { | ||
61 | arg = prhs[3]; | ||
62 | if notDblMtx(arg) mexErrMsgTxt("STEP arg must be double float matrix."); | ||
63 | if (mxGetM(arg) * mxGetN(arg) != 2) | ||
64 | mexErrMsgTxt("STEP arg must contain two elements."); | ||
65 | mxMat = mxGetPr(arg); | ||
66 | x_step = (int) mxMat[0]; | ||
67 | y_step = (int) mxMat[1]; | ||
68 | if ((x_step<1) || (y_step<1)) | ||
69 | mexErrMsgTxt("STEP values must be greater than zero."); | ||
70 | } | ||
71 | |||
72 | /* ARG 5 (optional): START */ | ||
73 | if (nrhs>4) | ||
74 | { | ||
75 | arg = prhs[4]; | ||
76 | if notDblMtx(arg) mexErrMsgTxt("START arg must be double float matrix."); | ||
77 | if (mxGetM(arg) * mxGetN(arg) != 2) | ||
78 | mexErrMsgTxt("START arg must contain two elements."); | ||
79 | mxMat = mxGetPr(arg); | ||
80 | x_start = (int) mxMat[0]; | ||
81 | y_start = (int) mxMat[1]; | ||
82 | if ((x_start<1) || (y_start<1)) | ||
83 | mexErrMsgTxt("START values must be greater than zero."); | ||
84 | } | ||
85 | x_start--; /* convert to standard C indexes */ | ||
86 | y_start--; | ||
87 | |||
88 | /* ARG 6 (optional): STOP */ | ||
89 | if (nrhs>5) | ||
90 | { | ||
91 | if notDblMtx(prhs[5]) mexErrMsgTxt("STOP arg must be double float matrix."); | ||
92 | if (mxGetM(prhs[5]) * mxGetN(prhs[5]) != 2) | ||
93 | mexErrMsgTxt("STOP arg must contain two elements."); | ||
94 | mxMat = mxGetPr(prhs[5]); | ||
95 | x_stop = (int) mxMat[0]; | ||
96 | y_stop = (int) mxMat[1]; | ||
97 | if ((x_stop<x_start) || (y_stop<y_start)) | ||
98 | mexErrMsgTxt("STOP values must be greater than START values."); | ||
99 | } | ||
100 | else | ||
101 | { /* default: make res dims a multiple of STEP size */ | ||
102 | x_stop = x_step * ((x_start/x_step) + x_idim); | ||
103 | y_stop = y_step * ((y_start/y_step) + y_idim); | ||
104 | } | ||
105 | |||
106 | /* ARG 6 (optional): RESULT image */ | ||
107 | if (nrhs>6) | ||
108 | { | ||
109 | arg = prhs[6]; | ||
110 | if notDblMtx(arg) mexErrMsgTxt("RES arg must be double float matrix."); | ||
111 | |||
112 | /* 7/10/97: Returning one of the args causes problems with Matlab's memory | ||
113 | manager, so we don't return anything if the result image is passed */ | ||
114 | /* plhs[0] = arg; */ | ||
115 | result = mxGetPr(arg); | ||
116 | x_rdim = (int) mxGetM(arg); /* X is inner index! */ | ||
117 | y_rdim = (int) mxGetN(arg); | ||
118 | if ((x_stop>x_rdim) || (y_stop>y_rdim)) | ||
119 | mexErrMsgTxt("STOP values must within image dimensions."); | ||
120 | } | ||
121 | else | ||
122 | { | ||
123 | x_rdim = x_stop; | ||
124 | y_rdim = y_stop; | ||
125 | /* x_rdim = x_step * ((x_stop+x_step-1)/x_step); | ||
126 | y_rdim = y_step * ((y_stop+y_step-1)/y_step); */ | ||
127 | |||
128 | plhs[0] = (mxArray *) mxCreateDoubleMatrix(x_rdim,y_rdim,mxREAL); | ||
129 | if (plhs[0] == NULL) mexErrMsgTxt("Cannot allocate result matrix"); | ||
130 | result = mxGetPr(plhs[0]); | ||
131 | } | ||
132 | |||
133 | if ( (((x_stop-x_start+x_step-1) / x_step) != x_idim) || | ||
134 | (((y_stop-y_start+y_step-1) / y_step) != y_idim) ) | ||
135 | { | ||
136 | mexPrintf("Im dims: [%d %d]\n",x_idim,y_idim); | ||
137 | mexPrintf("Start: [%d %d]\n",x_start,y_start); | ||
138 | mexPrintf("Step: [%d %d]\n",x_step,y_step); | ||
139 | mexPrintf("Stop: [%d %d]\n",x_stop,y_stop); | ||
140 | mexPrintf("Res dims: [%d %d]\n",x_rdim,y_rdim); | ||
141 | mexErrMsgTxt("Image sizes and upsampling args are incompatible!"); | ||
142 | } | ||
143 | |||
144 | /* upConv has a bug for even-length kernels when using the | ||
145 | reflect1, extend, or repeat edge-handlers */ | ||
146 | if ((!strcmp(edges,"reflect1") || !strcmp(edges,"extend") || !strcmp(edges,"repeat")) | ||
147 | && | ||
148 | ((x_fdim%2 == 0) || (y_fdim%2 == 0))) | ||
149 | { | ||
150 | orig_filt = filt; | ||
151 | orig_x = x_fdim; | ||
152 | orig_y = y_fdim; | ||
153 | x_fdim = 2*(orig_x/2)+1; | ||
154 | y_fdim = 2*(orig_y/2)+1; | ||
155 | filt = mxCalloc(x_fdim*y_fdim, sizeof(double)); | ||
156 | if (filt == NULL) | ||
157 | mexErrMsgTxt("Cannot allocate necessary temporary space"); | ||
158 | for (y=0; y<orig_y; y++) | ||
159 | for (x=0; x<orig_x; x++) | ||
160 | filt[y*x_fdim + x] = orig_filt[y*orig_x + x]; | ||
161 | } | ||
162 | |||
163 | if ((x_fdim > x_rdim) || (y_fdim > y_rdim)) | ||
164 | { | ||
165 | mexPrintf("Filter: [%d %d], ",x_fdim,y_fdim); | ||
166 | mexPrintf("Result: [%d %d]\n",x_rdim,y_rdim); | ||
167 | mexErrMsgTxt("FILTER dimensions larger than RESULT dimensions."); | ||
168 | } | ||
169 | |||
170 | temp = mxCalloc(x_fdim*y_fdim, sizeof(double)); | ||
171 | if (temp == NULL) | ||
172 | mexErrMsgTxt("Cannot allocate necessary temporary space"); | ||
173 | |||
174 | /* | ||
175 | printf("(%d, %d), (%d, %d), (%d, %d), (%d, %d), (%d, %d), %s\n", | ||
176 | x_idim,y_idim,x_fdim,y_fdim,x_rdim,y_rdim, | ||
177 | x_start,x_step,y_start,y_step,edges); | ||
178 | */ | ||
179 | |||
180 | if (strcmp(edges,"circular") == 0) | ||
181 | internal_wrap_expand(image, filt, x_fdim, y_fdim, | ||
182 | x_start, x_step, x_stop, y_start, y_step, y_stop, | ||
183 | result, x_rdim, y_rdim); | ||
184 | else internal_expand(image, filt, temp, x_fdim, y_fdim, | ||
185 | x_start, x_step, x_stop, y_start, y_step, y_stop, | ||
186 | result, x_rdim, y_rdim, edges); | ||
187 | |||
188 | if (orig_x) mxFree((char *) filt); | ||
189 | mxFree((char *) temp); | ||
190 | |||
191 | return; | ||
192 | } | ||
193 | |||
194 | |||
195 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/wrap.c b/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/wrap.c deleted file mode 100755 index a081123..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/wrap.c +++ /dev/null | |||
@@ -1,281 +0,0 @@ | |||
1 | /* | ||
2 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
3 | ;;; File: wrap.c | ||
4 | ;;; Author: Eero Simoncelli | ||
5 | ;;; Description: Circular convolution on 2D images. | ||
6 | ;;; Creation Date: Spring, 1987. | ||
7 | ;;; MODIFICATIONS: | ||
8 | ;;; 6/96: Switched array types to double float. | ||
9 | ;;; 2/97: made more robust and readable. Added STOP arguments. | ||
10 | ;;; ---------------------------------------------------------------- | ||
11 | ;;; Object-Based Vision and Image Understanding System (OBVIUS), | ||
12 | ;;; Copyright 1988, Vision Science Group, Media Laboratory, | ||
13 | ;;; Massachusetts Institute of Technology. | ||
14 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
15 | */ | ||
16 | |||
17 | #include <stdlib.h> | ||
18 | |||
19 | #include "convolve.h" | ||
20 | |||
21 | /* | ||
22 | -------------------------------------------------------------------- | ||
23 | Performs correlation (i.e., convolution with filt(-x,-y)) of FILT | ||
24 | with IMAGE followed by subsampling (a.k.a. REDUCE in Burt&Adelson81). | ||
25 | The operations are combined to avoid unnecessary computation of the | ||
26 | convolution samples that are to be discarded in the subsampling | ||
27 | operation. The convolution is done in 9 sections so that mod | ||
28 | operations are not performed unnecessarily. The subsampling lattice | ||
29 | is specified by the START, STEP and STOP parameters. | ||
30 | -------------------------------------------------------------------- */ | ||
31 | |||
32 | /* abstract out the inner product computation */ | ||
33 | #define INPROD(YSTART,YIND,XSTART,XIND) \ | ||
34 | { \ | ||
35 | sum=0.0; \ | ||
36 | for (y_im=YSTART, filt_pos=0, x_filt_stop=x_fdim; \ | ||
37 | x_filt_stop<=filt_size; \ | ||
38 | y_im++, x_filt_stop+=x_fdim) \ | ||
39 | for (x_im=XSTART ; \ | ||
40 | filt_pos<x_filt_stop; \ | ||
41 | filt_pos++, x_im++) \ | ||
42 | sum += imval[YIND][XIND] * filt[filt_pos]; \ | ||
43 | result[res_pos] = sum; \ | ||
44 | } | ||
45 | |||
46 | int internal_wrap_reduce(image, x_dim, y_dim, filt, x_fdim, y_fdim, | ||
47 | x_start, x_step, x_stop, y_start, y_step, y_stop, | ||
48 | result) | ||
49 | register image_type *filt, *result; | ||
50 | register int x_dim, y_dim, x_fdim, y_fdim; | ||
51 | image_type *image; | ||
52 | int x_start, x_step, x_stop, y_start, y_step, y_stop; | ||
53 | { | ||
54 | register double sum; | ||
55 | register int filt_size = x_fdim*y_fdim; | ||
56 | image_type **imval; | ||
57 | register int filt_pos, x_im, y_im, x_filt_stop; | ||
58 | register int x_pos, y_pos, res_pos; | ||
59 | int x_ctr_stop = x_dim - x_fdim + 1; | ||
60 | int y_ctr_stop = y_dim - y_fdim + 1; | ||
61 | int x_ctr_start = 0; | ||
62 | int y_ctr_start = 0; | ||
63 | int x_fmid = x_fdim/2; | ||
64 | int y_fmid = y_fdim/2; | ||
65 | |||
66 | /* shift start/stop coords to filter upper left hand corner */ | ||
67 | x_start -= x_fmid; y_start -= y_fmid; | ||
68 | x_stop -= x_fmid; y_stop -= y_fmid; | ||
69 | |||
70 | if (x_stop < x_ctr_stop) x_ctr_stop = x_stop; | ||
71 | if (y_stop < y_ctr_stop) y_ctr_stop = y_stop; | ||
72 | |||
73 | /* Set up pointer array for rows */ | ||
74 | imval = (image_type **) malloc(y_dim*sizeof(image_type *)); | ||
75 | if (imval IS NULL) | ||
76 | { | ||
77 | printf("INTERNAL_WRAP: Failed to allocate temp array!"); | ||
78 | return(-1); | ||
79 | } | ||
80 | for (y_pos=y_im=0;y_pos<y_dim;y_pos++,y_im+=x_dim) | ||
81 | imval[y_pos] = (image+y_im); | ||
82 | |||
83 | for (res_pos=0, y_pos=y_start; /* TOP ROWS */ | ||
84 | y_pos<y_ctr_start; | ||
85 | y_pos+=y_step) | ||
86 | { | ||
87 | for (x_pos=x_start; | ||
88 | x_pos<x_ctr_start; | ||
89 | x_pos+=x_step, res_pos++) | ||
90 | INPROD(y_pos+y_dim, y_im%y_dim, x_pos+x_dim, x_im%x_dim) | ||
91 | |||
92 | for (; | ||
93 | x_pos<x_ctr_stop; | ||
94 | x_pos+=x_step, res_pos++) | ||
95 | INPROD(y_pos+y_dim, y_im%y_dim, x_pos, x_im) | ||
96 | |||
97 | for (; | ||
98 | x_pos<x_stop; | ||
99 | x_pos+=x_step, res_pos++) | ||
100 | INPROD(y_pos+y_dim, y_im%y_dim, x_pos, x_im%x_dim) | ||
101 | } /* end TOP ROWS */ | ||
102 | |||
103 | for (; /* MID ROWS */ | ||
104 | y_pos<y_ctr_stop; | ||
105 | y_pos+=y_step) | ||
106 | { | ||
107 | for (x_pos=x_start; | ||
108 | x_pos<x_ctr_start; | ||
109 | x_pos+=x_step, res_pos++) | ||
110 | INPROD(y_pos, y_im, x_pos+x_dim, x_im%x_dim) | ||
111 | |||
112 | for (; /* CENTER SECTION */ | ||
113 | x_pos<x_ctr_stop; | ||
114 | x_pos+=x_step, res_pos++) | ||
115 | INPROD(y_pos, y_im, x_pos, x_im) | ||
116 | |||
117 | for (; | ||
118 | x_pos<x_stop; | ||
119 | x_pos+=x_step, res_pos++) | ||
120 | INPROD(y_pos, y_im, x_pos, x_im%x_dim) | ||
121 | } /* end MID ROWS */ | ||
122 | |||
123 | for (; /* BOTTOM ROWS */ | ||
124 | y_pos<y_stop; | ||
125 | y_pos+=y_step) | ||
126 | { | ||
127 | for (x_pos=x_start; | ||
128 | x_pos<x_ctr_start; | ||
129 | x_pos+=x_step, res_pos++) | ||
130 | INPROD(y_pos, y_im%y_dim, x_pos+x_dim, x_im%x_dim) | ||
131 | |||
132 | for (; | ||
133 | x_pos<x_ctr_stop; | ||
134 | x_pos+=x_step, res_pos++) | ||
135 | INPROD(y_pos, y_im%y_dim, x_pos, x_im) | ||
136 | |||
137 | for (; | ||
138 | x_pos<x_stop; | ||
139 | x_pos+=x_step, res_pos++) | ||
140 | INPROD(y_pos, y_im%y_dim, x_pos, x_im%x_dim) | ||
141 | } /* end BOTTOM ROWS */ | ||
142 | |||
143 | free ((image_type **) imval); | ||
144 | |||
145 | return(0); | ||
146 | } /* end of internal_wrap_reduce */ | ||
147 | |||
148 | |||
149 | |||
150 | /* | ||
151 | -------------------------------------------------------------------- | ||
152 | Performs upsampling (padding with zeros) followed by convolution of | ||
153 | FILT with IMAGE (a.k.a. EXPAND in Burt&Adelson81). The operations | ||
154 | are combined to avoid unnecessary multiplication of filter samples | ||
155 | with zeros in the upsampled image. The convolution is done in 9 | ||
156 | sections so that mod operation is not performed unnecessarily. | ||
157 | Arguments are described in the comment above internal_wrap_reduce. | ||
158 | |||
159 | WARNING: this subroutine destructively modifes the RESULT image, so | ||
160 | the user must zero the result before invocation! | ||
161 | -------------------------------------------------------------------- */ | ||
162 | |||
163 | /* abstract out the inner product computation */ | ||
164 | #define INPROD2(YSTART,YIND,XSTART,XIND) \ | ||
165 | { \ | ||
166 | val = image[im_pos]; \ | ||
167 | for (y_res=YSTART, filt_pos=0, x_filt_stop=x_fdim; \ | ||
168 | x_filt_stop<=filt_size; \ | ||
169 | y_res++, x_filt_stop+=x_fdim) \ | ||
170 | for (x_res=XSTART; \ | ||
171 | filt_pos<x_filt_stop; \ | ||
172 | filt_pos++, x_res++) \ | ||
173 | imval[YIND][XIND] += val * filt[filt_pos]; \ | ||
174 | } | ||
175 | |||
176 | int internal_wrap_expand(image, filt, x_fdim, y_fdim, | ||
177 | x_start, x_step, x_stop, y_start, y_step, y_stop, | ||
178 | result, x_dim, y_dim) | ||
179 | register image_type *filt, *result; | ||
180 | register int x_fdim, y_fdim, x_dim, y_dim; | ||
181 | image_type *image; | ||
182 | int x_start, x_step, x_stop, y_start, y_step, y_stop; | ||
183 | { | ||
184 | register double val; | ||
185 | register int filt_size = x_fdim*y_fdim; | ||
186 | image_type **imval; | ||
187 | register int filt_pos, x_res, y_res, x_filt_stop; | ||
188 | register int x_pos, y_pos, im_pos; | ||
189 | int x_ctr_stop = x_dim - x_fdim + 1; | ||
190 | int y_ctr_stop = y_dim - y_fdim + 1; | ||
191 | int x_ctr_start = 0; | ||
192 | int y_ctr_start = 0; | ||
193 | int x_fmid = x_fdim/2; | ||
194 | int y_fmid = y_fdim/2; | ||
195 | |||
196 | /* shift start/stop coords to filter upper left hand corner */ | ||
197 | x_start -= x_fmid; y_start -= y_fmid; | ||
198 | x_stop -= x_fmid; y_stop -= y_fmid; | ||
199 | |||
200 | if (x_stop < x_ctr_stop) x_ctr_stop = x_stop; | ||
201 | if (y_stop < y_ctr_stop) y_ctr_stop = y_stop; | ||
202 | |||
203 | /* Set up pointer array for rows */ | ||
204 | imval = (image_type **) malloc(y_dim*sizeof(image_type *)); | ||
205 | if (imval IS NULL) | ||
206 | { | ||
207 | printf("INTERNAL_WRAP: Failed to allocate temp array!"); | ||
208 | return(-1); | ||
209 | } | ||
210 | for (y_pos=y_res=0;y_pos<y_dim;y_pos++,y_res+=x_dim) | ||
211 | imval[y_pos] = (result+y_res); | ||
212 | |||
213 | for (im_pos=0, y_pos=y_start; /* TOP ROWS */ | ||
214 | y_pos<y_ctr_start; | ||
215 | y_pos+=y_step) | ||
216 | { | ||
217 | for (x_pos=x_start; | ||
218 | x_pos<x_ctr_start; | ||
219 | x_pos+=x_step, im_pos++) | ||
220 | INPROD2(y_pos+y_dim, y_res%y_dim, x_pos+x_dim, x_res%x_dim) | ||
221 | |||
222 | for (; | ||
223 | x_pos<x_ctr_stop; | ||
224 | x_pos+=x_step, im_pos++) | ||
225 | INPROD2(y_pos+y_dim, y_res%y_dim, x_pos, x_res) | ||
226 | |||
227 | for (; | ||
228 | x_pos<x_stop; | ||
229 | x_pos+=x_step, im_pos++) | ||
230 | INPROD2(y_pos+y_dim, y_res%y_dim, x_pos, x_res%x_dim) | ||
231 | } /* end TOP ROWS */ | ||
232 | |||
233 | for (; /* MID ROWS */ | ||
234 | y_pos<y_ctr_stop; | ||
235 | y_pos+=y_step) | ||
236 | { | ||
237 | for (x_pos=x_start; | ||
238 | x_pos<x_ctr_start; | ||
239 | x_pos+=x_step, im_pos++) | ||
240 | INPROD2(y_pos, y_res, x_pos+x_dim, x_res%x_dim) | ||
241 | |||
242 | for (; /* CENTER SECTION */ | ||
243 | x_pos<x_ctr_stop; | ||
244 | x_pos+=x_step, im_pos++) | ||
245 | INPROD2(y_pos, y_res, x_pos, x_res) | ||
246 | |||
247 | for (; | ||
248 | x_pos<x_stop; | ||
249 | x_pos+=x_step, im_pos++) | ||
250 | INPROD2(y_pos, y_res, x_pos, x_res%x_dim) | ||
251 | } /* end MID ROWS */ | ||
252 | |||
253 | for (; /* BOTTOM ROWS */ | ||
254 | y_pos<y_stop; | ||
255 | y_pos+=y_step) | ||
256 | { | ||
257 | for (x_pos=x_start; | ||
258 | x_pos<x_ctr_start; | ||
259 | x_pos+=x_step, im_pos++) | ||
260 | INPROD2(y_pos, y_res%y_dim, x_pos+x_dim, x_res%x_dim) | ||
261 | |||
262 | for (; | ||
263 | x_pos<x_ctr_stop; | ||
264 | x_pos+=x_step, im_pos++) | ||
265 | INPROD2(y_pos, y_res%y_dim, x_pos, x_res) | ||
266 | |||
267 | for (; | ||
268 | x_pos<x_stop; | ||
269 | x_pos+=x_step, im_pos++) | ||
270 | INPROD2(y_pos, y_res%y_dim, x_pos, x_res%x_dim) | ||
271 | } /* end BOTTOM ROWS */ | ||
272 | |||
273 | free ((image_type **) imval); | ||
274 | return(0); | ||
275 | } /* end of internal_wrap_expand */ | ||
276 | |||
277 | |||
278 | |||
279 | /* Local Variables: */ | ||
280 | /* buffer-read-only: t */ | ||
281 | /* End: */ | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/README b/SD-VBS/benchmarks/texture_synthesis/src/matlab/README deleted file mode 100755 index 8f339f3..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/README +++ /dev/null | |||
@@ -1,55 +0,0 @@ | |||
1 | This package contains some MatLab tools for multi-scale image | ||
2 | processing. Briefly, the tools include: | ||
3 | - Recursive multi-scale image decompositions (pyramids), including | ||
4 | Laplacian pyramids, QMFs, Wavelets, and steerable pyramids. These | ||
5 | operate on 1D or 2D signals of arbitrary dimension. Data | ||
6 | structures are compatible with the MatLab wavelet toolbox. | ||
7 | - Fast 2D convolution routines, with subsampling and boundary-handling. | ||
8 | - Fast point-operations, histograms, histogram-matching. | ||
9 | - Fast synthetic image generation: sine gratings, zone plates, fractals, etc. | ||
10 | - Display routines for images and pyramids. These include several | ||
11 | auto-scaling options, rounding to integer zoom factors to avoid | ||
12 | resampling artifacts, and useful labeling (dimensions and gray-range). | ||
13 | |||
14 | The package is available as a gnu-zipped UNIX "tar" file, | ||
15 | accessible from the web page: | ||
16 | http://www.cns.nyu.edu/~lcv/software.html | ||
17 | |||
18 | The code works in Matlab versions 4.2 and higher, and has been fully tested | ||
19 | on Linux and Macintosh OSX platforms (it should, however, port easily to | ||
20 | others). To use the code (these lines are for UNIX): | ||
21 | 1) gunzip matlabPyrTools.tar.gz # unpack g'zipped file | ||
22 | 2) tar tvf matlabPyrTools.tar # view contents | ||
23 | 3) tar xvf matlabPyrTools.tar # extract contents | ||
24 | 4) rm matlabPyrTools.tar # delete tarfile | ||
25 | 5) Run matlab, and execute: | ||
26 | path(<pathname-of-matlabPyrTools>, path); | ||
27 | help matlabPyrTools | ||
28 | |||
29 | A few functions are actually MEX interfaces to C code. These are | ||
30 | contained in the subdirectory called MEX. The MEX files have been | ||
31 | tested on Sun (Solaris), LinuX on a Pentium platform, and Macintosh | ||
32 | OSX on a PowerPC, but should not be difficult to compile on most other | ||
33 | platforms. Source code is included in the MEX directory, as well as | ||
34 | Make files. I've included pre-compiled versions for a number of | ||
35 | platforms (Solaris,Linux,Mac,Windows). To make sure these are in your | ||
36 | matlab path, you can do *one* of the following: | ||
37 | 1) Create a symbolic link (or macintosh "alias") for the relavent files | ||
38 | in the main matlabPyrTools directory, or | ||
39 | 2) Copy the relavent files into the main matlabPyrTools directory, or | ||
40 | 3) Put the MEX subdirectory in your matlab path. | ||
41 | |||
42 | Some example script files showing usage of the code are in the | ||
43 | directory <dir>/TUTORIALS. There is a README file in that directory | ||
44 | describing the contents. | ||
45 | |||
46 | Incremental changes to the code are documented in the ChangeLog file. | ||
47 | |||
48 | Comments/Suggestions/Bugs to: | ||
49 | Eero P. Simoncelli | ||
50 | Associate Professor, | ||
51 | Center for Neural Science, and | ||
52 | Courant Institute for Mathematical Sciences | ||
53 | New York University | ||
54 | eero.simoncelli@nyu.edu | ||
55 | http://www.cns.nyu.edu/~eero/ | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/adjustCorr1s.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/adjustCorr1s.m deleted file mode 100755 index 81f428d..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/adjustCorr1s.m +++ /dev/null | |||
@@ -1,63 +0,0 @@ | |||
1 | % [newX, snr1, M] = adjustCorr1s(X, Cx, MODE, p) | ||
2 | % | ||
3 | % Linearly adjust variables in X to have correlation Cx. | ||
4 | % Rows of X and newX are samples of a (random) row-vector, such that: | ||
5 | % 1: newX = X * M | ||
6 | % 2: newX' * newX = Cx | ||
7 | % | ||
8 | % MODE is optional: | ||
9 | % 0 => choose randomly from the space of linear solutions | ||
10 | % 1 => simplest soln | ||
11 | % 2 => minimize angle change (DEFAULT) | ||
12 | % 3 => SVD minimal vector change soln | ||
13 | % | ||
14 | % p is optional: | ||
15 | % Imposes an intermediate value of correlation between the current one | ||
16 | % C and Cx: | ||
17 | % Cx' = (1-p)*C + p*Cx; | ||
18 | % DEFAULT is p=1. | ||
19 | |||
20 | % EPS, 11/23/97. | ||
21 | |||
22 | function [newX, snr1, M] = adjustCorr1s(X,Co,mode,p) | ||
23 | |||
24 | if (exist('mode') ~= 1) | ||
25 | mode = 2; | ||
26 | end | ||
27 | |||
28 | if (exist('p') ~= 1) | ||
29 | p = 1; | ||
30 | end | ||
31 | |||
32 | C = innerProd(X) / size(X,1); | ||
33 | [E, D] = eig(C); | ||
34 | D = diag(D); | ||
35 | [junk,Ind] = sort(D); | ||
36 | D = diag(sqrt(D(Ind(size(Ind,1):-1:1)))); | ||
37 | E = E(:,Ind(size(Ind,1):-1:1)); | ||
38 | |||
39 | Co0 = Co; | ||
40 | Co = (1-p)*C + p*Co; | ||
41 | |||
42 | [Eo,Do] = eig(Co); | ||
43 | Do = diag(Do); | ||
44 | [junk,Ind] = sort(Do); | ||
45 | Do = diag(sqrt(Do(Ind(size(Ind,1):-1:1)))); | ||
46 | Eo = Eo(:,Ind(size(Ind,1):-1:1)); | ||
47 | |||
48 | if (mode == 0) | ||
49 | Orth = orth(rand(size(C))); | ||
50 | elseif (mode == 1) % eye | ||
51 | Orth = eye(size(C)); | ||
52 | elseif (mode == 2) % simple | ||
53 | Orth = E' * Eo; | ||
54 | else % SVD | ||
55 | [U,S,V] = svd(D * E' * Eo * inv(Do)); | ||
56 | Orth = U * V'; | ||
57 | end | ||
58 | |||
59 | M = E * inv(D) * Orth * Do * Eo'; | ||
60 | |||
61 | newX = X * M; | ||
62 | |||
63 | snr1=10*log10(sum(sum(Co0.^2))/sum(sum((Co0-C).^2))); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/adjustCorr2s.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/adjustCorr2s.m deleted file mode 100755 index 3bd0c2e..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/adjustCorr2s.m +++ /dev/null | |||
@@ -1,99 +0,0 @@ | |||
1 | % [newX, snr1, snr2, Mx, My] = adjustCorr2s(X, Cx, Y, Cxy, MODE, p) | ||
2 | % | ||
3 | % Linearly adjust variables in X to have correlation Cx, and cross-correlation Cxy. | ||
4 | % Rows of X, Y, and newX are samples of (random) row-vectors, such that: | ||
5 | % 1: newX = X * Mx + Y * My | ||
6 | % 2: newX' * newX = Cx | ||
7 | % 3: newX' * Y = Cxy | ||
8 | % | ||
9 | % MODE is optional: | ||
10 | % 0 => choose randomly from the space of linear solutions | ||
11 | % 1 => simplest soln | ||
12 | % 2 => minimize angle change | ||
13 | % 3 => Simple rotational (DEFAULT) | ||
14 | % 4 => SVD minimal vector change soln | ||
15 | % | ||
16 | % p is optional: | ||
17 | % Imposes an intermediate value of correlation between the current ones | ||
18 | % Bx and Bxy and the specified Cx and Cxy: | ||
19 | % Cx' = (1-p)*Bx + p*Cx; | ||
20 | % Cxy' = (1-p)*Bxy + p*Cxy; | ||
21 | % DEFAULT is p=1. | ||
22 | |||
23 | |||
24 | % EPS, 11/25/97 | ||
25 | |||
26 | function [newX,snr1,snr2,Mx,My] = adjustCorr2s(X, Cx, Y, Cxy, mode, p) | ||
27 | |||
28 | Warn = 0; % Set to 1 if you want to display warning messages | ||
29 | if (exist('mode') ~= 1) | ||
30 | mode = 3; | ||
31 | end | ||
32 | if (exist('p') ~= 1) | ||
33 | p = 1; | ||
34 | end | ||
35 | |||
36 | Bx = innerProd(X) / size(X,1); | ||
37 | Bxy = (X' * Y) / size(X,1); | ||
38 | By = innerProd(Y) / size(X,1); | ||
39 | iBy = inv(By); | ||
40 | |||
41 | Current = Bx - (Bxy * iBy * Bxy'); | ||
42 | Cx0 = Cx; | ||
43 | Cx = (1-p)*Bx + p*Cx; | ||
44 | Cxy0 = Cxy; | ||
45 | Cxy = (1-p)*Bxy + p*Cxy; | ||
46 | Desired = Cx - (Cxy * iBy * Cxy'); | ||
47 | |||
48 | [E, D] = eig(Current); | ||
49 | D = diag(D); | ||
50 | if any(D < 0) & Warn | ||
51 | ind = find(D<0); | ||
52 | fprintf(1,'Warning: negative current eigenvalues: %d\n',D(ind)'); | ||
53 | end | ||
54 | [junk,Ind] = sort(D); | ||
55 | D = diag(sqrt(D(Ind(size(Ind,1):-1:1)))); | ||
56 | E = E(:,Ind(size(Ind,1):-1:1)); | ||
57 | |||
58 | [Eo,Do] = eig(Desired); | ||
59 | Do = diag(Do); | ||
60 | if any(Do < 0) & Warn | ||
61 | ind = find(Do<0); | ||
62 | fprintf(1,'Warning: negative desired eigenvalues: %d\n',Do(ind)'); | ||
63 | end | ||
64 | [junk,Ind] = sort(Do); | ||
65 | Do = diag(sqrt(Do(Ind(size(Ind,1):-1:1)))); | ||
66 | Eo = Eo(:,Ind(size(Ind,1):-1:1)); | ||
67 | |||
68 | if (mode == 0) | ||
69 | Orth = orth(rand(size(D))); | ||
70 | elseif (mode == 1) % eye | ||
71 | Orth = eye(size(D)); | ||
72 | elseif (mode == 2) % simple | ||
73 | A = [ eye(size(Cx)); -iBy*Bxy' ]; | ||
74 | Ao = [ eye(size(Cx)); -iBy*Cxy' ]; | ||
75 | [U,S,V] = svd(E' * pinv(A) * Ao * Eo); | ||
76 | Orth = U * V'; | ||
77 | elseif (mode == 3) | ||
78 | Orth = E' * Eo; | ||
79 | else % SVD | ||
80 | A = [ eye(size(Cx)); -iBy*Bxy' ]; | ||
81 | Ao = [ eye(size(Cx)); -iBy*Cxy' ]; | ||
82 | [U,S,V] = svd(D * E' * pinv(A) * Ao * Eo * inv(Do)); | ||
83 | Orth = U * V'; | ||
84 | end | ||
85 | |||
86 | Mx = E * inv(D) * Orth * Do * Eo'; | ||
87 | My = iBy * (Cxy' - Bxy' * Mx); | ||
88 | newX = X * Mx + Y * My; | ||
89 | |||
90 | if Cx0~=Bx, | ||
91 | snr1=10*log10(sum(sum(Cx0.^2))/sum(sum((Cx0-Bx).^2))); | ||
92 | else | ||
93 | snr1 = Inf; | ||
94 | end | ||
95 | if Cxy0~=Bxy, | ||
96 | snr2=10*log10(sum(sum(Cxy0.^2))/sum(sum((Cxy0-Bxy).^2))); | ||
97 | else | ||
98 | snr2 = Inf; | ||
99 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/binomialFilter.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/binomialFilter.m deleted file mode 100755 index e5670c7..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/binomialFilter.m +++ /dev/null | |||
@@ -1,18 +0,0 @@ | |||
1 | % KERNEL = binomialFilter(size) | ||
2 | % | ||
3 | % Returns a vector of binomial coefficients of order (size-1) . | ||
4 | |||
5 | % Eero Simoncelli, 2/97. | ||
6 | |||
7 | function [kernel] = binomialFilter(sz) | ||
8 | |||
9 | if (sz < 2) | ||
10 | error('size argument must be larger than 1'); | ||
11 | end | ||
12 | |||
13 | kernel = [0.5 0.5]'; | ||
14 | |||
15 | for n=1:sz-2 | ||
16 | kernel = conv([0.5 0.5]', kernel); | ||
17 | end | ||
18 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/blur.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/blur.m deleted file mode 100755 index f993d09..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/blur.m +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
1 | % RES = blur(IM, LEVELS, FILT) | ||
2 | % | ||
3 | % Blur an image, by filtering and downsampling LEVELS times | ||
4 | % (default=1), followed by upsampling and filtering LEVELS times. The | ||
5 | % blurring is done with filter kernel specified by FILT (default = | ||
6 | % 'binom5'), which can be a string (to be passed to namedFilter), a | ||
7 | % vector (applied separably as a 1D convolution kernel in X and Y), or | ||
8 | % a matrix (applied as a 2D convolution kernel). The downsampling is | ||
9 | % always by 2 in each direction. | ||
10 | |||
11 | % Eero Simoncelli, 3/04. | ||
12 | |||
13 | function res = blur(im, nlevs, filt) | ||
14 | |||
15 | %------------------------------------------------------------ | ||
16 | %% OPTIONAL ARGS: | ||
17 | |||
18 | if (exist('nlevs') ~= 1) | ||
19 | nlevs = 1; | ||
20 | end | ||
21 | |||
22 | if (exist('filt') ~= 1) | ||
23 | filt = 'binom5'; | ||
24 | end | ||
25 | |||
26 | %------------------------------------------------------------ | ||
27 | |||
28 | res = upBlur(blurDn(im,nlevs,filt)); \ No newline at end of file | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/blurDn.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/blurDn.m deleted file mode 100755 index 8120c04..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/blurDn.m +++ /dev/null | |||
@@ -1,59 +0,0 @@ | |||
1 | % RES = blurDn(IM, LEVELS, FILT) | ||
2 | % | ||
3 | % Blur and downsample an image. The blurring is done with filter | ||
4 | % kernel specified by FILT (default = 'binom5'), which can be a string | ||
5 | % (to be passed to namedFilter), a vector (applied separably as a 1D | ||
6 | % convolution kernel in X and Y), or a matrix (applied as a 2D | ||
7 | % convolution kernel). The downsampling is always by 2 in each | ||
8 | % direction. | ||
9 | % | ||
10 | % The procedure is applied recursively LEVELS times (default=1). | ||
11 | |||
12 | % Eero Simoncelli, 3/97. | ||
13 | |||
14 | function res = blurDn(im, nlevs, filt) | ||
15 | |||
16 | %------------------------------------------------------------ | ||
17 | %% OPTIONAL ARGS: | ||
18 | |||
19 | if (exist('nlevs') ~= 1) | ||
20 | nlevs = 1; | ||
21 | end | ||
22 | |||
23 | if (exist('filt') ~= 1) | ||
24 | filt = 'binom5'; | ||
25 | end | ||
26 | |||
27 | %------------------------------------------------------------ | ||
28 | |||
29 | if isstr(filt) | ||
30 | filt = namedFilter(filt); | ||
31 | end | ||
32 | |||
33 | filt = filt/sum(filt(:)); | ||
34 | |||
35 | if nlevs > 1 | ||
36 | im = blurDn(im,nlevs-1,filt); | ||
37 | end | ||
38 | |||
39 | if (nlevs >= 1) | ||
40 | if (any(size(im)==1)) | ||
41 | if (~any(size(filt)==1)) | ||
42 | error('Cant apply 2D filter to 1D signal'); | ||
43 | end | ||
44 | if (size(im,2)==1) | ||
45 | filt = filt(:); | ||
46 | else | ||
47 | filt = filt(:)'; | ||
48 | end | ||
49 | res = corrDn(im,filt,'reflect1',(size(im)~=1)+1); | ||
50 | elseif (any(size(filt)==1)) | ||
51 | filt = filt(:); | ||
52 | res = corrDn(im,filt,'reflect1',[2 1]); | ||
53 | res = corrDn(res,filt','reflect1',[1 2]); | ||
54 | else | ||
55 | res = corrDn(im,filt,'reflect1',[2 2]); | ||
56 | end | ||
57 | else | ||
58 | res = im; | ||
59 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/buildGpyr.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/buildGpyr.m deleted file mode 100755 index 3f3d07b..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/buildGpyr.m +++ /dev/null | |||
@@ -1,82 +0,0 @@ | |||
1 | % [PYR, INDICES] = buildGpyr(IM, HEIGHT, FILT, EDGES) | ||
2 | % | ||
3 | % Construct a Gaussian pyramid on matrix IM. | ||
4 | % | ||
5 | % HEIGHT (optional) specifies the number of pyramid levels to build. Default | ||
6 | % is 1+maxPyrHt(size(IM),size(FILT)). | ||
7 | % You can also specify 'auto' to use this value. | ||
8 | % | ||
9 | % FILT (optional) can be a string naming a standard filter (see | ||
10 | % namedFilter), or a vector which will be used for (separable) | ||
11 | % convolution. Default = 'binom5'. EDGES specifies edge-handling, and | ||
12 | % defaults to 'reflect1' (see corrDn). | ||
13 | % | ||
14 | % PYR is a vector containing the N pyramid subbands, ordered from fine | ||
15 | % to coarse. INDICES is an Nx2 matrix containing the sizes of | ||
16 | % each subband. This is compatible with the MatLab Wavelet toolbox. | ||
17 | |||
18 | % Eero Simoncelli, 6/96. | ||
19 | |||
20 | function [pyr,pind] = buildGpyr(im, ht, filt, edges) | ||
21 | |||
22 | if (nargin < 1) | ||
23 | error('First argument (IM) is required'); | ||
24 | end | ||
25 | |||
26 | im_sz = size(im); | ||
27 | |||
28 | %------------------------------------------------------------ | ||
29 | %% OPTIONAL ARGS: | ||
30 | |||
31 | if (exist('filt') ~= 1) | ||
32 | filt = 'binom5'; | ||
33 | end | ||
34 | |||
35 | if isstr(filt) | ||
36 | filt = namedFilter(filt); | ||
37 | end | ||
38 | |||
39 | if ( (size(filt,1) > 1) & (size(filt,2) > 1) ) | ||
40 | error('FILT should be a 1D filter (i.e., a vector)'); | ||
41 | else | ||
42 | filt = filt(:); | ||
43 | end | ||
44 | |||
45 | max_ht = 1 + maxPyrHt(im_sz, size(filt,1)); | ||
46 | if ( (exist('ht') ~= 1) | (ht == 'auto') ) | ||
47 | ht = max_ht; | ||
48 | else | ||
49 | if (ht > max_ht) | ||
50 | error(sprintf('Cannot build pyramid higher than %d levels.',max_ht)); | ||
51 | end | ||
52 | end | ||
53 | |||
54 | if (exist('edges') ~= 1) | ||
55 | edges= 'reflect1'; | ||
56 | end | ||
57 | |||
58 | %------------------------------------------------------------ | ||
59 | |||
60 | if (ht <= 1) | ||
61 | |||
62 | pyr = im(:); | ||
63 | pind = im_sz; | ||
64 | |||
65 | else | ||
66 | |||
67 | if (im_sz(2) == 1) | ||
68 | lo2 = corrDn(im, filt, edges, [2 1], [1 1]); | ||
69 | elseif (im_sz(1) == 1) | ||
70 | lo2 = corrDn(im, filt', edges, [1 2], [1 1]); | ||
71 | else | ||
72 | lo = corrDn(im, filt', edges, [1 2], [1 1]); | ||
73 | lo2 = corrDn(lo, filt, edges, [2 1], [1 1]); | ||
74 | end | ||
75 | |||
76 | [npyr,nind] = buildGpyr(lo2, ht-1, filt, edges); | ||
77 | |||
78 | pyr = [im(:); npyr]; | ||
79 | pind = [im_sz; nind]; | ||
80 | |||
81 | end | ||
82 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/buildLpyr.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/buildLpyr.m deleted file mode 100755 index facb0f3..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/buildLpyr.m +++ /dev/null | |||
@@ -1,109 +0,0 @@ | |||
1 | % [PYR, INDICES] = buildLpyr(IM, HEIGHT, FILT1, FILT2, EDGES) | ||
2 | % | ||
3 | % Construct a Laplacian pyramid on matrix (or vector) IM. | ||
4 | % | ||
5 | % HEIGHT (optional) specifies the number of pyramid levels to build. Default | ||
6 | % is 1+maxPyrHt(size(IM),size(FILT)). You can also specify 'auto' to | ||
7 | % use this value. | ||
8 | % | ||
9 | % FILT1 (optional) can be a string naming a standard filter (see | ||
10 | % namedFilter), or a vector which will be used for (separable) | ||
11 | % convolution. Default = 'binom5'. FILT2 specifies the "expansion" | ||
12 | % filter (default = filt1). EDGES specifies edge-handling, and | ||
13 | % defaults to 'reflect1' (see corrDn). | ||
14 | % | ||
15 | % PYR is a vector containing the N pyramid subbands, ordered from fine | ||
16 | % to coarse. INDICES is an Nx2 matrix containing the sizes of | ||
17 | % each subband. This is compatible with the MatLab Wavelet toolbox. | ||
18 | |||
19 | % Eero Simoncelli, 6/96. | ||
20 | |||
21 | function [pyr,pind] = buildLpyr(im, ht, filt1, filt2, edges) | ||
22 | |||
23 | if (nargin < 1) | ||
24 | error('First argument (IM) is required'); | ||
25 | end | ||
26 | |||
27 | im_sz = size(im); | ||
28 | |||
29 | %------------------------------------------------------------ | ||
30 | %% OPTIONAL ARGS: | ||
31 | |||
32 | if (exist('filt1') ~= 1) | ||
33 | filt1 = 'binom5'; | ||
34 | end | ||
35 | |||
36 | if isstr(filt1) | ||
37 | filt1 = namedFilter(filt1); | ||
38 | end | ||
39 | |||
40 | if ( (size(filt1,1) > 1) & (size(filt1,2) > 1) ) | ||
41 | error('FILT1 should be a 1D filter (i.e., a vector)'); | ||
42 | else | ||
43 | filt1 = filt1(:); | ||
44 | end | ||
45 | |||
46 | if (exist('filt2') ~= 1) | ||
47 | filt2 = filt1; | ||
48 | end | ||
49 | |||
50 | if isstr(filt2) | ||
51 | filt2 = namedFilter(filt2); | ||
52 | end | ||
53 | |||
54 | if ( (size(filt2,1) > 1) & (size(filt2,2) > 1) ) | ||
55 | error('FILT2 should be a 1D filter (i.e., a vector)'); | ||
56 | else | ||
57 | filt2 = filt2(:); | ||
58 | end | ||
59 | |||
60 | max_ht = 1 + maxPyrHt(im_sz, max(size(filt1,1), size(filt2,1))); | ||
61 | if ( (exist('ht') ~= 1) | (ht == 'auto') ) | ||
62 | ht = max_ht; | ||
63 | else | ||
64 | if (ht > max_ht) | ||
65 | error(sprintf('Cannot build pyramid higher than %d levels.',max_ht)); | ||
66 | end | ||
67 | end | ||
68 | |||
69 | if (exist('edges') ~= 1) | ||
70 | edges= 'reflect1'; | ||
71 | end | ||
72 | |||
73 | %------------------------------------------------------------ | ||
74 | |||
75 | if (ht <= 1) | ||
76 | |||
77 | pyr = im(:); | ||
78 | pind = im_sz; | ||
79 | |||
80 | else | ||
81 | |||
82 | if (im_sz(2) == 1) | ||
83 | lo2 = corrDn(im, filt1, edges, [2 1], [1 1]); | ||
84 | elseif (im_sz(1) == 1) | ||
85 | lo2 = corrDn(im, filt1', edges, [1 2], [1 1]); | ||
86 | else | ||
87 | lo = corrDn(im, filt1', edges, [1 2], [1 1]); | ||
88 | int_sz = size(lo); | ||
89 | lo2 = corrDn(lo, filt1, edges, [2 1], [1 1]); | ||
90 | end | ||
91 | |||
92 | [npyr,nind] = buildLpyr(lo2, ht-1, filt1, filt2, edges); | ||
93 | |||
94 | if (im_sz(1) == 1) | ||
95 | hi2 = upConv(lo2, filt2', edges, [1 2], [1 1], im_sz); | ||
96 | elseif (im_sz(2) == 1) | ||
97 | hi2 = upConv(lo2, filt2, edges, [2 1], [1 1], im_sz); | ||
98 | else | ||
99 | hi = upConv(lo2, filt2, edges, [2 1], [1 1], int_sz); | ||
100 | hi2 = upConv(hi, filt2', edges, [1 2], [1 1], im_sz); | ||
101 | end | ||
102 | |||
103 | hi2 = im - hi2; | ||
104 | |||
105 | pyr = [hi2(:); npyr]; | ||
106 | pind = [im_sz; nind]; | ||
107 | |||
108 | end | ||
109 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/buildSCFpyr.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/buildSCFpyr.m deleted file mode 100755 index 101b6d2..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/buildSCFpyr.m +++ /dev/null | |||
@@ -1,90 +0,0 @@ | |||
1 | % [PYR, INDICES, STEERMTX, HARMONICS] = buildSCFpyr(IM, HEIGHT, ORDER, TWIDTH) | ||
2 | % | ||
3 | % This is a modified version of buildSFpyr, that constructs a | ||
4 | % complex-valued steerable pyramid using Hilbert-transform pairs | ||
5 | % of filters. Note that the imaginary parts will *not* be steerable. | ||
6 | % | ||
7 | % To reconstruct from this representation, either call reconSFpyr | ||
8 | % on the real part of the pyramid, *or* call reconSCFpyr which will | ||
9 | % use both real and imaginary parts (forcing analyticity). | ||
10 | % | ||
11 | % Description of this transform appears in: Portilla & Simoncelli, | ||
12 | % Int'l Journal of Computer Vision, 40(1):49-71, Oct 2000. | ||
13 | % Further information: http://www.cns.nyu.edu/~eero/STEERPYR/ | ||
14 | |||
15 | % Original code: Eero Simoncelli, 5/97. | ||
16 | % Modified by Javier Portilla to return complex (quadrature pair) channels, | ||
17 | % 9/97. | ||
18 | |||
19 | function [pyr,pind,steermtx,harmonics] = buildSCFpyr(im, ht, order, twidth) | ||
20 | |||
21 | %----------------------------------------------------------------- | ||
22 | %% DEFAULTS: | ||
23 | |||
24 | max_ht = floor(log2(min(size(im)))) - 2; | ||
25 | |||
26 | if (exist('ht') ~= 1) | ||
27 | ht = max_ht; | ||
28 | else | ||
29 | if (ht > max_ht) | ||
30 | error(sprintf('Cannot build pyramid higher than %d levels.',max_ht)); | ||
31 | end | ||
32 | end | ||
33 | |||
34 | if (exist('order') ~= 1) | ||
35 | order = 3; | ||
36 | elseif ((order > 15) | (order < 0)) | ||
37 | fprintf(1,'Warning: ORDER must be an integer in the range [0,15]. Truncating.\n'); | ||
38 | order = min(max(order,0),15); | ||
39 | else | ||
40 | order = round(order); | ||
41 | end | ||
42 | nbands = order+1; | ||
43 | |||
44 | if (exist('twidth') ~= 1) | ||
45 | twidth = 1; | ||
46 | elseif (twidth <= 0) | ||
47 | fprintf(1,'Warning: TWIDTH must be positive. Setting to 1.\n'); | ||
48 | twidth = 1; | ||
49 | end | ||
50 | |||
51 | %----------------------------------------------------------------- | ||
52 | %% Steering stuff: | ||
53 | |||
54 | if (mod((nbands),2) == 0) | ||
55 | harmonics = [0:(nbands/2)-1]'*2 + 1; | ||
56 | else | ||
57 | harmonics = [0:(nbands-1)/2]'*2; | ||
58 | end | ||
59 | |||
60 | steermtx = steer2HarmMtx(harmonics, pi*[0:nbands-1]/nbands, 'even'); | ||
61 | |||
62 | %----------------------------------------------------------------- | ||
63 | |||
64 | dims = size(im); | ||
65 | ctr = ceil((dims+0.5)/2); | ||
66 | |||
67 | [xramp,yramp] = meshgrid( ([1:dims(2)]-ctr(2))./(dims(2)/2), ... | ||
68 | ([1:dims(1)]-ctr(1))./(dims(1)/2) ); | ||
69 | angle = atan2(yramp,xramp); | ||
70 | log_rad = sqrt(xramp.^2 + yramp.^2); | ||
71 | log_rad(ctr(1),ctr(2)) = log_rad(ctr(1),ctr(2)-1); | ||
72 | log_rad = log2(log_rad); | ||
73 | |||
74 | %% Radial transition function (a raised cosine in log-frequency): | ||
75 | [Xrcos,Yrcos] = rcosFn(twidth,(-twidth/2),[0 1]); | ||
76 | Yrcos = sqrt(Yrcos); | ||
77 | |||
78 | YIrcos = sqrt(1.0 - Yrcos.^2); | ||
79 | lo0mask = pointOp(log_rad, YIrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); | ||
80 | imdft = fftshift(fft2(im)); | ||
81 | lo0dft = imdft .* lo0mask; | ||
82 | |||
83 | [pyr,pind] = buildSCFpyrLevs(lo0dft, log_rad, Xrcos, Yrcos, angle, ht, nbands); | ||
84 | |||
85 | hi0mask = pointOp(log_rad, Yrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); | ||
86 | hi0dft = imdft .* hi0mask; | ||
87 | hi0 = ifft2(ifftshift(hi0dft)); | ||
88 | |||
89 | pyr = [real(hi0(:)) ; pyr]; | ||
90 | pind = [size(hi0); pind]; | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/buildSCFpyrLevs.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/buildSCFpyrLevs.m deleted file mode 100755 index bd75695..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/buildSCFpyrLevs.m +++ /dev/null | |||
@@ -1,73 +0,0 @@ | |||
1 | % [PYR, INDICES] = buildSCFpyrLevs(LODFT, LOGRAD, XRCOS, YRCOS, ANGLE, HEIGHT, NBANDS) | ||
2 | % | ||
3 | % Recursive function for constructing levels of a steerable pyramid. This | ||
4 | % is called by buildSCFpyr, and is not usually called directly. | ||
5 | |||
6 | % Original code: Eero Simoncelli, 5/97. | ||
7 | % Modified by Javier Portilla to generate complex bands in 9/97. | ||
8 | |||
9 | function [pyr,pind] = buildSCFpyrLevs(lodft,log_rad,Xrcos,Yrcos,angle,ht,nbands); | ||
10 | |||
11 | if (ht <= 0) | ||
12 | |||
13 | lo0 = ifft2(ifftshift(lodft)); | ||
14 | pyr = real(lo0(:)); | ||
15 | pind = size(lo0); | ||
16 | |||
17 | else | ||
18 | |||
19 | bands = zeros(prod(size(lodft)), nbands); | ||
20 | bind = zeros(nbands,2); | ||
21 | |||
22 | % log_rad = log_rad + 1; | ||
23 | Xrcos = Xrcos - log2(2); % shift origin of lut by 1 octave. | ||
24 | |||
25 | lutsize = 1024; | ||
26 | Xcosn = pi*[-(2*lutsize+1):(lutsize+1)]/lutsize; % [-2*pi:pi] | ||
27 | order = nbands-1; | ||
28 | %% divide by sqrt(sum_(n=0)^(N-1) cos(pi*n/N)^(2(N-1)) ) | ||
29 | %% Thanks to Patrick Teo for writing this out :) | ||
30 | const = (2^(2*order))*(factorial(order)^2)/(nbands*factorial(2*order)); | ||
31 | |||
32 | % | ||
33 | % Ycosn = sqrt(const) * (cos(Xcosn)).^order; | ||
34 | % | ||
35 | % analityc version: only take one lobe | ||
36 | alfa= mod(pi+Xcosn,2*pi)-pi; | ||
37 | Ycosn = 2*sqrt(const) * (cos(Xcosn).^order) .* (abs(alfa)<pi/2); | ||
38 | |||
39 | himask = pointOp(log_rad, Yrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); | ||
40 | |||
41 | for b = 1:nbands | ||
42 | anglemask = pointOp(angle, Ycosn, Xcosn(1)+pi*(b-1)/nbands, Xcosn(2)-Xcosn(1)); | ||
43 | banddft = ((-i)^(nbands-1)) .* lodft .* anglemask .* himask; | ||
44 | band = ifft2(ifftshift(banddft)); | ||
45 | |||
46 | % bands(:,b) = real(band(:)); | ||
47 | % analytic version: full complex value | ||
48 | bands(:,b)=band(:); | ||
49 | bind(b,:) = size(band); | ||
50 | end | ||
51 | |||
52 | dims = size(lodft); | ||
53 | ctr = ceil((dims+0.5)/2); | ||
54 | lodims = ceil((dims-0.5)/2); | ||
55 | loctr = ceil((lodims+0.5)/2); | ||
56 | lostart = ctr-loctr+1; | ||
57 | loend = lostart+lodims-1; | ||
58 | |||
59 | log_rad = log_rad(lostart(1):loend(1),lostart(2):loend(2)); | ||
60 | angle = angle(lostart(1):loend(1),lostart(2):loend(2)); | ||
61 | lodft = lodft(lostart(1):loend(1),lostart(2):loend(2)); | ||
62 | YIrcos = abs(sqrt(1.0 - Yrcos.^2)); | ||
63 | lomask = pointOp(log_rad, YIrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); | ||
64 | |||
65 | lodft = lomask .* lodft; | ||
66 | |||
67 | [npyr,nind] = buildSCFpyrLevs(lodft, log_rad, Xrcos, Yrcos, angle, ht-1, nbands); | ||
68 | |||
69 | pyr = [bands(:); npyr]; | ||
70 | pind = [bind; nind]; | ||
71 | |||
72 | end | ||
73 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/buildSFpyr.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/buildSFpyr.m deleted file mode 100755 index ae67206..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/buildSFpyr.m +++ /dev/null | |||
@@ -1,102 +0,0 @@ | |||
1 | % [PYR, INDICES, STEERMTX, HARMONICS] = buildSFpyr(IM, HEIGHT, ORDER, TWIDTH) | ||
2 | % | ||
3 | % Construct a steerable pyramid on matrix IM, in the Fourier domain. | ||
4 | % This is similar to buildSpyr, except that: | ||
5 | % | ||
6 | % + Reconstruction is exact (within floating point errors) | ||
7 | % + It can produce any number of orientation bands. | ||
8 | % - Typically slower, especially for non-power-of-two sizes. | ||
9 | % - Boundary-handling is circular. | ||
10 | % | ||
11 | % HEIGHT (optional) specifies the number of pyramid levels to build. Default | ||
12 | % is maxPyrHt(size(IM),size(FILT)); | ||
13 | % | ||
14 | % The squared radial functions tile the Fourier plane, with a raised-cosine | ||
15 | % falloff. Angular functions are cos(theta-k\pi/(K+1))^K, where K is | ||
16 | % the ORDER (one less than the number of orientation bands, default= 3). | ||
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 | % PYR is a vector containing the N pyramid subbands, ordered from fine | ||
23 | % to coarse. INDICES is an Nx2 matrix containing the sizes of | ||
24 | % each subband. This is compatible with the MatLab Wavelet toolbox. | ||
25 | % See the function STEER for a description of STEERMTX and HARMONICS. | ||
26 | |||
27 | % Eero Simoncelli, 5/97. | ||
28 | % See http://www.cns.nyu.edu/~eero/STEERPYR/ for more | ||
29 | % information about the Steerable Pyramid image decomposition. | ||
30 | |||
31 | function [pyr,pind,steermtx,harmonics] = buildSFpyr(im, ht, order, twidth) | ||
32 | |||
33 | %----------------------------------------------------------------- | ||
34 | %% DEFAULTS: | ||
35 | |||
36 | max_ht = floor(log2(min(size(im)))) - 2; | ||
37 | |||
38 | if (exist('ht') ~= 1) | ||
39 | ht = max_ht; | ||
40 | else | ||
41 | if (ht > max_ht) | ||
42 | error(sprintf('Cannot build pyramid higher than %d levels.',max_ht)); | ||
43 | end | ||
44 | end | ||
45 | |||
46 | if (exist('order') ~= 1) | ||
47 | order = 3; | ||
48 | elseif ((order > 15) | (order < 0)) | ||
49 | fprintf(1,'Warning: ORDER must be an integer in the range [0,15]. Truncating.\n'); | ||
50 | order = min(max(order,0),15); | ||
51 | else | ||
52 | order = round(order); | ||
53 | end | ||
54 | nbands = order+1; | ||
55 | |||
56 | if (exist('twidth') ~= 1) | ||
57 | twidth = 1; | ||
58 | elseif (twidth <= 0) | ||
59 | fprintf(1,'Warning: TWIDTH must be positive. Setting to 1.\n'); | ||
60 | twidth = 1; | ||
61 | end | ||
62 | |||
63 | %----------------------------------------------------------------- | ||
64 | %% Steering stuff: | ||
65 | |||
66 | if (mod((nbands),2) == 0) | ||
67 | harmonics = [0:(nbands/2)-1]'*2 + 1; | ||
68 | else | ||
69 | harmonics = [0:(nbands-1)/2]'*2; | ||
70 | end | ||
71 | |||
72 | steermtx = steer2HarmMtx(harmonics, pi*[0:nbands-1]/nbands, 'even'); | ||
73 | |||
74 | %----------------------------------------------------------------- | ||
75 | |||
76 | dims = size(im); | ||
77 | ctr = ceil((dims+0.5)/2); | ||
78 | |||
79 | [xramp,yramp] = meshgrid( ([1:dims(2)]-ctr(2))./(dims(2)/2), ... | ||
80 | ([1:dims(1)]-ctr(1))./(dims(1)/2) ); | ||
81 | angle = atan2(yramp,xramp); | ||
82 | log_rad = sqrt(xramp.^2 + yramp.^2); | ||
83 | log_rad(ctr(1),ctr(2)) = log_rad(ctr(1),ctr(2)-1); | ||
84 | log_rad = log2(log_rad); | ||
85 | |||
86 | %% Radial transition function (a raised cosine in log-frequency): | ||
87 | [Xrcos,Yrcos] = rcosFn(twidth,(-twidth/2),[0 1]); | ||
88 | Yrcos = sqrt(Yrcos); | ||
89 | |||
90 | YIrcos = sqrt(1.0 - Yrcos.^2); | ||
91 | lo0mask = pointOp(log_rad, YIrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); | ||
92 | imdft = fftshift(fft2(im)); | ||
93 | lo0dft = imdft .* lo0mask; | ||
94 | |||
95 | [pyr,pind] = buildSFpyrLevs(lo0dft, log_rad, Xrcos, Yrcos, angle, ht, nbands); | ||
96 | |||
97 | hi0mask = pointOp(log_rad, Yrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); | ||
98 | hi0dft = imdft .* hi0mask; | ||
99 | hi0 = ifft2(ifftshift(hi0dft)); | ||
100 | |||
101 | pyr = [real(hi0(:)) ; pyr]; | ||
102 | pind = [size(hi0); pind]; | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/buildSFpyrLevs.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/buildSFpyrLevs.m deleted file mode 100755 index 472d861..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/buildSFpyrLevs.m +++ /dev/null | |||
@@ -1,63 +0,0 @@ | |||
1 | % [PYR, INDICES] = buildSFpyrLevs(LODFT, LOGRAD, XRCOS, YRCOS, ANGLE, HEIGHT, NBANDS) | ||
2 | % | ||
3 | % Recursive function for constructing levels of a steerable pyramid. This | ||
4 | % is called by buildSFpyr, and is not usually called directly. | ||
5 | |||
6 | % Eero Simoncelli, 5/97. | ||
7 | |||
8 | function [pyr,pind] = buildSFpyrLevs(lodft,log_rad,Xrcos,Yrcos,angle,ht,nbands); | ||
9 | |||
10 | if (ht <= 0) | ||
11 | |||
12 | lo0 = ifft2(ifftshift(lodft)); | ||
13 | pyr = real(lo0(:)); | ||
14 | pind = size(lo0); | ||
15 | |||
16 | else | ||
17 | |||
18 | bands = zeros(prod(size(lodft)), nbands); | ||
19 | bind = zeros(nbands,2); | ||
20 | |||
21 | % log_rad = log_rad + 1; | ||
22 | Xrcos = Xrcos - log2(2); % shift origin of lut by 1 octave. | ||
23 | |||
24 | lutsize = 1024; | ||
25 | Xcosn = pi*[-(2*lutsize+1):(lutsize+1)]/lutsize; % [-2*pi:pi] | ||
26 | order = nbands-1; | ||
27 | %% divide by sqrt(sum_(n=0)^(N-1) cos(pi*n/N)^(2(N-1)) ) | ||
28 | %% Thanks to Patrick Teo for writing this out :) | ||
29 | const = (2^(2*order))*(factorial(order)^2)/(nbands*factorial(2*order)); | ||
30 | Ycosn = sqrt(const) * (cos(Xcosn)).^order; | ||
31 | himask = pointOp(log_rad, Yrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); | ||
32 | |||
33 | for b = 1:nbands | ||
34 | anglemask = pointOp(angle, Ycosn, Xcosn(1)+pi*(b-1)/nbands, Xcosn(2)-Xcosn(1)); | ||
35 | banddft = ((-sqrt(-1))^(nbands-1)) .* lodft .* anglemask .* himask; | ||
36 | band = ifft2(ifftshift(banddft)); | ||
37 | |||
38 | bands(:,b) = real(band(:)); | ||
39 | bind(b,:) = size(band); | ||
40 | end | ||
41 | |||
42 | dims = size(lodft); | ||
43 | ctr = ceil((dims+0.5)/2); | ||
44 | lodims = ceil((dims-0.5)/2); | ||
45 | loctr = ceil((lodims+0.5)/2); | ||
46 | lostart = ctr-loctr+1; | ||
47 | loend = lostart+lodims-1; | ||
48 | |||
49 | log_rad = log_rad(lostart(1):loend(1),lostart(2):loend(2)); | ||
50 | angle = angle(lostart(1):loend(1),lostart(2):loend(2)); | ||
51 | lodft = lodft(lostart(1):loend(1),lostart(2):loend(2)); | ||
52 | YIrcos = abs(sqrt(1.0 - Yrcos.^2)); | ||
53 | lomask = pointOp(log_rad, YIrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); | ||
54 | |||
55 | lodft = lomask .* lodft; | ||
56 | |||
57 | [npyr,nind] = buildSFpyrLevs(lodft, log_rad, Xrcos, Yrcos, angle, ht-1, nbands); | ||
58 | |||
59 | pyr = [bands(:); npyr]; | ||
60 | pind = [bind; nind]; | ||
61 | |||
62 | end | ||
63 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/buildSpyr.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/buildSpyr.m deleted file mode 100755 index b2bead6..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/buildSpyr.m +++ /dev/null | |||
@@ -1,61 +0,0 @@ | |||
1 | % [PYR, INDICES, STEERMTX, HARMONICS] = buildSpyr(IM, HEIGHT, FILTFILE, EDGES) | ||
2 | % | ||
3 | % Construct a steerable pyramid on matrix IM. | ||
4 | % | ||
5 | % HEIGHT (optional) specifies the number of pyramid levels to build. Default | ||
6 | % is maxPyrHt(size(IM),size(FILT)). | ||
7 | % You can also specify 'auto' to use this value. | ||
8 | % | ||
9 | % FILTFILE (optional) should be a string referring to an m-file that | ||
10 | % returns the rfilters. (examples: 'sp0Filters', 'sp1Filters', | ||
11 | % 'sp3Filters','sp5Filters'. default = 'sp1Filters'). EDGES specifies | ||
12 | % edge-handling, and defaults to 'reflect1' (see corrDn). | ||
13 | % | ||
14 | % PYR is a vector containing the N pyramid subbands, ordered from fine | ||
15 | % to coarse. INDICES is an Nx2 matrix containing the sizes of | ||
16 | % each subband. This is compatible with the MatLab Wavelet toolbox. | ||
17 | % See the function STEER for a description of STEERMTX and HARMONICS. | ||
18 | |||
19 | % Eero Simoncelli, 6/96. | ||
20 | % See http://www.cis.upenn.edu/~eero/steerpyr.html for more | ||
21 | % information about the Steerable Pyramid image decomposition. | ||
22 | |||
23 | function [pyr,pind,steermtx,harmonics] = buildSpyr(im, ht, filtfile, edges) | ||
24 | |||
25 | %----------------------------------------------------------------- | ||
26 | %% DEFAULTS: | ||
27 | |||
28 | if (exist('filtfile') ~= 1) | ||
29 | filtfile = 'sp1Filters'; | ||
30 | end | ||
31 | |||
32 | if (exist('edges') ~= 1) | ||
33 | edges= 'reflect1'; | ||
34 | end | ||
35 | |||
36 | if (isstr(filtfile) & (exist(filtfile) == 2)) | ||
37 | [lo0filt,hi0filt,lofilt,bfilts,steermtx,harmonics] = eval(filtfile); | ||
38 | else | ||
39 | fprintf(1,'\nUse buildSFpyr for pyramids with arbitrary numbers of orientation bands.\n'); | ||
40 | error('FILTFILE argument must be the name of an M-file containing SPYR filters.'); | ||
41 | end | ||
42 | |||
43 | max_ht = maxPyrHt(size(im), size(lofilt,1)); | ||
44 | if ( (exist('ht') ~= 1) | (ht == 'auto') ) | ||
45 | ht = max_ht; | ||
46 | else | ||
47 | if (ht > max_ht) | ||
48 | error(sprintf('Cannot build pyramid higher than %d levels.',max_ht)); | ||
49 | end | ||
50 | end | ||
51 | |||
52 | %----------------------------------------------------------------- | ||
53 | |||
54 | hi0 = corrDn(im, hi0filt, edges); | ||
55 | lo0 = corrDn(im, lo0filt, edges); | ||
56 | |||
57 | [pyr,pind] = buildSpyrLevs(lo0, ht, lofilt, bfilts, edges); | ||
58 | |||
59 | pyr = [hi0(:) ; pyr]; | ||
60 | pind = [size(hi0); pind]; | ||
61 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/buildSpyrLevs.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/buildSpyrLevs.m deleted file mode 100755 index 4c00077..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/buildSpyrLevs.m +++ /dev/null | |||
@@ -1,37 +0,0 @@ | |||
1 | % [PYR, INDICES] = buildSpyrLevs(LOIM, HEIGHT, LOFILT, BFILTS, EDGES) | ||
2 | % | ||
3 | % Recursive function for constructing levels of a steerable pyramid. This | ||
4 | % is called by buildSpyr, and is not usually called directly. | ||
5 | |||
6 | % Eero Simoncelli, 6/96. | ||
7 | |||
8 | function [pyr,pind] = buildSpyrLevs(lo0,ht,lofilt,bfilts,edges); | ||
9 | |||
10 | if (ht <= 0) | ||
11 | |||
12 | pyr = lo0(:); | ||
13 | pind = size(lo0); | ||
14 | |||
15 | else | ||
16 | |||
17 | % Assume square filters: | ||
18 | bfiltsz = round(sqrt(size(bfilts,1))); | ||
19 | |||
20 | bands = zeros(prod(size(lo0)),size(bfilts,2)); | ||
21 | bind = zeros(size(bfilts,2),2); | ||
22 | |||
23 | for b = 1:size(bfilts,2) | ||
24 | filt = reshape(bfilts(:,b),bfiltsz,bfiltsz); | ||
25 | band = corrDn(lo0, filt, edges); | ||
26 | bands(:,b) = band(:); | ||
27 | bind(b,:) = size(band); | ||
28 | end | ||
29 | |||
30 | lo = corrDn(lo0, lofilt, edges, [2 2], [1 1]); | ||
31 | |||
32 | [npyr,nind] = buildSpyrLevs(lo, ht-1, lofilt, bfilts, edges); | ||
33 | |||
34 | pyr = [bands(:); npyr]; | ||
35 | pind = [bind; nind]; | ||
36 | |||
37 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/buildWpyr.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/buildWpyr.m deleted file mode 100755 index 22ae32f..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/buildWpyr.m +++ /dev/null | |||
@@ -1,100 +0,0 @@ | |||
1 | % [PYR, INDICES] = buildWpyr(IM, HEIGHT, FILT, EDGES) | ||
2 | % | ||
3 | % Construct a separable orthonormal QMF/wavelet pyramid on matrix (or vector) IM. | ||
4 | % | ||
5 | % HEIGHT (optional) specifies the number of pyramid levels to build. Default | ||
6 | % is maxPyrHt(IM,FILT). You can also specify 'auto' to use this value. | ||
7 | % | ||
8 | % FILT (optional) can be a string naming a standard filter (see | ||
9 | % namedFilter), or a vector which will be used for (separable) | ||
10 | % convolution. Filter can be of even or odd length, but should be symmetric. | ||
11 | % Default = 'qmf9'. EDGES specifies edge-handling, and | ||
12 | % defaults to 'reflect1' (see corrDn). | ||
13 | % | ||
14 | % PYR is a vector containing the N pyramid subbands, ordered from fine | ||
15 | % to coarse. INDICES is an Nx2 matrix containing the sizes of | ||
16 | % each subband. This is compatible with the MatLab Wavelet toolbox. | ||
17 | |||
18 | % Eero Simoncelli, 6/96. | ||
19 | |||
20 | function [pyr,pind] = buildWpyr(im, ht, filt, edges) | ||
21 | |||
22 | if (nargin < 1) | ||
23 | error('First argument (IM) is required'); | ||
24 | end | ||
25 | |||
26 | %------------------------------------------------------------ | ||
27 | %% OPTIONAL ARGS: | ||
28 | |||
29 | if (exist('filt') ~= 1) | ||
30 | filt = 'qmf9'; | ||
31 | end | ||
32 | |||
33 | if (exist('edges') ~= 1) | ||
34 | edges= 'reflect1'; | ||
35 | end | ||
36 | |||
37 | if isstr(filt) | ||
38 | filt = namedFilter(filt); | ||
39 | end | ||
40 | |||
41 | if ( (size(filt,1) > 1) & (size(filt,2) > 1) ) | ||
42 | error('FILT should be a 1D filter (i.e., a vector)'); | ||
43 | else | ||
44 | filt = filt(:); | ||
45 | end | ||
46 | |||
47 | hfilt = modulateFlip(filt); | ||
48 | |||
49 | % Stagger sampling if filter is odd-length: | ||
50 | if (mod(size(filt,1),2) == 0) | ||
51 | stag = 2; | ||
52 | else | ||
53 | stag = 1; | ||
54 | end | ||
55 | |||
56 | im_sz = size(im); | ||
57 | |||
58 | max_ht = maxPyrHt(im_sz, size(filt,1)); | ||
59 | if ( (exist('ht') ~= 1) | (ht == 'auto') ) | ||
60 | ht = max_ht; | ||
61 | else | ||
62 | if (ht > max_ht) | ||
63 | error(sprintf('Cannot build pyramid higher than %d levels.',max_ht)); | ||
64 | end | ||
65 | end | ||
66 | |||
67 | if (ht <= 0) | ||
68 | |||
69 | pyr = im(:); | ||
70 | pind = im_sz; | ||
71 | |||
72 | else | ||
73 | |||
74 | if (im_sz(2) == 1) | ||
75 | lolo = corrDn(im, filt, edges, [2 1], [stag 1]); | ||
76 | hihi = corrDn(im, hfilt, edges, [2 1], [2 1]); | ||
77 | elseif (im_sz(1) == 1) | ||
78 | lolo = corrDn(im, filt', edges, [1 2], [1 stag]); | ||
79 | hihi = corrDn(im, hfilt', edges, [1 2], [1 2]); | ||
80 | else | ||
81 | lo = corrDn(im, filt, edges, [2 1], [stag 1]); | ||
82 | hi = corrDn(im, hfilt, edges, [2 1], [2 1]); | ||
83 | lolo = corrDn(lo, filt', edges, [1 2], [1 stag]); | ||
84 | lohi = corrDn(hi, filt', edges, [1 2], [1 stag]); % horizontal | ||
85 | hilo = corrDn(lo, hfilt', edges, [1 2], [1 2]); % vertical | ||
86 | hihi = corrDn(hi, hfilt', edges, [1 2], [1 2]); % diagonal | ||
87 | end | ||
88 | |||
89 | [npyr,nind] = buildWpyr(lolo, ht-1, filt, edges); | ||
90 | |||
91 | if ((im_sz(1) == 1) | (im_sz(2) == 1)) | ||
92 | pyr = [hihi(:); npyr]; | ||
93 | pind = [size(hihi); nind]; | ||
94 | else | ||
95 | pyr = [lohi(:); hilo(:); hihi(:); npyr]; | ||
96 | pind = [size(lohi); size(hilo); size(hihi); nind]; | ||
97 | end | ||
98 | |||
99 | end | ||
100 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/cconv2.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/cconv2.m deleted file mode 100755 index efba438..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/cconv2.m +++ /dev/null | |||
@@ -1,50 +0,0 @@ | |||
1 | % RES = CCONV2(MTX1, MTX2, CTR) | ||
2 | % | ||
3 | % Circular convolution of two matrices. Result will be of size of | ||
4 | % LARGER vector. | ||
5 | % | ||
6 | % The origin of the smaller matrix is assumed to be its center. | ||
7 | % For even dimensions, the origin is determined by the CTR (optional) | ||
8 | % argument: | ||
9 | % CTR origin | ||
10 | % 0 DIM/2 (default) | ||
11 | % 1 (DIM/2)+1 | ||
12 | |||
13 | % Eero Simoncelli, 6/96. Modified 2/97. | ||
14 | |||
15 | function c = cconv2(a,b,ctr) | ||
16 | |||
17 | if (exist('ctr') ~= 1) | ||
18 | ctr = 0; | ||
19 | end | ||
20 | |||
21 | if (( size(a,1) >= size(b,1) ) & ( size(a,2) >= size(b,2) )) | ||
22 | large = a; small = b; | ||
23 | elseif (( size(a,1) <= size(b,1) ) & ( size(a,2) <= size(b,2) )) | ||
24 | large = b; small = a; | ||
25 | else | ||
26 | error('one arg must be larger than the other in both dimensions!'); | ||
27 | end | ||
28 | |||
29 | ly = size(large,1); | ||
30 | lx = size(large,2); | ||
31 | sy = size(small,1); | ||
32 | sx = size(small,2); | ||
33 | |||
34 | %% These values are the index of the small mtx that falls on the | ||
35 | %% border pixel of the large matrix when computing the first | ||
36 | %% convolution response sample: | ||
37 | sy2 = floor((sy+ctr+1)/2); | ||
38 | sx2 = floor((sx+ctr+1)/2); | ||
39 | |||
40 | % pad: | ||
41 | clarge = [ ... | ||
42 | large(ly-sy+sy2+1:ly,lx-sx+sx2+1:lx), large(ly-sy+sy2+1:ly,:), ... | ||
43 | large(ly-sy+sy2+1:ly,1:sx2-1); ... | ||
44 | large(:,lx-sx+sx2+1:lx), large, large(:,1:sx2-1); ... | ||
45 | large(1:sy2-1,lx-sx+sx2+1:lx), ... | ||
46 | large(1:sy2-1,:), ... | ||
47 | large(1:sy2-1,1:sx2-1) ]; | ||
48 | |||
49 | c = conv2(clarge,small,'valid'); | ||
50 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/clip.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/clip.m deleted file mode 100755 index 28804f3..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/clip.m +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | % [RES] = clip(IM, MINVALorRANGE, MAXVAL) | ||
2 | % | ||
3 | % Clip values of matrix IM to lie between minVal and maxVal: | ||
4 | % RES = max(min(IM,MAXVAL),MINVAL) | ||
5 | % The first argument can also specify both min and max, as a 2-vector. | ||
6 | % If only one argument is passed, the range defaults to [0,1]. | ||
7 | |||
8 | function res = clip(im, minValOrRange, maxVal) | ||
9 | |||
10 | if (exist('minValOrRange') ~= 1) | ||
11 | minVal = 0; | ||
12 | maxVal = 1; | ||
13 | elseif (length(minValOrRange) == 2) | ||
14 | minVal = minValOrRange(1); | ||
15 | maxVal = minValOrRange(2); | ||
16 | elseif (length(minValOrRange) == 1) | ||
17 | minVal = minValOrRange; | ||
18 | if (exist('maxVal') ~= 1) | ||
19 | maxVal=minVal+1; | ||
20 | end | ||
21 | else | ||
22 | error('MINVAL must be a scalar or a 2-vector'); | ||
23 | end | ||
24 | |||
25 | if ( maxVal < minVal ) | ||
26 | error('MAXVAL should be less than MINVAL'); | ||
27 | end | ||
28 | |||
29 | res = im; | ||
30 | res(find(im < minVal)) = minVal; | ||
31 | res(find(im > maxVal)) = maxVal; | ||
32 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/corrDn.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/corrDn.m deleted file mode 100755 index 7e07abf..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/corrDn.m +++ /dev/null | |||
@@ -1,63 +0,0 @@ | |||
1 | % RES = corrDn(IM, FILT, EDGES, STEP, START, STOP) | ||
2 | % | ||
3 | % Compute correlation of matrices IM with FILT, followed by | ||
4 | % downsampling. These arguments should be 1D or 2D matrices, and IM | ||
5 | % must be larger (in both dimensions) than FILT. The origin of filt | ||
6 | % is assumed to be floor(size(filt)/2)+1. | ||
7 | % | ||
8 | % EDGES is a string determining boundary handling: | ||
9 | % 'circular' - Circular convolution | ||
10 | % 'reflect1' - Reflect about the edge pixels | ||
11 | % 'reflect2' - Reflect, doubling the edge pixels | ||
12 | % 'repeat' - Repeat the edge pixels | ||
13 | % 'zero' - Assume values of zero outside image boundary | ||
14 | % 'extend' - Reflect and invert | ||
15 | % 'dont-compute' - Zero output when filter overhangs input boundaries | ||
16 | % | ||
17 | % Downsampling factors are determined by STEP (optional, default=[1 1]), | ||
18 | % which should be a 2-vector [y,x]. | ||
19 | % | ||
20 | % The window over which the convolution occurs is specfied by START | ||
21 | % (optional, default=[1,1], and STOP (optional, default=size(IM)). | ||
22 | % | ||
23 | % NOTE: this operation corresponds to multiplication of a signal | ||
24 | % vector by a matrix whose rows contain copies of the FILT shifted by | ||
25 | % multiples of STEP. See upConv.m for the operation corresponding to | ||
26 | % the transpose of this matrix. | ||
27 | |||
28 | % Eero Simoncelli, 6/96, revised 2/97. | ||
29 | |||
30 | function res = corrDn(im, filt, edges, step, start, stop) | ||
31 | |||
32 | %% NOTE: THIS CODE IS NOT ACTUALLY USED! (MEX FILE IS CALLED INSTEAD) | ||
33 | |||
34 | %fprintf(1,'WARNING: You should compile the MEX version of "corrDn.c",\n found in the MEX subdirectory of matlabPyrTools, and put it in your matlab path. It is MUCH faster, and provides more boundary-handling options.\n'); | ||
35 | |||
36 | %------------------------------------------------------------ | ||
37 | %% OPTIONAL ARGS: | ||
38 | |||
39 | if (exist('edges') == 1) | ||
40 | if (strcmp(edges,'reflect1') ~= 1) | ||
41 | warning('Using REFLECT1 edge-handling (use MEX code for other options).'); | ||
42 | end | ||
43 | end | ||
44 | |||
45 | if (exist('step') ~= 1) | ||
46 | step = [1,1]; | ||
47 | end | ||
48 | |||
49 | if (exist('start') ~= 1) | ||
50 | start = [1,1]; | ||
51 | end | ||
52 | |||
53 | if (exist('stop') ~= 1) | ||
54 | stop = size(im); | ||
55 | end | ||
56 | |||
57 | %------------------------------------------------------------ | ||
58 | |||
59 | % Reverse order of taps in filt, to do correlation instead of convolution | ||
60 | filt = filt(size(filt,1):-1:1,size(filt,2):-1:1); | ||
61 | |||
62 | tmp = rconv2(im,filt); | ||
63 | res = tmp(start(1):step(1):stop(1),start(2):step(2):stop(2)); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/edges-orig.c b/SD-VBS/benchmarks/texture_synthesis/src/matlab/edges-orig.c deleted file mode 100755 index 1f6a98b..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/edges-orig.c +++ /dev/null | |||
@@ -1,494 +0,0 @@ | |||
1 | /* | ||
2 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
3 | ;;; File: edges.c | ||
4 | ;;; Author: Eero Simoncelli | ||
5 | ;;; Description: Boundary handling routines for use with convolve.c | ||
6 | ;;; Creation Date: Spring 1987. | ||
7 | ;;; MODIFIED, 6/96, to operate on double float arrays. | ||
8 | ;;; MODIFIED by dgp, 4/1/97, to support THINK C. | ||
9 | ;;; ---------------------------------------------------------------- | ||
10 | ;;; Object-Based Vision and Image Understanding System (OBVIUS), | ||
11 | ;;; Copyright 1988, Vision Science Group, Media Laboratory, | ||
12 | ;;; Massachusetts Institute of Technology. | ||
13 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
14 | */ | ||
15 | |||
16 | /* | ||
17 | This file contains functions which determine how edges are to be | ||
18 | handled when performing convolutions of images with linear filters. | ||
19 | Any edge handling function which is local and linear may be defined, | ||
20 | except (unfortunately) constants cannot be added. So to treat the | ||
21 | edges as if the image is surrounded by a gray field, you must paste it | ||
22 | into a gray image, convolve, and crop it out... | ||
23 | The main convolution function is called internal_filter and is defined | ||
24 | in the file convolve.c. The idea is that the convolution function | ||
25 | calls the edge handling function which computes a new filter based on | ||
26 | the old filter and the distance to the edge of the image. For | ||
27 | example, reflection is done by reflecting the filter through the | ||
28 | appropriate axis and summing. Currently defined functions are listed | ||
29 | below. | ||
30 | */ | ||
31 | |||
32 | /* | ||
33 | #define DEBUG | ||
34 | */ | ||
35 | |||
36 | #include <stdio.h> | ||
37 | #include <math.h> | ||
38 | #include <string.h> | ||
39 | #include "convolve.h" | ||
40 | |||
41 | #define sgn(a) ( ((a)>0)?1:(((a)<0)?-1:0) ) | ||
42 | #define clip(a,mn,mx) ( ((a)<(mn))?(mn):(((a)>=(mx))?(mx-1):(a)) ) | ||
43 | |||
44 | int reflect1(), reflect2(), repeat(), zero(), Extend(), nocompute(); | ||
45 | int ereflect(), predict(); | ||
46 | |||
47 | /* Lookup table matching a descriptive string to the edge-handling function */ | ||
48 | #if !THINK_C | ||
49 | static EDGE_HANDLER edge_foos[] = | ||
50 | { | ||
51 | { "dont-compute", nocompute }, /* zero output for filter touching edge */ | ||
52 | { "zero", zero }, /* zero outside of image */ | ||
53 | { "repeat", repeat }, /* repeat edge pixel */ | ||
54 | { "reflect1", reflect1 }, /* reflect about edge pixels */ | ||
55 | { "reflect2", reflect2 }, /* reflect image, including edge pixels */ | ||
56 | { "extend", Extend }, /* extend (reflect & invert) */ | ||
57 | { "predict", predict }, /* predict based on portion covered by filt */ | ||
58 | { "ereflect", ereflect }, /* orthogonal QMF reflection */ | ||
59 | }; | ||
60 | #else | ||
61 | /* | ||
62 | This is really stupid, but THINK C won't allow initialization of static variables in | ||
63 | a code resource with string addresses. So we do it this way. | ||
64 | The 68K code for a MATLAB 4 MEX file can only be created by THINK C. | ||
65 | However, for MATLAB 5, we'll be able to use Metrowerks CodeWarrior for both 68K and PPC, so this | ||
66 | cludge can be dropped when we drop support for MATLAB 4. | ||
67 | Denis Pelli, 4/1/97. | ||
68 | */ | ||
69 | static EDGE_HANDLER edge_foos[8]; | ||
70 | |||
71 | void InitializeTable(EDGE_HANDLER edge_foos[]) | ||
72 | { | ||
73 | static int i=0; | ||
74 | |||
75 | if(i>0) return; | ||
76 | edge_foos[i].name="dont-compute"; | ||
77 | edge_foos[i++].func=nocompute; | ||
78 | edge_foos[i].name="zero"; | ||
79 | edge_foos[i++].func=zero; | ||
80 | edge_foos[i].name="repeat"; | ||
81 | edge_foos[i++].func=repeat; | ||
82 | edge_foos[i].name="reflect1"; | ||
83 | edge_foos[i++].func=reflect1; | ||
84 | edge_foos[i].name="reflect2"; | ||
85 | edge_foos[i++].func=reflect2; | ||
86 | edge_foos[i].name="extend"; | ||
87 | edge_foos[i++].func=Extend; | ||
88 | edge_foos[i].name="predict"; | ||
89 | edge_foos[i++].func=predict; | ||
90 | edge_foos[i].name="ereflect"; | ||
91 | edge_foos[i++].func=ereflect; | ||
92 | } | ||
93 | #endif | ||
94 | |||
95 | /* | ||
96 | Function looks up an edge handler id string in the structure above, and | ||
97 | returns the associated function | ||
98 | */ | ||
99 | fptr edge_function(char *edges) | ||
100 | { | ||
101 | int i; | ||
102 | |||
103 | #if THINK_C | ||
104 | InitializeTable(edge_foos); | ||
105 | #endif | ||
106 | for (i = 0; i<sizeof(edge_foos)/sizeof(EDGE_HANDLER); i++) | ||
107 | if (strcmp(edges,edge_foos[i].name) == 0) | ||
108 | return(edge_foos[i].func); | ||
109 | printf("Error: '%s' is not the name of a valid edge-handler!\n",edges); | ||
110 | for (i=0; i<sizeof(edge_foos)/sizeof(EDGE_HANDLER); i++) | ||
111 | { | ||
112 | if (i==0) printf(" Options are: "); | ||
113 | else printf(", "); | ||
114 | printf("%s",edge_foos[i].name); | ||
115 | } | ||
116 | printf("\n"); | ||
117 | return(0); | ||
118 | } | ||
119 | |||
120 | /* | ||
121 | ---------------- EDGE HANDLER ARGUMENTS ------------------------ | ||
122 | filt - array of filter taps. | ||
123 | x_dim, y_dim - x and y dimensions of filt. | ||
124 | x_pos - position of filter relative to the horizontal image edges. Negative | ||
125 | values indicate left edge, positive indicate right edge. Zero | ||
126 | indicates that the filter is not touching either edge. An absolute | ||
127 | value of 1 indicates that the edge tap of the filter is over the | ||
128 | edge pixel of the image. | ||
129 | y_pos - analogous to x_pos. | ||
130 | result - array where the resulting filter will go. The edge | ||
131 | of this filter will be aligned with the image for application... | ||
132 | f_or_e - equal to one of the two constants EXPAND or FILTER. | ||
133 | -------------------------------------------------------------------- | ||
134 | */ | ||
135 | |||
136 | |||
137 | /* -------------------------------------------------------------------- | ||
138 | nocompute() - Return zero for values where filter hangs over the edge. | ||
139 | */ | ||
140 | |||
141 | int nocompute(filt,x_dim,y_dim,x_pos,y_pos,result,f_or_e) | ||
142 | register double *filt, *result; | ||
143 | register int x_dim; | ||
144 | int y_dim, x_pos, y_pos, f_or_e; | ||
145 | { | ||
146 | register int i; | ||
147 | register int size = x_dim*y_dim; | ||
148 | |||
149 | if ( (x_pos>1) OR (x_pos<-1) OR (y_pos>1) OR (y_pos<-1) ) | ||
150 | for (i=0; i<size; i++) result[i] = 0.0; | ||
151 | else | ||
152 | for (i=0; i<size; i++) result[i] = filt[i]; | ||
153 | return(0); | ||
154 | } | ||
155 | |||
156 | /* -------------------------------------------------------------------- | ||
157 | zero() - Zero outside of image. Discontinuous, but adds zero energy. */ | ||
158 | |||
159 | int zero(filt,x_dim,y_dim,x_pos,y_pos,result,f_or_e) | ||
160 | register double *filt, *result; | ||
161 | register int x_dim; | ||
162 | int y_dim, x_pos, y_pos, f_or_e; | ||
163 | { | ||
164 | register int y_filt,x_filt, y_res,x_res; | ||
165 | int filt_sz = x_dim*y_dim; | ||
166 | int x_start = ((x_pos>0)?(x_pos-1):((x_pos<0)?(x_pos+1):0)); | ||
167 | int y_start = x_dim * ((y_pos>0)?(y_pos-1):((y_pos<0)?(y_pos+1):0)); | ||
168 | int i; | ||
169 | |||
170 | for (i=0; i<filt_sz; i++) result[i] = 0.0; | ||
171 | |||
172 | for (y_filt=0, y_res=y_start; | ||
173 | y_filt<filt_sz; | ||
174 | y_filt+=x_dim, y_res+=x_dim) | ||
175 | if ((y_res >= 0) AND (y_res < filt_sz)) | ||
176 | for (x_filt=y_filt, x_res=x_start; | ||
177 | x_filt<y_filt+x_dim; | ||
178 | x_filt++, x_res++) | ||
179 | if ((x_res >= 0) AND (x_res < x_dim)) | ||
180 | result[y_res+x_res] = filt[x_filt]; | ||
181 | return(0); | ||
182 | } | ||
183 | |||
184 | /* -------------------------------------------------------------------- | ||
185 | repeat() - repeat edge pixel. Continuous, but content is usually | ||
186 | different from image. | ||
187 | */ | ||
188 | |||
189 | int repeat(filt,x_dim,y_dim,x_pos,y_pos,result,f_or_e) | ||
190 | register double *filt, *result; | ||
191 | register int x_dim; | ||
192 | int y_dim, x_pos, y_pos, f_or_e; | ||
193 | { | ||
194 | register int y_filt,x_filt, y_res,x_res; | ||
195 | int filt_sz = x_dim*y_dim; | ||
196 | int x_start = ((x_pos>0)?(x_pos-1):((x_pos<0)?(x_pos+1):0)); | ||
197 | int y_start = x_dim * ((y_pos>0)?(y_pos-1):((y_pos<0)?(y_pos+1):0)); | ||
198 | int i; | ||
199 | |||
200 | for (i=0; i<filt_sz; i++) result[i] = 0.0; | ||
201 | |||
202 | for (y_filt=0, y_res=y_start; | ||
203 | y_filt<filt_sz; | ||
204 | y_filt+=x_dim, y_res+=x_dim) | ||
205 | for (x_filt=y_filt, x_res=x_start; | ||
206 | x_filt<y_filt+x_dim; | ||
207 | x_filt++, x_res++) | ||
208 | result[((y_res>=0)?((y_res<filt_sz)?y_res:(filt_sz-x_dim)):0) | ||
209 | + ((x_res>=0)?((x_res<x_dim)?x_res:(x_dim-1)):0)] | ||
210 | += filt[x_filt]; | ||
211 | return(0); | ||
212 | } | ||
213 | |||
214 | /* -------------------------------------------------------------------- | ||
215 | reflect2() - "Normal" image reflection. The edge pixel is repeated, | ||
216 | then the next pixel, etc. Continuous, attempting to maintain | ||
217 | "similar" content, but discontinuous first derivative. | ||
218 | */ | ||
219 | |||
220 | int reflect2(filt,x_dim,y_dim,x_pos,y_pos,result,f_or_e) | ||
221 | register double *filt, *result; | ||
222 | register int x_dim; | ||
223 | int y_dim, x_pos, y_pos, f_or_e; | ||
224 | { | ||
225 | register int y_filt,x_filt, y_edge,x_edge; | ||
226 | register int x_base = (x_pos>0)?(x_dim-1):0; | ||
227 | register int y_base = (y_pos>0)?(x_dim*(y_dim-1)):0; | ||
228 | int filt_sz = x_dim*y_dim; | ||
229 | int x_edge_dist = (x_pos>0)?(x_pos-x_dim-1):(x_pos+1); | ||
230 | int y_edge_dist = x_dim * ((y_pos>0)?(y_pos-y_dim-1):(y_pos+1)); | ||
231 | int i; | ||
232 | |||
233 | #ifdef DEBUG | ||
234 | printf("(%d,%d) ",y_pos,x_pos); | ||
235 | if (x_pos==0) printf("\n"); | ||
236 | #endif | ||
237 | |||
238 | for (i=0; i<filt_sz; i++) result[i] = 0.0; | ||
239 | |||
240 | for (y_filt=0, y_edge=y_edge_dist; | ||
241 | y_filt<filt_sz; | ||
242 | y_filt+=x_dim, y_edge+=x_dim) | ||
243 | { | ||
244 | if (y_edge IS 0) y_edge+=x_dim; | ||
245 | for (x_filt=y_filt, x_edge=x_edge_dist; | ||
246 | x_filt<y_filt+x_dim; | ||
247 | x_filt++, x_edge++) | ||
248 | { | ||
249 | if (x_edge IS 0) x_edge++; | ||
250 | result[ABS(y_base-ABS(y_edge)+x_dim) + ABS(x_base-ABS(x_edge)+1)] | ||
251 | += filt[x_filt]; | ||
252 | } | ||
253 | } | ||
254 | return(0); | ||
255 | } | ||
256 | |||
257 | /* -------------------------------------------------------------------- | ||
258 | reflect1() - Reflection through the edge pixels. This is the right thing | ||
259 | to do if you are subsampling by 2, since it maintains parity (even | ||
260 | pixels positions remain even, odd ones remain odd). (note: procedure differs | ||
261 | depending on f_or_e parameter). */ | ||
262 | |||
263 | int reflect1(filt,x_dim,y_dim,x_pos,y_pos,result,f_or_e) | ||
264 | register double *filt, *result; | ||
265 | register int x_dim; | ||
266 | int y_dim, x_pos, y_pos, f_or_e; | ||
267 | { | ||
268 | int filt_sz = x_dim*y_dim; | ||
269 | register int x_start = 0, y_start = 0, x_stop = x_dim, y_stop = filt_sz; | ||
270 | register int y_filt,x_filt, y_edge,x_edge; | ||
271 | register int x_base = (x_pos>0)?(x_dim-1):0; | ||
272 | register int y_base = (y_pos>0)?(x_dim*(y_dim-1)):0; | ||
273 | int x_edge_dist = (x_pos>0)?(x_pos-x_dim):((x_pos<0)?(x_pos+1):0); | ||
274 | int y_edge_dist = x_dim * ((y_pos>0)?(y_pos-y_dim):((y_pos<0)?(y_pos+1):0)); | ||
275 | int i; | ||
276 | int mx_pos = (x_dim/2)+1; | ||
277 | int my_pos = (y_dim/2)+1; | ||
278 | |||
279 | #ifdef DEBUG | ||
280 | printf("(%d,%d) ",y_pos,x_pos); | ||
281 | if (x_pos==0) printf("\n"); | ||
282 | #endif | ||
283 | |||
284 | for (i=0; i<filt_sz; i++) result[i] = 0.0; | ||
285 | |||
286 | /* if EXPAND and filter is centered on image edge, do not reflect */ | ||
287 | if (f_or_e IS EXPAND) | ||
288 | { | ||
289 | if (x_pos IS mx_pos) x_stop = (x_dim+1)/2; | ||
290 | else if (x_pos IS -mx_pos) { x_start = x_dim/2; x_edge_dist = 0; } | ||
291 | |||
292 | if (y_pos IS my_pos) y_stop = x_dim*((y_dim+1)/2); | ||
293 | else if (y_pos IS -my_pos) { y_start = x_dim*(y_dim/2); y_edge_dist = 0;} | ||
294 | } | ||
295 | |||
296 | /* reflect at boundary of image */ | ||
297 | for (y_filt=y_start, y_edge=y_edge_dist; | ||
298 | y_filt<y_stop; | ||
299 | y_filt+=x_dim, y_edge+=x_dim) | ||
300 | for (x_filt=y_filt+x_start, x_edge=x_edge_dist; | ||
301 | x_filt<y_filt+x_stop; | ||
302 | x_filt++, x_edge++) | ||
303 | result[ABS(y_base-ABS(y_edge)) + ABS(x_base-ABS(x_edge))] | ||
304 | += filt[x_filt]; | ||
305 | |||
306 | /* if EXPAND and filter is not centered on image edge, mult edge by 2 */ | ||
307 | if (f_or_e IS EXPAND) | ||
308 | { | ||
309 | if ( (ABS(x_pos) ISNT mx_pos) AND (x_pos ISNT 0) ) | ||
310 | for (y_filt=x_base; y_filt<filt_sz; y_filt+=x_dim) | ||
311 | result[y_filt] += result[y_filt]; | ||
312 | if ( (ABS(y_pos) ISNT my_pos) AND (y_pos ISNT 0) ) | ||
313 | for (x_filt=y_base; x_filt<y_base+x_dim; x_filt++) | ||
314 | result[x_filt] += result[x_filt]; | ||
315 | } | ||
316 | return(0); | ||
317 | } | ||
318 | |||
319 | /* -------------------------------------------------------------------- | ||
320 | Extend() - Extend image by reflecting and inverting about edge pixel | ||
321 | value. Maintains continuity in intensity AND first derivative (but | ||
322 | not higher derivs). | ||
323 | */ | ||
324 | |||
325 | int Extend(filt,x_dim,y_dim,x_pos,y_pos,result,f_or_e) | ||
326 | register double *filt, *result; | ||
327 | register int x_dim; | ||
328 | int y_dim, x_pos, y_pos, f_or_e; | ||
329 | { | ||
330 | int filt_sz = x_dim*y_dim; | ||
331 | register int x_start = 0, y_start = 0, x_stop = x_dim, y_stop = filt_sz; | ||
332 | register int y_filt,x_filt, y_edge,x_edge; | ||
333 | register int x_base = (x_pos>0)?(x_dim-1):0; | ||
334 | register int y_base = (y_pos>0)?(x_dim*(y_dim-1)):0; | ||
335 | int x_edge_dist = (x_pos>0)?(x_pos-x_dim):((x_pos<-1)?(x_pos+1):0); | ||
336 | int y_edge_dist = x_dim * ((y_pos>0)?(y_pos-y_dim):((y_pos<-1)?(y_pos+1):0)); | ||
337 | int i; | ||
338 | int mx_pos = (x_dim/2)+1; | ||
339 | int my_pos = (y_dim/2)+1; | ||
340 | |||
341 | for (i=0; i<filt_sz; i++) result[i] = 0.0; | ||
342 | |||
343 | /* if EXPAND and filter is centered on image edge, do not reflect */ | ||
344 | if (f_or_e IS EXPAND) | ||
345 | { | ||
346 | if (x_pos IS mx_pos) x_stop = (x_dim+1)/2; | ||
347 | else if (x_pos IS -mx_pos) { x_start = x_dim/2; x_edge_dist = 0; } | ||
348 | |||
349 | if (y_pos IS my_pos) y_stop = x_dim*((y_dim+1)/2); | ||
350 | else if (y_pos IS -my_pos) { y_start = x_dim*(y_dim/2); y_edge_dist = 0;} | ||
351 | } | ||
352 | |||
353 | /* reflect at boundary of image */ | ||
354 | for (y_filt=y_start, y_edge=y_edge_dist; | ||
355 | y_filt<y_stop; | ||
356 | y_filt+=x_dim, y_edge+=x_dim) | ||
357 | for (x_filt=y_filt+x_start, x_edge=x_edge_dist; | ||
358 | x_filt<y_filt+x_stop; | ||
359 | x_filt++, x_edge++) | ||
360 | if (((!y_base AND (sgn(y_edge) IS -1)) /* y overhanging */ | ||
361 | OR | ||
362 | (y_base AND (sgn(y_edge) IS 1))) | ||
363 | ISNT /* XOR */ | ||
364 | ((!x_base AND (sgn(x_edge) IS -1)) /* x overhanging */ | ||
365 | OR | ||
366 | (x_base AND (sgn(x_edge) IS 1)))) | ||
367 | { | ||
368 | result[ABS(y_base-ABS(y_edge)) + ABS(x_base-ABS(x_edge))] | ||
369 | -= filt[x_filt]; | ||
370 | result[clip(y_base+y_edge,0,y_dim) + clip(x_base+x_edge,0,x_dim)] | ||
371 | += filt[x_filt] + filt[x_filt]; | ||
372 | } | ||
373 | else result[ABS(y_base-ABS(y_edge)) + ABS(x_base-ABS(x_edge))] | ||
374 | += filt[x_filt]; | ||
375 | return(0); | ||
376 | } | ||
377 | |||
378 | /* -------------------------------------------------------------------- | ||
379 | predict() - Simple prediction. Like zero, but multiplies the result | ||
380 | by the reciprocal of the percentage of filter being used. (i.e. if | ||
381 | 50% of the filter is hanging over the edge of the image, multiply the | ||
382 | taps being used by 2). */ | ||
383 | |||
384 | int predict(filt,x_dim,y_dim,x_pos,y_pos,result,f_or_e) | ||
385 | register double *filt, *result; | ||
386 | register int x_dim; | ||
387 | int y_dim, x_pos, y_pos, f_or_e; | ||
388 | { | ||
389 | register int y_filt,x_filt, y_res,x_res; | ||
390 | register double taps_used = 0.0; /* int *** */ | ||
391 | register double fraction = 0.0; | ||
392 | int filt_sz = x_dim*y_dim; | ||
393 | int x_start = ((x_pos>0)?(x_pos-1):((x_pos<0)?(x_pos+1):0)); | ||
394 | int y_start = x_dim * ((y_pos>0)?(y_pos-1):((y_pos<0)?(y_pos+1):0)); | ||
395 | int i; | ||
396 | |||
397 | for (i=0; i<filt_sz; i++) result[i] = 0.0; | ||
398 | |||
399 | for (y_filt=0, y_res=y_start; | ||
400 | y_filt<filt_sz; | ||
401 | y_filt+=x_dim, y_res+=x_dim) | ||
402 | if ((y_res >= 0) AND (y_res < filt_sz)) | ||
403 | for (x_filt=y_filt, x_res=x_start; | ||
404 | x_filt<y_filt+x_dim; | ||
405 | x_filt++, x_res++) | ||
406 | if ((x_res >= 0) AND (x_res < x_dim)) | ||
407 | { | ||
408 | result[y_res+x_res] = filt[x_filt]; | ||
409 | taps_used += ABS(filt[x_filt]); | ||
410 | } | ||
411 | printf("TU: %f\n",taps_used); | ||
412 | if (f_or_e IS FILTER) | ||
413 | { | ||
414 | /* fraction = ( (double) filt_sz ) / ( (double) taps_used ); */ | ||
415 | for (i=0; i<filt_sz; i++) fraction += ABS(filt[i]); | ||
416 | fraction = ( fraction / taps_used ); | ||
417 | for (i=0; i<filt_sz; i++) result[i] *= fraction; | ||
418 | } | ||
419 | return(0); | ||
420 | } | ||
421 | |||
422 | |||
423 | /* -------------------------------------------------------------------- | ||
424 | Reflect, multiplying tap of filter which is at the edge of the image | ||
425 | by root 2. This maintains orthogonality of odd-length linear-phase | ||
426 | QMF filters, but it is not useful for most applications, since it | ||
427 | alters the DC level. */ | ||
428 | |||
429 | int ereflect(filt,x_dim,y_dim,x_pos,y_pos,result,f_or_e) | ||
430 | register double *filt, *result; | ||
431 | register int x_dim; | ||
432 | int y_dim, x_pos, y_pos, f_or_e; | ||
433 | { | ||
434 | register int y_filt,x_filt, y_edge,x_edge; | ||
435 | register int x_base = (x_pos>0)?(x_dim-1):0; | ||
436 | register int y_base = x_dim * ( (y_pos>0)?(y_dim-1):0 ); | ||
437 | int filt_sz = x_dim*y_dim; | ||
438 | int x_edge_dist = (x_pos>1)?(x_pos-x_dim):((x_pos<-1)?(x_pos+1):0); | ||
439 | int y_edge_dist = x_dim * ( (y_pos>1)?(y_pos-y_dim):((y_pos<-1)?(y_pos+1):0) ); | ||
440 | int i; | ||
441 | double norm,onorm; | ||
442 | |||
443 | for (i=0; i<filt_sz; i++) result[i] = 0.0; | ||
444 | |||
445 | /* reflect at boundary */ | ||
446 | for (y_filt=0, y_edge=y_edge_dist; | ||
447 | y_filt<filt_sz; | ||
448 | y_filt+=x_dim, y_edge+=x_dim) | ||
449 | for (x_filt=y_filt, x_edge=x_edge_dist; | ||
450 | x_filt<y_filt+x_dim; | ||
451 | x_filt++, x_edge++) | ||
452 | result[ABS(y_base-ABS(y_edge)) + ABS(x_base-ABS(x_edge))] | ||
453 | += filt[x_filt]; | ||
454 | |||
455 | /* now multiply edge by root 2 */ | ||
456 | if (x_pos ISNT 0) | ||
457 | for (y_filt=x_base; y_filt<filt_sz; y_filt+=x_dim) | ||
458 | result[y_filt] *= ROOT2; | ||
459 | if (y_pos ISNT 0) | ||
460 | for (x_filt=y_base; x_filt<y_base+x_dim; x_filt++) | ||
461 | result[x_filt] *= ROOT2; | ||
462 | |||
463 | /* now normalize to norm of original filter */ | ||
464 | for (norm=0.0,i=0; i<filt_sz; i++) | ||
465 | norm += (result[i]*result[i]); | ||
466 | norm=sqrt(norm); | ||
467 | |||
468 | for (onorm=0.0,i=0; i<filt_sz; i++) | ||
469 | onorm += (filt[i]*filt[i]); | ||
470 | onorm = sqrt(onorm); | ||
471 | |||
472 | norm = norm/onorm; | ||
473 | for (i=0; i<filt_sz; i++) | ||
474 | result[i] /= norm; | ||
475 | return(0); | ||
476 | } | ||
477 | |||
478 | |||
479 | /* ------- printout stuff for testing ------------------------------ | ||
480 | printf("Xpos: %d, Ypos: %d", x_pos, y_pos); | ||
481 | for (y_filt=0; y_filt<y_dim; y_filt++) | ||
482 | { | ||
483 | printf("\n"); | ||
484 | for (x_filt=0; x_filt<x_dim; x_filt++) | ||
485 | printf("%6.1f", result[y_filt*x_dim+x_filt]); | ||
486 | } | ||
487 | printf("\n"); | ||
488 | */ | ||
489 | |||
490 | |||
491 | |||
492 | /* Local Variables: */ | ||
493 | /* buffer-read-only: t */ | ||
494 | /* End: */ | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/einstein.pgm b/SD-VBS/benchmarks/texture_synthesis/src/matlab/einstein.pgm deleted file mode 100755 index 99b974c..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/einstein.pgm +++ /dev/null | |||
Binary files differ | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/entropy2.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/entropy2.m deleted file mode 100755 index 68a2a9f..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/entropy2.m +++ /dev/null | |||
@@ -1,31 +0,0 @@ | |||
1 | % E = ENTROPY2(MTX,BINSIZE) | ||
2 | % | ||
3 | % Compute the first-order sample entropy of MTX. Samples of VEC are | ||
4 | % first discretized. Optional argument BINSIZE controls the | ||
5 | % discretization, and defaults to 256/(max(VEC)-min(VEC)). | ||
6 | % | ||
7 | % NOTE: This is a heavily biased estimate of entropy when you | ||
8 | % don't have much data. | ||
9 | |||
10 | % Eero Simoncelli, 6/96. | ||
11 | |||
12 | function res = entropy2(mtx,binsize) | ||
13 | |||
14 | %% Ensure it's a vector, not a matrix. | ||
15 | vec = mtx(:); | ||
16 | [mn,mx] = range2(vec); | ||
17 | |||
18 | if (exist('binsize') == 1) | ||
19 | nbins = max((mx-mn)/binsize, 1); | ||
20 | else | ||
21 | nbins = 256; | ||
22 | end | ||
23 | |||
24 | [bincount,bins] = histo(vec,nbins); | ||
25 | |||
26 | %% Collect non-zero bins: | ||
27 | H = bincount(find(bincount)); | ||
28 | H = H/sum(H); | ||
29 | |||
30 | res = -sum(H .* log2(H)); | ||
31 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/expand.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/expand.m deleted file mode 100755 index 5f6e4d9..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/expand.m +++ /dev/null | |||
@@ -1,34 +0,0 @@ | |||
1 | function te = expand(t,f) | ||
2 | |||
3 | % Expand spatially an image t in a factor f | ||
4 | % in X and in Y. | ||
5 | % t may be complex. | ||
6 | % It fills in with zeros in the Fourier domain. | ||
7 | % te = expand(t, f) | ||
8 | % See also: shrink.m | ||
9 | % JPM, May 95, Instituto de Optica, CSIC, Madrid. | ||
10 | |||
11 | [my mx]=size(t); | ||
12 | my=f*my; | ||
13 | mx=f*mx; | ||
14 | Te=zeros(my,mx); | ||
15 | T=f^2*fftshift(fft2(t)); | ||
16 | y1=my/2+2-my/(2*f); | ||
17 | y2=my/2+my/(2*f); | ||
18 | x1=mx/2+2-mx/(2*f); | ||
19 | x2=mx/2+mx/(2*f); | ||
20 | Te(y1:y2,x1:x2)=T(2:my/f,2:mx/f); | ||
21 | Te(y1-1,x1:x2)=T(1,2:mx/f)/2; | ||
22 | Te(y2+1,x1:x2)=((T(1,mx/f:-1:2)/2)').'; | ||
23 | Te(y1:y2,x1-1)=T(2:my/f,1)/2; | ||
24 | Te(y1:y2,x2+1)=((T(my/f:-1:2,1)/2)').'; | ||
25 | esq=T(1,1)/4; | ||
26 | Te(y1-1,x1-1)=esq; | ||
27 | Te(y1-1,x2+1)=esq; | ||
28 | Te(y2+1,x1-1)=esq; | ||
29 | Te(y2+1,x2+1)=esq; | ||
30 | Te=fftshift(Te); | ||
31 | te=ifft2(Te); | ||
32 | if all(imag(t)==0), | ||
33 | te = real(te); | ||
34 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/factorial.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/factorial.m deleted file mode 100755 index 9255f43..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/factorial.m +++ /dev/null | |||
@@ -1,16 +0,0 @@ | |||
1 | %% RES = factorial(NUM) | ||
2 | % | ||
3 | % Factorial function that works on matrices (matlab's does not). | ||
4 | |||
5 | % EPS, 11/02 | ||
6 | |||
7 | function res = factorial(num) | ||
8 | |||
9 | res = ones(size(num)); | ||
10 | |||
11 | ind = find(num > 0); | ||
12 | if ( ~isempty(ind) ) | ||
13 | subNum = num(ind); | ||
14 | res(ind) = subNum .* factorial(subNum-1); | ||
15 | end | ||
16 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/feynman.pgm b/SD-VBS/benchmarks/texture_synthesis/src/matlab/feynman.pgm deleted file mode 100755 index 7d14101..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/feynman.pgm +++ /dev/null | |||
Binary files differ | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/histo.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/histo.m deleted file mode 100755 index 8da36e5..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/histo.m +++ /dev/null | |||
@@ -1,58 +0,0 @@ | |||
1 | % [N,X] = histo(MTX, nbinsOrBinsize, binCenter); | ||
2 | % | ||
3 | % Compute a histogram of (all) elements of MTX. N contains the histogram | ||
4 | % counts, X is a vector containg the centers of the histogram bins. | ||
5 | % | ||
6 | % nbinsOrBinsize (optional, default = 101) specifies either | ||
7 | % the number of histogram bins, or the negative of the binsize. | ||
8 | % | ||
9 | % binCenter (optional, default = mean2(MTX)) specifies a center position | ||
10 | % for (any one of) the histogram bins. | ||
11 | % | ||
12 | % How does this differ from MatLab's HIST function? This function: | ||
13 | % - allows uniformly spaced bins only. | ||
14 | % +/- operates on all elements of MTX, instead of columnwise. | ||
15 | % + is much faster (approximately a factor of 80 on my machine). | ||
16 | % + allows specification of number of bins OR binsize. Default=101 bins. | ||
17 | % + allows (optional) specification of binCenter. | ||
18 | |||
19 | % Eero Simoncelli, 3/97. | ||
20 | |||
21 | function [N, X] = histo(mtx, nbins, binCtr) | ||
22 | |||
23 | %% NOTE: THIS CODE IS NOT ACTUALLY USED! (MEX FILE IS CALLED INSTEAD) | ||
24 | |||
25 | %fprintf(1,'WARNING: You should compile the MEX version of "histo.c",\n found in the MEX subdirectory of matlabPyrTools, and put it in your matlab path. It is MUCH faster.\n'); | ||
26 | |||
27 | mtx = mtx(:); | ||
28 | |||
29 | %------------------------------------------------------------ | ||
30 | %% OPTIONAL ARGS: | ||
31 | |||
32 | [mn,mx] = range2(mtx); | ||
33 | |||
34 | if (exist('binCtr') ~= 1) | ||
35 | binCtr = mean(mtx); | ||
36 | end | ||
37 | |||
38 | if (exist('nbins') == 1) | ||
39 | if (nbins < 0) | ||
40 | binSize = -nbins; | ||
41 | else | ||
42 | binSize = ((mx-mn)/nbins); | ||
43 | tmpNbins = round((mx-binCtr)/binSize) - round((mn-binCtr)/binSize); | ||
44 | if (tmpNbins ~= nbins) | ||
45 | warning('Using %d bins instead of requested number (%d)',tmpNbins,nbins); | ||
46 | end | ||
47 | end | ||
48 | else | ||
49 | binSize = ((mx-mn)/101); | ||
50 | end | ||
51 | |||
52 | firstBin = binCtr + binSize*round( (mn-binCtr)/binSize ); | ||
53 | |||
54 | tmpNbins = round((mx-binCtr)/binSize) - round((mn-binCtr)/binSize); | ||
55 | |||
56 | bins = firstBin + binSize*[0:tmpNbins]; | ||
57 | |||
58 | [N, X] = hist(mtx, bins); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/histoMatch.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/histoMatch.m deleted file mode 100755 index ab82782..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/histoMatch.m +++ /dev/null | |||
@@ -1,35 +0,0 @@ | |||
1 | % RES = histoMatch(MTX, N, X) | ||
2 | % | ||
3 | % Modify elements of MTX so that normalized histogram matches that | ||
4 | % specified by vectors X and N, where N contains the histogram counts | ||
5 | % and X the histogram bin positions (see histo). | ||
6 | |||
7 | % Eero Simoncelli, 7/96. | ||
8 | |||
9 | function res = histoMatch(mtx, N, X) | ||
10 | |||
11 | if ( exist('histo') == 3 ) | ||
12 | [oN, oX] = histo(mtx(:), size(X(:),1)); | ||
13 | else | ||
14 | [oN, oX] = hist(mtx(:), size(X(:),1)); | ||
15 | end | ||
16 | |||
17 | oStep = oX(2) - oX(1); | ||
18 | oC = [0, cumsum(oN)]/sum(oN); | ||
19 | oX = [oX(1)-oStep/2, oX+oStep/2]; | ||
20 | |||
21 | N = N(:)'; | ||
22 | X = X(:)'; | ||
23 | N = N + mean(N)/(1e8); %% HACK: no empty bins ensures nC strictly monotonic | ||
24 | |||
25 | nStep = X(2) - X(1); | ||
26 | nC = [0, cumsum(N)]/sum(N); | ||
27 | nX = [X(1)-nStep/2, X+nStep/2]; | ||
28 | |||
29 | nnX = interp1(nC, nX, oC, 'linear'); | ||
30 | |||
31 | if ( exist('pointOp') == 3 ) | ||
32 | res = pointOp(mtx, nnX, oX(1), oStep); | ||
33 | else | ||
34 | res = reshape(interp1(oX, nnX, mtx(:)),size(mtx,1),size(mtx,2)); | ||
35 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/ifftshift.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/ifftshift.m deleted file mode 100755 index 2ade297..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/ifftshift.m +++ /dev/null | |||
@@ -1,15 +0,0 @@ | |||
1 | % [RES] = ifftshift (MTX) | ||
2 | % | ||
3 | % Inverse of MatLab's FFTSHIFT. That is, | ||
4 | % ifftshift(fftshift(MTX)) = MTX | ||
5 | % for any size MTX. | ||
6 | |||
7 | % Eero Simoncelli, 2/97. | ||
8 | |||
9 | function [res] = ifftshift(mtx) | ||
10 | |||
11 | sz = size(mtx); | ||
12 | DC = ceil((sz+1)./2); % location of DC term in a matlab fft. | ||
13 | |||
14 | res = [mtx(DC(1):sz(1), DC(2):sz(2)) , mtx(DC(1):sz(1), 1:DC(2)-1); ... | ||
15 | mtx(1:DC(1)-1, DC(2):sz(2)) , mtx(1:DC(1)-1, 1:DC(2)-1)]; | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/imGradient.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/imGradient.m deleted file mode 100755 index 23187e3..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/imGradient.m +++ /dev/null | |||
@@ -1,48 +0,0 @@ | |||
1 | % [dx, dy] = imGradient(im, edges) | ||
2 | % | ||
3 | % Compute the gradient of the image using smooth derivative filters | ||
4 | % optimized for accurate direction estimation. Coordinate system | ||
5 | % corresponds to standard pixel indexing: X axis points rightward. Y | ||
6 | % axis points downward. EDGES specify boundary handling (see corrDn | ||
7 | % for options). | ||
8 | |||
9 | % EPS, 1997. | ||
10 | % original filters from Int'l Conf Image Processing, 1994. | ||
11 | % updated filters 10/2003. | ||
12 | % Added to matlabPyrTools 10/2004. | ||
13 | |||
14 | function [dx, dy] = imGradient(im, edges) | ||
15 | |||
16 | %% 1D smoothing and differentiation kernels. | ||
17 | %% See Farid & Simoncelli, IEEE Trans Image Processing, 13(4):496-508, April 2004. | ||
18 | |||
19 | if (exist('edges') ~= 1) | ||
20 | edges = 'dont-compute'; | ||
21 | end | ||
22 | |||
23 | gp = [0.037659 0.249153 0.426375 0.249153 0.037659]'; | ||
24 | gd = [-0.109604 -0.276691 0.000000 0.276691 0.109604]'; | ||
25 | |||
26 | dx = corrDn(corrDn(im, gp, edges), gd', edges); | ||
27 | dy = corrDn(corrDn(im, gd, edges), gp', edges); | ||
28 | |||
29 | return | ||
30 | |||
31 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
32 | %%% TEST: | ||
33 | |||
34 | %%Make a ramp with random slope and direction | ||
35 | dir = 2*pi*rand - pi; | ||
36 | slope = 10*rand; | ||
37 | |||
38 | sz = 32 | ||
39 | im = mkRamp(sz, dir, slope); | ||
40 | [dx,dy] = imGradient(im); | ||
41 | showIm(dx + sqrt(-1)*dy); | ||
42 | |||
43 | ctr = (sz*sz/2)+sz/2; | ||
44 | slopeEst = sqrt(dx(ctr).^2 + dy(ctr).^2); | ||
45 | dirEst = atan2(dy(ctr), dx(ctr)); | ||
46 | |||
47 | [slope, slopeEst] | ||
48 | [dir, dirEst] | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/imStats.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/imStats.m deleted file mode 100755 index 3d79b4c..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/imStats.m +++ /dev/null | |||
@@ -1,41 +0,0 @@ | |||
1 | % imStats(IM1,IM2) | ||
2 | % | ||
3 | % Report image (matrix) statistics. | ||
4 | % When called on a single image IM1, report min, max, mean, stdev, | ||
5 | % and kurtosis. | ||
6 | % When called on two images (IM1 and IM2), report min, max, mean, | ||
7 | % stdev of the difference, and also SNR (relative to IM1). | ||
8 | |||
9 | % Eero Simoncelli, 6/96. | ||
10 | |||
11 | function [] = imStats(im1,im2) | ||
12 | |||
13 | if (~isreal(im1)) | ||
14 | error('Args must be real-valued matrices'); | ||
15 | end | ||
16 | |||
17 | if (exist('im2') == 1) | ||
18 | difference = im1 - im2; | ||
19 | [mn,mx] = range2(difference); | ||
20 | mean = mean2(difference); | ||
21 | v = var2(difference,mean); | ||
22 | if (v < realmin) | ||
23 | snr = Inf; | ||
24 | else | ||
25 | snr = 10 * log10(var2(im1)/v); | ||
26 | end | ||
27 | fprintf(1, 'Difference statistics:\n'); | ||
28 | fprintf(1, ' Range: [%c, %c]\n',mn,mx); | ||
29 | fprintf(1, ' Mean: %f, Stdev (rmse): %f, SNR (dB): %f\n',... | ||
30 | mean,sqrt(v),snr); | ||
31 | else | ||
32 | [mn,mx] = range2(im1); | ||
33 | mean = mean2(im1); | ||
34 | var = var2(im1); | ||
35 | stdev = sqrt(real(var))+sqrt(imag(var)); | ||
36 | kurt = kurt2(im1, mean, stdev^2); | ||
37 | fprintf(1, 'Image statistics:\n'); | ||
38 | fprintf(1, ' Range: [%f, %f]\n',mn,mx); | ||
39 | fprintf(1, ' Mean: %f, Stdev: %f, Kurtosis: %f\n',mean,stdev,kurt); | ||
40 | end | ||
41 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/innerProd.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/innerProd.m deleted file mode 100755 index 9252c70..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/innerProd.m +++ /dev/null | |||
@@ -1,12 +0,0 @@ | |||
1 | % RES = innerProd(MTX) | ||
2 | % | ||
3 | % Compute (MTX' * MTX) efficiently (i.e., without copying the matrix) | ||
4 | |||
5 | function res = innerProd(mtx) | ||
6 | |||
7 | %fprintf(1,['WARNING: You should compile the MEX version of' ... | ||
8 | % ' "innerProd.c",\n found in the MEX subdirectory' ... | ||
9 | % ' of matlabPyrTools, and put it in your matlab path.' ... | ||
10 | % ' It is MUCH faster and requires less memory.\n']); | ||
11 | |||
12 | res = mtx' * mtx; | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/kurt2.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/kurt2.m deleted file mode 100755 index 8351eb4..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/kurt2.m +++ /dev/null | |||
@@ -1,24 +0,0 @@ | |||
1 | % K = KURT2(MTX,MEAN,VAR) | ||
2 | % | ||
3 | % Sample kurtosis (fourth moment divided by squared variance) | ||
4 | % of a matrix. Kurtosis of a Gaussian distribution is 3. | ||
5 | % MEAN (optional) and VAR (optional) make the computation faster. | ||
6 | |||
7 | % Eero Simoncelli, 6/96. | ||
8 | |||
9 | function res = kurt2(mtx, mn, v) | ||
10 | |||
11 | if (exist('mn') ~= 1) | ||
12 | mn = mean(mean(mtx)); | ||
13 | end | ||
14 | |||
15 | if (exist('v') ~= 1) | ||
16 | v = var2(mtx,mn); | ||
17 | end | ||
18 | |||
19 | if (isreal(mtx)) | ||
20 | res = mean(mean(abs(mtx-mn).^4)) / (v^2); | ||
21 | else | ||
22 | res = mean(mean(real(mtx-mn).^4)) / (real(v)^2) + ... | ||
23 | i*mean(mean(imag(mtx-mn).^4)) / (imag(v)^2); | ||
24 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/lplot.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/lplot.m deleted file mode 100755 index 3c67d8b..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/lplot.m +++ /dev/null | |||
@@ -1,43 +0,0 @@ | |||
1 | % lplot(VEC, XRANGE) | ||
2 | % | ||
3 | % Plot VEC, a vector, in "lollipop" format. | ||
4 | % XRANGE (optional, default = [1,length(VEC)]), should be a 2-vector | ||
5 | % specifying the X positions (for labeling purposes) of the first and | ||
6 | % last sample of VEC. | ||
7 | |||
8 | % Mark Liberman, Linguistics Dept, UPenn, 1994. | ||
9 | |||
10 | function lplot(x,xrange) | ||
11 | |||
12 | if (exist('xrange') ~= 1) | ||
13 | xrange = [1,length(x)]; | ||
14 | end | ||
15 | |||
16 | msize = size(x); | ||
17 | if ( msize(2) == 1) | ||
18 | x = x'; | ||
19 | elseif (msize(1) ~= 1) | ||
20 | error('First arg must be a vector'); | ||
21 | end | ||
22 | |||
23 | if (~isreal(x)) | ||
24 | fprintf(1,'Warning: Imaginary part of signal ignored\n'); | ||
25 | x = abs(x); | ||
26 | end | ||
27 | |||
28 | N = length(x); | ||
29 | index = xrange(1) + (xrange(2)-xrange(1))*[0:(N-1)]/(N-1) | ||
30 | xinc = index(2)-index(1); | ||
31 | |||
32 | xx = [zeros(1,N);x;zeros(1,N)]; | ||
33 | indexis = [index;index;index]; | ||
34 | xdiscrete = [0 xx(:)' 0]; | ||
35 | idiscrete = [index(1)-xinc indexis(:)' index(N)+xinc]; | ||
36 | |||
37 | [mn,mx] = range2(xdiscrete); | ||
38 | ypad = (mx-mn)/12; % MAGIC NUMBER: graph padding | ||
39 | |||
40 | plot(idiscrete, xdiscrete, index, x, 'o'); | ||
41 | axis([index(1)-xinc, index(N)+xinc, mn-ypad, mx+ypad]); | ||
42 | |||
43 | return | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/lpyrHt.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/lpyrHt.m deleted file mode 100755 index d6834d7..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/lpyrHt.m +++ /dev/null | |||
@@ -1,11 +0,0 @@ | |||
1 | % [HEIGHT] = lpyrHt(INDICES) | ||
2 | % | ||
3 | % Compute height of Laplacian pyramid with given its INDICES matrix. | ||
4 | % See buildLpyr.m | ||
5 | |||
6 | % Eero Simoncelli, 6/96. | ||
7 | |||
8 | function [ht] = lpyrHt(pind) | ||
9 | |||
10 | % Don't count lowpass residual band | ||
11 | ht = size(pind,1)-1; | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/maxPyrHt.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/maxPyrHt.m deleted file mode 100755 index 84bcf29..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/maxPyrHt.m +++ /dev/null | |||
@@ -1,25 +0,0 @@ | |||
1 | % HEIGHT = maxPyrHt(IMSIZE, FILTSIZE) | ||
2 | % | ||
3 | % Compute maximum pyramid height for given image and filter sizes. | ||
4 | % Specifically: the number of corrDn operations that can be sequentially | ||
5 | % performed when subsampling by a factor of 2. | ||
6 | |||
7 | % Eero Simoncelli, 6/96. | ||
8 | |||
9 | function height = maxPyrHt(imsz, filtsz) | ||
10 | |||
11 | imsz = imsz(:); | ||
12 | filtsz = filtsz(:); | ||
13 | |||
14 | if any(imsz == 1) % 1D image | ||
15 | imsz = prod(imsz); | ||
16 | filtsz = prod(filtsz); | ||
17 | elseif any(filtsz == 1) % 2D image, 1D filter | ||
18 | filtsz = [filtsz(1); filtsz(1)]; | ||
19 | end | ||
20 | |||
21 | if any(imsz < filtsz) | ||
22 | height = 0; | ||
23 | else | ||
24 | height = 1 + maxPyrHt( floor(imsz/2), filtsz ); | ||
25 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/mccExcludedFiles.log b/SD-VBS/benchmarks/texture_synthesis/src/matlab/mccExcludedFiles.log deleted file mode 100755 index 2c5359b..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/mccExcludedFiles.log +++ /dev/null | |||
@@ -1,11 +0,0 @@ | |||
1 | This file contains the list of various toolbox functions that are not | ||
2 | included in the CTF file. An error will be thrown if any of these functions | ||
3 | are called at run-time. Some of these functions may be from toolboxes | ||
4 | that you are not using in your application. The reason for this is that | ||
5 | these toolboxes have overloaded some methods that are called by your code. | ||
6 | If you know which toolboxes are being used by your code, you can use the -p | ||
7 | flag with the -N flag to list these toolboxes explicitly. This will | ||
8 | cause MATLAB Compiler to only look for functions in the specified toolbox | ||
9 | directories in addition to the MATLAB directories. Refer to the MCC | ||
10 | documentation for more information on this. | ||
11 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/mean2.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/mean2.m deleted file mode 100755 index 177f7ac..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/mean2.m +++ /dev/null | |||
@@ -1,7 +0,0 @@ | |||
1 | % M = MEAN2(MTX) | ||
2 | % | ||
3 | % Sample mean of a matrix. | ||
4 | |||
5 | function res = mean2(mtx) | ||
6 | |||
7 | res = mean(mean(mtx)); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkAngle.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkAngle.m deleted file mode 100755 index bd54f8d..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkAngle.m +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | % IM = mkAngle(SIZE, PHASE, ORIGIN) | ||
2 | % | ||
3 | % Compute a matrix of dimension SIZE (a [Y X] 2-vector, or a scalar) | ||
4 | % containing samples of the polar angle (in radians, CW from the | ||
5 | % X-axis, ranging from -pi to pi), relative to angle PHASE (default = | ||
6 | % 0), about ORIGIN pixel (default = (size+1)/2). | ||
7 | |||
8 | % Eero Simoncelli, 6/96. | ||
9 | |||
10 | function [res] = mkAngle(sz, phase, origin) | ||
11 | |||
12 | sz = sz(:); | ||
13 | if (size(sz,1) == 1) | ||
14 | sz = [sz,sz]; | ||
15 | end | ||
16 | |||
17 | % ----------------------------------------------------------------- | ||
18 | % OPTIONAL args: | ||
19 | |||
20 | if (exist('origin') ~= 1) | ||
21 | origin = (sz+1)/2; | ||
22 | end | ||
23 | |||
24 | % ----------------------------------------------------------------- | ||
25 | |||
26 | [xramp,yramp] = meshgrid( [1:sz(2)]-origin(2), [1:sz(1)]-origin(1) ); | ||
27 | |||
28 | res = atan2(yramp,xramp); | ||
29 | |||
30 | if (exist('phase') == 1) | ||
31 | res = mod(res+(pi-phase),2*pi)-pi; | ||
32 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkAngularSine.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkAngularSine.m deleted file mode 100755 index f5238cc..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkAngularSine.m +++ /dev/null | |||
@@ -1,42 +0,0 @@ | |||
1 | % IM = mkAngularSine(SIZE, HARMONIC, AMPL, PHASE, ORIGIN) | ||
2 | % | ||
3 | % Make an angular sinusoidal image: | ||
4 | % AMPL * sin( HARMONIC*theta + PHASE), | ||
5 | % where theta is the angle about the origin. | ||
6 | % SIZE specifies the matrix size, as for zeros(). | ||
7 | % AMPL (default = 1) and PHASE (default = 0) are optional. | ||
8 | |||
9 | % Eero Simoncelli, 2/97. | ||
10 | |||
11 | function [res] = mkAngularSine(sz, harmonic, ampl, ph, origin) | ||
12 | |||
13 | sz = sz(:); | ||
14 | if (size(sz,1) == 1) | ||
15 | sz = [sz,sz]; | ||
16 | end | ||
17 | |||
18 | mxsz = max(sz(1),sz(2)); | ||
19 | |||
20 | %------------------------------------------------------------ | ||
21 | %% OPTIONAL ARGS: | ||
22 | |||
23 | if (exist('harmonic') ~= 1) | ||
24 | harmonic = 1; | ||
25 | end | ||
26 | |||
27 | if (exist('ampl') ~= 1) | ||
28 | ampl = 1; | ||
29 | end | ||
30 | |||
31 | if (exist('ph') ~= 1) | ||
32 | ph = 0; | ||
33 | end | ||
34 | |||
35 | if (exist('origin') ~= 1) | ||
36 | origin = (sz+1)/2; | ||
37 | end | ||
38 | |||
39 | %------------------------------------------------------------ | ||
40 | |||
41 | res = ampl * sin(harmonic*mkAngle(sz,ph,origin) + ph); | ||
42 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkDisc.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkDisc.m deleted file mode 100755 index 33e7d6d..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkDisc.m +++ /dev/null | |||
@@ -1,61 +0,0 @@ | |||
1 | % IM = mkDisc(SIZE, RADIUS, ORIGIN, TWIDTH, VALS) | ||
2 | % | ||
3 | % Make a "disk" image. SIZE specifies the matrix size, as for | ||
4 | % zeros(). RADIUS (default = min(size)/4) specifies the radius of | ||
5 | % the disk. ORIGIN (default = (size+1)/2) specifies the | ||
6 | % location of the disk center. TWIDTH (in pixels, default = 2) | ||
7 | % specifies the width over which a soft threshold transition is made. | ||
8 | % VALS (default = [0,1]) should be a 2-vector containing the | ||
9 | % intensity value inside and outside the disk. | ||
10 | |||
11 | % Eero Simoncelli, 6/96. | ||
12 | |||
13 | function [res] = mkDisc(sz, rad, origin, twidth, vals) | ||
14 | |||
15 | if (nargin < 1) | ||
16 | error('Must pass at least a size argument'); | ||
17 | end | ||
18 | |||
19 | sz = sz(:); | ||
20 | if (size(sz,1) == 1) | ||
21 | sz = [sz sz]; | ||
22 | end | ||
23 | |||
24 | %------------------------------------------------------------ | ||
25 | % OPTIONAL ARGS: | ||
26 | |||
27 | if (exist('rad') ~= 1) | ||
28 | rad = min(sz(1),sz(2))/4; | ||
29 | end | ||
30 | |||
31 | if (exist('origin') ~= 1) | ||
32 | origin = (sz+1)./2; | ||
33 | end | ||
34 | |||
35 | if (exist('twidth') ~= 1) | ||
36 | twidth = 2; | ||
37 | end | ||
38 | |||
39 | if (exist('vals') ~= 1) | ||
40 | vals = [1,0]; | ||
41 | end | ||
42 | |||
43 | %------------------------------------------------------------ | ||
44 | |||
45 | res = mkR(sz,1,origin); | ||
46 | |||
47 | if (abs(twidth) < realmin) | ||
48 | res = vals(2) + (vals(1) - vals(2)) * (res <= rad); | ||
49 | else | ||
50 | [Xtbl,Ytbl] = rcosFn(twidth, rad, [vals(1), vals(2)]); | ||
51 | res = pointOp(res, Ytbl, Xtbl(1), Xtbl(2)-Xtbl(1), 0); | ||
52 | % | ||
53 | % OLD interp1 VERSION: | ||
54 | % res = res(:); | ||
55 | % Xtbl(1) = min(res); | ||
56 | % Xtbl(size(Xtbl,2)) = max(res); | ||
57 | % res = reshape(interp1(Xtbl,Ytbl,res), sz(1), sz(2)); | ||
58 | % | ||
59 | end | ||
60 | |||
61 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkFract.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkFract.m deleted file mode 100755 index af95cd5..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkFract.m +++ /dev/null | |||
@@ -1,36 +0,0 @@ | |||
1 | % IM = mkFract(SIZE, FRACT_DIM) | ||
2 | % | ||
3 | % Make a matrix of dimensions SIZE (a [Y X] 2-vector, or a scalar) | ||
4 | % containing fractal (pink) noise with power spectral density of the | ||
5 | % form: 1/f^(5-2*FRACT_DIM). Image variance is normalized to 1.0. | ||
6 | % FRACT_DIM defaults to 1.0 | ||
7 | |||
8 | % Eero Simoncelli, 6/96. | ||
9 | |||
10 | %% TODO: Verify that this matches Mandelbrot defn of fractal dimension. | ||
11 | %% Make this more efficient! | ||
12 | |||
13 | function res = mkFract(dims, fract_dim) | ||
14 | |||
15 | if (exist('fract_dim') ~= 1) | ||
16 | fract_dim = 1.0; | ||
17 | end | ||
18 | |||
19 | res = randn(dims); | ||
20 | fres = fft2(res); | ||
21 | |||
22 | sz = size(res); | ||
23 | ctr = ceil((sz+1)./2); | ||
24 | |||
25 | shape = ifftshift(mkR(sz, -(2.5-fract_dim), ctr)); | ||
26 | shape(1,1) = 1; %%DC term | ||
27 | |||
28 | fres = shape .* fres; | ||
29 | fres = ifft2(fres); | ||
30 | |||
31 | if (max(max(abs(imag(fres)))) > 1e-10) | ||
32 | error('Symmetry error in creating fractal'); | ||
33 | else | ||
34 | res = real(fres); | ||
35 | res = res / sqrt(var2(res)); | ||
36 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkGaussian.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkGaussian.m deleted file mode 100755 index fa8a554..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkGaussian.m +++ /dev/null | |||
@@ -1,58 +0,0 @@ | |||
1 | % IM = mkGaussian(SIZE, COVARIANCE, MEAN, AMPLITUDE) | ||
2 | % | ||
3 | % Compute a matrix with dimensions SIZE (a [Y X] 2-vector, or a | ||
4 | % scalar) containing a Gaussian function, centered at pixel position | ||
5 | % specified by MEAN (default = (size+1)/2), with given COVARIANCE (can | ||
6 | % be a scalar, 2-vector, or 2x2 matrix. Default = (min(size)/6)^2), | ||
7 | % and AMPLITUDE. AMPLITUDE='norm' (default) will produce a | ||
8 | % probability-normalized function. All but the first argument are | ||
9 | % optional. | ||
10 | |||
11 | % Eero Simoncelli, 6/96. | ||
12 | |||
13 | function [res] = mkGaussian(sz, cov, mn, ampl) | ||
14 | |||
15 | sz = sz(:); | ||
16 | if (size(sz,1) == 1) | ||
17 | sz = [sz,sz]; | ||
18 | end | ||
19 | |||
20 | %------------------------------------------------------------ | ||
21 | %% OPTIONAL ARGS: | ||
22 | |||
23 | if (exist('cov') ~= 1) | ||
24 | cov = (min(sz(1),sz(2))/6)^2; | ||
25 | end | ||
26 | |||
27 | if (exist('mn') ~= 1) | ||
28 | mn = (sz+1)/2; | ||
29 | end | ||
30 | |||
31 | if (exist('ampl') ~= 1) | ||
32 | ampl = 'norm'; | ||
33 | end | ||
34 | |||
35 | %------------------------------------------------------------ | ||
36 | |||
37 | [xramp,yramp] = meshgrid([1:sz(2)]-mn(2),[1:sz(1)]-mn(1)); | ||
38 | |||
39 | if (sum(size(cov)) == 2) % scalar | ||
40 | if (strcmp(ampl,'norm')) | ||
41 | ampl = 1/(2*pi*cov(1)); | ||
42 | end | ||
43 | e = (xramp.^2 + yramp.^2)/(-2 * cov); | ||
44 | elseif (sum(size(cov)) == 3) % a 2-vector | ||
45 | if (strcmp(ampl,'norm')) | ||
46 | ampl = 1/(2*pi*sqrt(cov(1)*cov(2))); | ||
47 | end | ||
48 | e = xramp.^2/(-2 * cov(2)) + yramp.^2/(-2 * cov(1)); | ||
49 | else | ||
50 | if (strcmp(ampl,'norm')) | ||
51 | ampl = 1/(2*pi*sqrt(det(cov))); | ||
52 | end | ||
53 | cov = -inv(cov)/2; | ||
54 | e = cov(2,2)*xramp.^2 + (cov(1,2)+cov(2,1))*(xramp.*yramp) ... | ||
55 | + cov(1,1)*yramp.^2; | ||
56 | end | ||
57 | |||
58 | res = ampl .* exp(e); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkImpulse.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkImpulse.m deleted file mode 100755 index 9844ee8..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkImpulse.m +++ /dev/null | |||
@@ -1,25 +0,0 @@ | |||
1 | % IM = mkImpulse(SIZE, ORIGIN, AMPLITUDE) | ||
2 | % | ||
3 | % Compute a matrix of dimension SIZE (a [Y X] 2-vector, or a scalar) | ||
4 | % containing a single non-zero entry, at position ORIGIN (defaults to | ||
5 | % ceil(size/2)), of value AMPLITUDE (defaults to 1). | ||
6 | |||
7 | % Eero Simoncelli, 6/96. | ||
8 | |||
9 | function [res] = mkImpulse(sz, origin, amplitude) | ||
10 | |||
11 | sz = sz(:)'; | ||
12 | if (size(sz,2) == 1) | ||
13 | sz = [sz sz]; | ||
14 | end | ||
15 | |||
16 | if (exist('origin') ~= 1) | ||
17 | origin = ceil(sz/2); | ||
18 | end | ||
19 | |||
20 | if (exist('amplitude') ~= 1) | ||
21 | amplitude = 1; | ||
22 | end | ||
23 | |||
24 | res = zeros(sz); | ||
25 | res(origin(1),origin(2)) = amplitude; | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkR.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkR.m deleted file mode 100755 index a1e8448..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkR.m +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | % IM = mkR(SIZE, EXPT, ORIGIN) | ||
2 | % | ||
3 | % Compute a matrix of dimension SIZE (a [Y X] 2-vector, or a scalar) | ||
4 | % containing samples of a radial ramp function, raised to power EXPT | ||
5 | % (default = 1), with given ORIGIN (default = (size+1)/2, [1 1] = | ||
6 | % upper left). All but the first argument are optional. | ||
7 | |||
8 | % Eero Simoncelli, 6/96. | ||
9 | |||
10 | function [res] = mkR(sz, expt, origin) | ||
11 | |||
12 | sz = sz(:); | ||
13 | if (size(sz,1) == 1) | ||
14 | sz = [sz,sz]; | ||
15 | end | ||
16 | |||
17 | % ----------------------------------------------------------------- | ||
18 | % OPTIONAL args: | ||
19 | |||
20 | if (exist('expt') ~= 1) | ||
21 | expt = 1; | ||
22 | end | ||
23 | |||
24 | if (exist('origin') ~= 1) | ||
25 | origin = (sz+1)/2; | ||
26 | end | ||
27 | |||
28 | % ----------------------------------------------------------------- | ||
29 | |||
30 | [xramp,yramp] = meshgrid( [1:sz(2)]-origin(2), [1:sz(1)]-origin(1) ); | ||
31 | |||
32 | res = (xramp.^2 + yramp.^2).^(expt/2); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkRamp.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkRamp.m deleted file mode 100755 index dd37164..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkRamp.m +++ /dev/null | |||
@@ -1,47 +0,0 @@ | |||
1 | % IM = mkRamp(SIZE, DIRECTION, SLOPE, INTERCEPT, ORIGIN) | ||
2 | % | ||
3 | % Compute a matrix of dimension SIZE (a [Y X] 2-vector, or a scalar) | ||
4 | % containing samples of a ramp function, with given gradient DIRECTION | ||
5 | % (radians, CW from X-axis, default = 0), SLOPE (per pixel, default = | ||
6 | % 1), and a value of INTERCEPT (default = 0) at the ORIGIN (default = | ||
7 | % (size+1)/2, [1 1] = upper left). All but the first argument are | ||
8 | % optional. | ||
9 | |||
10 | % Eero Simoncelli, 6/96. 2/97: adjusted coordinate system. | ||
11 | |||
12 | function [res] = mkRamp(sz, dir, slope, intercept, origin) | ||
13 | |||
14 | sz = sz(:); | ||
15 | if (size(sz,1) == 1) | ||
16 | sz = [sz,sz]; | ||
17 | end | ||
18 | |||
19 | % ----------------------------------------------------------------- | ||
20 | % OPTIONAL args: | ||
21 | |||
22 | if (exist('dir') ~= 1) | ||
23 | dir = 0; | ||
24 | end | ||
25 | |||
26 | if (exist('slope') ~= 1) | ||
27 | slope = 1; | ||
28 | end | ||
29 | |||
30 | if (exist('intercept') ~= 1) | ||
31 | intercept = 0; | ||
32 | end | ||
33 | |||
34 | if (exist('origin') ~= 1) | ||
35 | origin = (sz+1)/2; | ||
36 | end | ||
37 | |||
38 | % ----------------------------------------------------------------- | ||
39 | |||
40 | xinc = slope*cos(dir); | ||
41 | yinc = slope*sin(dir); | ||
42 | |||
43 | [xramp,yramp] = meshgrid( xinc*([1:sz(2)]-origin(2)), ... | ||
44 | yinc*([1:sz(1)]-origin(1)) ); | ||
45 | |||
46 | res = intercept + xramp + yramp; | ||
47 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkSine.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkSine.m deleted file mode 100755 index 147eb01..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkSine.m +++ /dev/null | |||
@@ -1,67 +0,0 @@ | |||
1 | % IM = mkSine(SIZE, PERIOD, DIRECTION, AMPLITUDE, PHASE, ORIGIN) | ||
2 | % or | ||
3 | % IM = mkSine(SIZE, FREQ, AMPLITUDE, PHASE, ORIGIN) | ||
4 | % | ||
5 | % Compute a matrix of dimension SIZE (a [Y X] 2-vector, or a scalar) | ||
6 | % containing samples of a 2D sinusoid, with given PERIOD (in pixels), | ||
7 | % DIRECTION (radians, CW from X-axis, default = 0), AMPLITUDE (default | ||
8 | % = 1), and PHASE (radians, relative to ORIGIN, default = 0). ORIGIN | ||
9 | % defaults to the center of the image. | ||
10 | % | ||
11 | % In the second form, FREQ is a 2-vector of frequencies (radians/pixel). | ||
12 | |||
13 | % Eero Simoncelli, 6/96. | ||
14 | |||
15 | function [res] = mkSine(sz, per_freq, dir_amp, amp_phase, phase_orig, orig) | ||
16 | |||
17 | %------------------------------------------------------------ | ||
18 | %% OPTIONAL ARGS: | ||
19 | |||
20 | if (prod(size(per_freq)) == 2) | ||
21 | frequency = norm(per_freq); | ||
22 | direction = atan2(per_freq(1),per_freq(2)); | ||
23 | if (exist('dir_amp') == 1) | ||
24 | amplitude = dir_amp; | ||
25 | else | ||
26 | amplitude = 1; | ||
27 | end | ||
28 | if (exist('amp_phase') == 1) | ||
29 | phase = amp_phase; | ||
30 | else | ||
31 | phase = 0; | ||
32 | end | ||
33 | if (exist('phase_orig') == 1) | ||
34 | origin = phase_orig; | ||
35 | end | ||
36 | if (exist('orig') == 1) | ||
37 | error('Too many arguments for (second form) of mkSine'); | ||
38 | end | ||
39 | else | ||
40 | frequency = 2*pi/per_freq; | ||
41 | if (exist('dir_amp') == 1) | ||
42 | direction = dir_amp; | ||
43 | else | ||
44 | direction = 0; | ||
45 | end | ||
46 | if (exist('amp_phase') == 1) | ||
47 | amplitude = amp_phase; | ||
48 | else | ||
49 | amplitude = 1; | ||
50 | end | ||
51 | if (exist('phase_orig') == 1) | ||
52 | phase = phase_orig; | ||
53 | else | ||
54 | phase = 0; | ||
55 | end | ||
56 | if (exist('orig') == 1) | ||
57 | origin = orig; | ||
58 | end | ||
59 | end | ||
60 | |||
61 | %------------------------------------------------------------ | ||
62 | |||
63 | if (exist('origin') == 1) | ||
64 | res = amplitude*sin(mkRamp(sz, direction, frequency, phase, origin)); | ||
65 | else | ||
66 | res = amplitude*sin(mkRamp(sz, direction, frequency, phase)); | ||
67 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkSquare.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkSquare.m deleted file mode 100755 index 84ef466..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkSquare.m +++ /dev/null | |||
@@ -1,89 +0,0 @@ | |||
1 | % IM = mkSquare(SIZE, PERIOD, DIRECTION, AMPLITUDE, PHASE, ORIGIN, TWIDTH) | ||
2 | % or | ||
3 | % IM = mkSine(SIZE, FREQ, AMPLITUDE, PHASE, ORIGIN, TWIDTH) | ||
4 | % | ||
5 | % Compute a matrix of dimension SIZE (a [Y X] 2-vector, or a scalar) | ||
6 | % containing samples of a 2D square wave, with given PERIOD (in | ||
7 | % pixels), DIRECTION (radians, CW from X-axis, default = 0), AMPLITUDE | ||
8 | % (default = 1), and PHASE (radians, relative to ORIGIN, default = 0). | ||
9 | % ORIGIN defaults to the center of the image. TWIDTH specifies width | ||
10 | % of raised-cosine edges on the bars of the grating (default = | ||
11 | % min(2,period/3)). | ||
12 | % | ||
13 | % In the second form, FREQ is a 2-vector of frequencies (radians/pixel). | ||
14 | |||
15 | % Eero Simoncelli, 6/96. | ||
16 | |||
17 | % TODO: Add duty cycle. | ||
18 | |||
19 | function [res] = mkSquare(sz, per_freq, dir_amp, amp_phase, phase_orig, orig_twidth, twidth) | ||
20 | |||
21 | %------------------------------------------------------------ | ||
22 | %% OPTIONAL ARGS: | ||
23 | |||
24 | if (prod(size(per_freq)) == 2) | ||
25 | frequency = norm(per_freq); | ||
26 | direction = atan2(per_freq(1),per_freq(2)); | ||
27 | if (exist('dir_amp') == 1) | ||
28 | amplitude = dir_amp; | ||
29 | else | ||
30 | amplitude = 1; | ||
31 | end | ||
32 | if (exist('amp_phase') == 1) | ||
33 | phase = amp_phase; | ||
34 | else | ||
35 | phase = 0; | ||
36 | end | ||
37 | if (exist('phase_orig') == 1) | ||
38 | origin = phase_orig; | ||
39 | end | ||
40 | if (exist('orig_twidth') == 1) | ||
41 | transition = orig_twidth; | ||
42 | else | ||
43 | transition = min(2,2*pi/(3*frequency)); | ||
44 | end | ||
45 | if (exist('twidth') == 1) | ||
46 | error('Too many arguments for (second form) of mkSine'); | ||
47 | end | ||
48 | else | ||
49 | frequency = 2*pi/per_freq; | ||
50 | if (exist('dir_amp') == 1) | ||
51 | direction = dir_amp; | ||
52 | else | ||
53 | direction = 0; | ||
54 | end | ||
55 | if (exist('amp_phase') == 1) | ||
56 | amplitude = amp_phase; | ||
57 | else | ||
58 | amplitude = 1; | ||
59 | end | ||
60 | if (exist('phase_orig') == 1) | ||
61 | phase = phase_orig; | ||
62 | else | ||
63 | phase = 0; | ||
64 | end | ||
65 | if (exist('orig_twidth') == 1) | ||
66 | origin = orig_twidth; | ||
67 | end | ||
68 | if (exist('twidth') == 1) | ||
69 | transition = twidth; | ||
70 | else | ||
71 | transition = min(2,2*pi/(3*frequency)); | ||
72 | end | ||
73 | |||
74 | end | ||
75 | |||
76 | %------------------------------------------------------------ | ||
77 | |||
78 | if (exist('origin') == 1) | ||
79 | res = mkRamp(sz, direction, frequency, phase, origin) - pi/2; | ||
80 | else | ||
81 | res = mkRamp(sz, direction, frequency, phase) - pi/2; | ||
82 | end | ||
83 | |||
84 | [Xtbl,Ytbl] = rcosFn(transition*frequency,pi/2,[-amplitude amplitude]); | ||
85 | |||
86 | res = pointOp(abs(mod(res+pi, 2*pi)-pi),Ytbl,Xtbl(1),Xtbl(2)-Xtbl(1),0); | ||
87 | |||
88 | % OLD threshold version: | ||
89 | %res = amplitude * (mod(res,2*pi) < pi); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkZonePlate.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkZonePlate.m deleted file mode 100755 index 2b6a4a5..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkZonePlate.m +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | % IM = mkZonePlate(SIZE, AMPL, PHASE) | ||
2 | % | ||
3 | % Make a "zone plate" image: | ||
4 | % AMPL * cos( r^2 + PHASE) | ||
5 | % SIZE specifies the matrix size, as for zeros(). | ||
6 | % AMPL (default = 1) and PHASE (default = 0) are optional. | ||
7 | |||
8 | % Eero Simoncelli, 6/96. | ||
9 | |||
10 | function [res] = mkZonePlate(sz, ampl, ph) | ||
11 | |||
12 | sz = sz(:); | ||
13 | if (size(sz,1) == 1) | ||
14 | sz = [sz,sz]; | ||
15 | end | ||
16 | |||
17 | mxsz = max(sz(1),sz(2)); | ||
18 | |||
19 | %------------------------------------------------------------ | ||
20 | %% OPTIONAL ARGS: | ||
21 | |||
22 | if (exist('ampl') ~= 1) | ||
23 | ampl = 1; | ||
24 | end | ||
25 | |||
26 | if (exist('ph') ~= 1) | ||
27 | ph = 0; | ||
28 | end | ||
29 | |||
30 | %------------------------------------------------------------ | ||
31 | |||
32 | res = ampl * cos( (pi/mxsz) * mkR(sz,2) + ph ); | ||
33 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/mod.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/mod.m deleted file mode 100755 index 21167e5..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/mod.m +++ /dev/null | |||
@@ -1,14 +0,0 @@ | |||
1 | % M = mod(A,B) | ||
2 | % | ||
3 | % Modulus operator: returns A mod B. | ||
4 | % Works on matrics, vectors or scalars. | ||
5 | % | ||
6 | % NOTE: This function is a Matlab-5 builtin, but was missing from Matlab-4. | ||
7 | |||
8 | % Eero Simoncelli, 7/96. | ||
9 | |||
10 | function m = mod(a,n) | ||
11 | |||
12 | m = a - n .* floor(a./n); | ||
13 | return; | ||
14 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/modacor22.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/modacor22.m deleted file mode 100755 index 89c8d52..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/modacor22.m +++ /dev/null | |||
@@ -1,127 +0,0 @@ | |||
1 | function [Y,snrV,Chf]=modacor22(X,Cy,p); | ||
2 | |||
3 | % It imposes the desired autocorrelation in the given (central) samples (Cy) to | ||
4 | % an image X, convolving it with an even filter of size(Cy), in such a way | ||
5 | % that the image containts change as less as possible, in a LSE sense. | ||
6 | % [Y,snr,Chf]=modacor22(X,Cy,p); | ||
7 | % Chf: Fourier transform of the filter that forces the autocorrelation | ||
8 | % p [OPTIONAL]: mixing proportion between Cx and Cy | ||
9 | % it imposes (1-p)*Cx + p*Cy, | ||
10 | % being Cx the actual autocorrelation. | ||
11 | % DEFAULT: p = 1; | ||
12 | |||
13 | % JPM, 10/97, working with EPS, NYU | ||
14 | |||
15 | Warn = 0; % Set to 1 if you want to see warning messages | ||
16 | if (exist('p') ~= 1) | ||
17 | p = 1; | ||
18 | end | ||
19 | |||
20 | % Compute the autocorrelation function of the original image | ||
21 | |||
22 | [Ny,Nx]=size(X); | ||
23 | Nc=size(Cy,1); % Normally Nc<<Nx, only the low indices of the autocorrelation | ||
24 | if (2*Nc-1 > Nx) & Warn | ||
25 | warning('Autocorrelation neighborhood too large for image: reducing'); | ||
26 | Nc = 2*floor(Nx/4)-1; | ||
27 | first = (size(Cy,1)-Nc)/2; | ||
28 | Cy = Cy(first+1:first+Nc, first+1:first+Nc); | ||
29 | end | ||
30 | |||
31 | Xf=fft2(X); | ||
32 | Xf2=abs(Xf).^2; | ||
33 | Cx=fftshift(real(ifft2(Xf2)))/(2-isreal(X)); | ||
34 | Cy=Cy*prod(size(X)); % Unnormalize the previously normalized correlation | ||
35 | |||
36 | cy=Ny/2+1; | ||
37 | cx=Nx/2+1; | ||
38 | Lc=(Nc-1)/2; | ||
39 | Cy0 = Cy; | ||
40 | Cy = p*Cy + (1-p)*Cx(cy-Lc:cy+Lc,cx-Lc:cx+Lc); | ||
41 | |||
42 | % Compare the actual correlation with the desired one | ||
43 | %imStats(Cx(cy-Lc:cy+Lc,cx-Lc:cx+Lc),Cy) | ||
44 | snrV=10*log10(sum(sum(Cy0.^2))/sum(sum((Cy0-Cx(cy-Lc:cy+Lc,cx-Lc:cx+Lc)).^2))); | ||
45 | |||
46 | % Take just the part that has influence on the samples of Cy (Cy=conv(Cx,Ch)) | ||
47 | Cx=Cx(cy-2*Lc:cy+2*Lc,cx-2*Lc:cx+2*Lc); | ||
48 | |||
49 | % Build the matrix that performs the convolution Cy1=Tcx*Ch1 | ||
50 | |||
51 | Ncx=4*Lc+1; | ||
52 | M=(Nc^2+1)/2; | ||
53 | Tcx=zeros(M); | ||
54 | |||
55 | for i=Lc+1:2*Lc, | ||
56 | for j=Lc+1:3*Lc+1, | ||
57 | nm=(i-Lc-1)*(2*Lc+1)+j-Lc; | ||
58 | ccx=Cx(i-Lc:i+Lc,j-Lc:j+Lc); | ||
59 | ccxi=ccx(2*Lc+1:-1:1,2*Lc+1:-1:1); | ||
60 | ccx=ccx+ccxi; | ||
61 | ccx(Lc+1,Lc+1)=ccx(Lc+1,Lc+1)/2; | ||
62 | ccx=vector(ccx'); | ||
63 | Tcx(nm,:)=ccx(1:M)'; | ||
64 | end | ||
65 | end | ||
66 | i=2*Lc+1; | ||
67 | for j=Lc+1:2*Lc+1, | ||
68 | nm=(i-Lc-1)*(2*Lc+1)+j-Lc; | ||
69 | ccx=Cx(i-Lc:i+Lc,j-Lc:j+Lc); | ||
70 | ccxi=ccx(2*Lc+1:-1:1,2*Lc+1:-1:1); | ||
71 | ccx=ccx+ccxi; | ||
72 | ccx(Lc+1,Lc+1)=ccx(Lc+1,Lc+1)/2; | ||
73 | ccx=vector(ccx'); | ||
74 | Tcx(nm,:)=ccx(1:M)'; | ||
75 | end | ||
76 | |||
77 | % Rearrange Cy indices and solve the equation | ||
78 | |||
79 | Cy1=vector(Cy'); | ||
80 | Cy1=Cy1(1:M); | ||
81 | |||
82 | Ch1=inv(Tcx)*Cy1; | ||
83 | |||
84 | % Rearrange Ch1 | ||
85 | |||
86 | Ch1=[Ch1;Ch1(length(Cy1)-1:-1:1)]; | ||
87 | Ch=reshape(Ch1,Nc,Nc)'; | ||
88 | |||
89 | % Compute H from Ch (H is zero-phase) through the DFT | ||
90 | |||
91 | %s=2^(ceil(log(Nc)/log(2))+1); | ||
92 | %H=sqrt(abs(fft2(Ch,s,s))); | ||
93 | %h=fftshift(real(ifft2(H))); | ||
94 | %h=h(s/2+1-Lc:s/2+1+Lc,s/2+1-Lc:s/2+1+Lc); | ||
95 | %%plot(Ch);drawnow | ||
96 | %h=recphase(Ch); | ||
97 | |||
98 | % Compute Y as conv(X,H) in the Fourier domain | ||
99 | |||
100 | %%Y=real(ifft2(Xf.*H)); | ||
101 | %Y=real(ifft2(Xf.*sqrt(abs(fft2(Ch,Ny,Nx))))); | ||
102 | aux=zeros(Ny,Nx); | ||
103 | aux(cy-Lc:cy+Lc,cx-Lc:cx+Lc)=Ch; | ||
104 | Ch=fftshift(aux); | ||
105 | Chf=real(fft2(Ch)); | ||
106 | %Chf=fft2(Ch,Ny,Nx); | ||
107 | %figure(7);plot(Chf);drawnow; | ||
108 | Yf=Xf.*sqrt(abs(Chf)); | ||
109 | Y=ifft2(Yf); | ||
110 | %Y=cconv2(X,h); | ||
111 | |||
112 | % Checks the fidelity of the imposition | ||
113 | |||
114 | %Cy2=fftshift(real(ifft2(Xf2.*abs(Chf))))/(2-isreal(X)); | ||
115 | %Cy2=Cy2(cy-Lc:cy+Lc,cx-Lc:cx+Lc); | ||
116 | %imStats(Cy,Cy2) | ||
117 | %imStats(X,Y) | ||
118 | |||
119 | %Yf2=abs(Yf).^2; | ||
120 | %Cy3=fftshift(real(ifft2(Yf2)))/2; | ||
121 | |||
122 | %Cy3=Cy3(cy-Lc:cy+Lc,cx-Lc:cx+Lc); | ||
123 | %snr(Cy,Cy-Cy3) | ||
124 | %imStats(Cy,Cy3) | ||
125 | |||
126 | |||
127 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/modkurt.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/modkurt.m deleted file mode 100755 index e144d32..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/modkurt.m +++ /dev/null | |||
@@ -1,172 +0,0 @@ | |||
1 | function [chm, snrk] = modkurt(ch,k,p); | ||
2 | |||
3 | % Modify the kurtosis in one step, by moving in gradient direction until | ||
4 | % reaching the desired kurtosis value. | ||
5 | % It does not affect the mean nor the variance, but it affects the skewness. | ||
6 | % This operation is not an orthogonal projection, but the projection angle is | ||
7 | % near pi/2 when k is close to the original kurtosis, which is a realistic assumption | ||
8 | % when doing iterative projections in a pyramid, for example (small corrections | ||
9 | % to the channels' statistics). | ||
10 | % | ||
11 | % [chm, snrk] = modkurt(ch,k,p); | ||
12 | % ch: channel | ||
13 | % k: desired kurtosis (k=M4/M2^2) | ||
14 | % p [OPTIONAL]: mixing proportion between k0 and k | ||
15 | % it imposes (1-p)*k0 + p*k, | ||
16 | % being k0 the current kurtosis. | ||
17 | % DEFAULT: p = 1; | ||
18 | |||
19 | |||
20 | % Javier Portilla, Oct.12/97, NYU | ||
21 | |||
22 | Warn = 0; % Set to 1 if you want to see warning messages | ||
23 | if ~exist('p'), | ||
24 | p = 1; | ||
25 | end | ||
26 | |||
27 | me=mean2(ch); | ||
28 | ch=ch-me; | ||
29 | |||
30 | % Compute the moments | ||
31 | |||
32 | m=zeros(12,1); | ||
33 | for n=2:12, | ||
34 | m(n)=mean2(ch.^n); | ||
35 | end | ||
36 | |||
37 | % The original kurtosis | ||
38 | |||
39 | k0=m(4)/m(2)^2; | ||
40 | snrk = snr(k, k-k0); | ||
41 | if snrk > 60, | ||
42 | chm = ch+me; | ||
43 | return | ||
44 | end | ||
45 | k = k0*(1-p) + k*p; | ||
46 | |||
47 | % Some auxiliar variables | ||
48 | |||
49 | a=m(4)/m(2); | ||
50 | |||
51 | % Coeficients of the numerator (A*lam^4+B*lam^3+C*lam^2+D*lam+E) | ||
52 | |||
53 | A=m(12)-4*a*m(10)-4*m(3)*m(9)+6*a^2*m(8)+12*a*m(3)*m(7)+6*m(3)^2*m(6)-... | ||
54 | 4*a^3*m(6)-12*a^2*m(3)*m(5)+a^4*m(4)-12*a*m(3)^2*m(4)+... | ||
55 | 4*a^3*m(3)^2+6*a^2*m(3)^2*m(2)-3*m(3)^4; | ||
56 | B=4*(m(10)-3*a*m(8)-3*m(3)*m(7)+3*a^2*m(6)+6*a*m(3)*m(5)+3*m(3)^2*m(4)-... | ||
57 | a^3*m(4)-3*a^2*m(3)^2-3*m(4)*m(3)^2); | ||
58 | C=6*(m(8)-2*a*m(6)-2*m(3)*m(5)+a^2*m(4)+2*a*m(3)^2+m(3)^2*m(2)); | ||
59 | D=4*(m(6)-a^2*m(2)-m(3)^2); | ||
60 | E=m(4); | ||
61 | |||
62 | % Define the coefficients of the denominator (F*lam^2+G)^2 | ||
63 | |||
64 | F=D/4; | ||
65 | G=m(2); | ||
66 | |||
67 | % test | ||
68 | test = 0; | ||
69 | |||
70 | if test, | ||
71 | |||
72 | grd = ch.^3 - a*ch - m(3); | ||
73 | lam = -0.001:0.00001:0.001; | ||
74 | k = (A*lam.^4+B*lam.^3+C*lam.^2+D*lam+E)./... | ||
75 | (F*lam.^2 + G).^2; | ||
76 | for lam = -0.001:0.00001:0.001, | ||
77 | n = lam*100000+101; | ||
78 | chp = ch + lam*grd; | ||
79 | k2(n) = mean2(chp.^4)/mean2(chp.^2)^2; | ||
80 | %k2(n) = mean2(chp.^4); | ||
81 | end | ||
82 | lam = -0.001:0.00001:0.001; | ||
83 | snr(k2, k-k2) | ||
84 | |||
85 | end % test | ||
86 | |||
87 | % Now I compute its derivative with respect to lambda | ||
88 | % (only the roots of derivative = 0 ) | ||
89 | |||
90 | d(1) = B*F; | ||
91 | d(2) = 2*C*F - 4*A*G; | ||
92 | d(3) = 4*F*D -3*B*G - D*F; | ||
93 | d(4) = 4*F*E - 2*C*G; | ||
94 | d(5) = -D*G; | ||
95 | |||
96 | mMlambda = roots(d); | ||
97 | |||
98 | tg = imag(mMlambda)./real(mMlambda); | ||
99 | mMlambda = mMlambda(find(abs(tg)<1e-6)); | ||
100 | lNeg = mMlambda(find(mMlambda<0)); | ||
101 | if length(lNeg)==0, | ||
102 | lNeg = -1/eps; | ||
103 | end | ||
104 | lPos = mMlambda(find(mMlambda>=0)); | ||
105 | if length(lPos)==0, | ||
106 | lPos = 1/eps; | ||
107 | end | ||
108 | lmi = max(lNeg); | ||
109 | lma = min(lPos); | ||
110 | |||
111 | lam = [lmi lma]; | ||
112 | mMnewKt = polyval([A B C D E],lam)./(polyval([F 0 G],lam)).^2; | ||
113 | kmin = min(mMnewKt); | ||
114 | kmax = max(mMnewKt); | ||
115 | |||
116 | % Given a desired kurtosis, solves for lambda | ||
117 | |||
118 | if k<=kmin & Warn, | ||
119 | lam = lmi; | ||
120 | warning('Saturating (down) kurtosis!'); | ||
121 | kmin | ||
122 | elseif k>=kmax & Warn, | ||
123 | lam = lma; | ||
124 | warning('Saturating (up) kurtosis!'); | ||
125 | kmax | ||
126 | else | ||
127 | |||
128 | % Coeficients of the algebraic equation | ||
129 | |||
130 | c0 = E - k*G^2; | ||
131 | c1 = D; | ||
132 | c2 = C - 2*k*F*G; | ||
133 | c3 = B; | ||
134 | c4 = A - k*F^2; | ||
135 | |||
136 | % Solves the equation | ||
137 | |||
138 | r=roots([c4 c3 c2 c1 c0]); | ||
139 | |||
140 | % Chose the real solution with minimum absolute value with the rigth sign | ||
141 | |||
142 | tg = imag(r)./real(r); | ||
143 | %lambda = real(r(find(abs(tg)<1e-6))); | ||
144 | lambda = real(r(find(abs(tg)==0))); | ||
145 | if length(lambda)>0, | ||
146 | lam = lambda(find(abs(lambda)==min(abs(lambda)))); | ||
147 | lam = lam(1); | ||
148 | else | ||
149 | lam = 0; | ||
150 | end | ||
151 | |||
152 | end % if ... else | ||
153 | |||
154 | |||
155 | % Modify the channel | ||
156 | |||
157 | chm=ch+lam*(ch.^3-a*ch-m(3)); % adjust the kurtosis | ||
158 | chm=chm*sqrt(m(2)/mean2(chm.^2)); % adjust the variance | ||
159 | chm=chm+me; % adjust the mean | ||
160 | |||
161 | % Check the result | ||
162 | %k2=mean2((chm-me).^4)/(mean2((chm-me).^2))^2; | ||
163 | %SNR=snr(k,k-k2) | ||
164 | |||
165 | |||
166 | |||
167 | |||
168 | |||
169 | |||
170 | |||
171 | |||
172 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/modskew.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/modskew.m deleted file mode 100755 index 3de0e3c..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/modskew.m +++ /dev/null | |||
@@ -1,183 +0,0 @@ | |||
1 | function [chm, snrk] = modskew(ch,sk,p); | ||
2 | |||
3 | % Adjust the sample skewness of a vector/matrix, using gradient projection, | ||
4 | % without affecting its sample mean and variance. | ||
5 | % | ||
6 | % This operation is not an orthogonal projection, but the projection angle is | ||
7 | % near pi/2 when sk is close to the original skewness, which is a realistic | ||
8 | % assumption when doing iterative projections in a pyramid, for example | ||
9 | % (small corrections to the channels' statistics). | ||
10 | % | ||
11 | % [xm, snrk] = modskew(x,sk,p); | ||
12 | % sk: new skweness | ||
13 | % p [OPTIONAL]: mixing proportion between sk0 and sk | ||
14 | % it imposes (1-p)*sk0 + p*sk, | ||
15 | % being sk0 the current skewness. | ||
16 | % DEFAULT: p = 1; | ||
17 | |||
18 | % | ||
19 | % JPM. 2/98, IODV, CSIC | ||
20 | % 4/00, CNS, NYU | ||
21 | |||
22 | Warn = 0; % Set to 1 if you want to see warning messages | ||
23 | if ~exist('p'), | ||
24 | p = 1; | ||
25 | end | ||
26 | |||
27 | N=prod(size(ch)); % number of samples | ||
28 | me=mean2(ch); | ||
29 | ch=ch-me; | ||
30 | |||
31 | for n=2:6, | ||
32 | m(n)=mean2(ch.^n); | ||
33 | end | ||
34 | |||
35 | sd=sqrt(m(2)); % standard deviation | ||
36 | s=m(3)/sd^3; % original skewness | ||
37 | snrk = snr(sk, sk-s); | ||
38 | sk = s*(1-p) + sk*p; | ||
39 | |||
40 | % Define the coefficients of the numerator (A*lam^3+B*lam^2+C*lam+D) | ||
41 | |||
42 | A=m(6)-3*sd*s*m(5)+3*sd^2*(s^2-1)*m(4)+sd^6*(2+3*s^2-s^4); | ||
43 | B=3*(m(5)-2*sd*s*m(4)+sd^5*s^3); | ||
44 | C=3*(m(4)-sd^4*(1+s^2)); | ||
45 | D=s*sd^3; | ||
46 | |||
47 | a(7)=A^2; | ||
48 | a(6)=2*A*B; | ||
49 | a(5)=B^2+2*A*C; | ||
50 | a(4)=2*(A*D+B*C); | ||
51 | a(3)=C^2+2*B*D; | ||
52 | a(2)=2*C*D; | ||
53 | a(1)=D^2; | ||
54 | |||
55 | % Define the coefficients of the denominator (A2+B2*lam^2) | ||
56 | |||
57 | A2=sd^2; | ||
58 | B2=m(4)-(1+s^2)*sd^4; | ||
59 | |||
60 | b=zeros(1,7); | ||
61 | b(7)=B2^3; | ||
62 | b(5)=3*A2*B2^2; | ||
63 | b(3)=3*A2^2*B2; | ||
64 | b(1)=A2^3; | ||
65 | |||
66 | |||
67 | if 0, % test | ||
68 | |||
69 | lam = -2:0.02:2; | ||
70 | S = (A*lam.^3+B*lam.^2+C*lam+D)./... | ||
71 | sqrt(b(7)*lam.^6 + b(5)*lam.^4 + b(3)*lam.^2 + b(1)); | ||
72 | % grd = ch.^2 - m(2) - sd * s * ch; | ||
73 | % for lam = -1:0.01:1, | ||
74 | % n = lam*100+101; | ||
75 | % chp = ch + lam*grd; | ||
76 | % S2(n) = mean2(chp.^3)/abs(mean2(chp.^2))^(1.5); | ||
77 | % end | ||
78 | lam = -2:0.02:2; | ||
79 | figure(1);plot(lam,S);grid;drawnow | ||
80 | % snr(S2, S-S2) | ||
81 | |||
82 | end % test | ||
83 | |||
84 | % Now I compute its derivative with respect to lambda | ||
85 | |||
86 | d(8) = B*b(7); | ||
87 | d(7) = 2*C*b(7) - A*b(5); | ||
88 | d(6) = 3*D*b(7); | ||
89 | d(5) = C*b(5) - 2*A*b(3); | ||
90 | d(4) = 2*D*b(5) - B*b(3); | ||
91 | d(3) = -3*A*b(1); | ||
92 | d(2) = D*b(3) - 2*B*b(1); | ||
93 | d(1) = -C*b(1); | ||
94 | |||
95 | d = d(8:-1:1); | ||
96 | mMlambda = roots(d); | ||
97 | |||
98 | tg = imag(mMlambda)./real(mMlambda); | ||
99 | mMlambda = real(mMlambda(find(abs(tg)<1e-6))); | ||
100 | lNeg = mMlambda(find(mMlambda<0)); | ||
101 | if length(lNeg)==0, | ||
102 | lNeg = -1/eps; | ||
103 | end | ||
104 | lPos = mMlambda(find(mMlambda>=0)); | ||
105 | if length(lPos)==0, | ||
106 | lPos = 1/eps; | ||
107 | end | ||
108 | lmi = max(lNeg); | ||
109 | lma = min(lPos); | ||
110 | |||
111 | lam = [lmi lma]; | ||
112 | mMnewSt = polyval([A B C D],lam)./(polyval(b(7:-1:1),lam)).^0.5; | ||
113 | skmin = min(mMnewSt); | ||
114 | skmax = max(mMnewSt); | ||
115 | |||
116 | |||
117 | % Given a desired skewness, solves for lambda | ||
118 | |||
119 | if sk<=skmin & Warn, | ||
120 | lam = lmi; | ||
121 | warning('Saturating (down) skewness!'); | ||
122 | skmin | ||
123 | elseif sk>=skmax & Warn, | ||
124 | lam = lma; | ||
125 | warning('Saturating (up) skewness!'); | ||
126 | skmax | ||
127 | else | ||
128 | |||
129 | |||
130 | % The equation is sum(c.*lam.^(0:6))=0 | ||
131 | |||
132 | c=a-b*sk^2; | ||
133 | |||
134 | c=c(7:-1:1); | ||
135 | |||
136 | r=roots(c); | ||
137 | |||
138 | % Chose the real solution with minimum absolute value with the rigth sign | ||
139 | lam=-Inf; | ||
140 | co=0; | ||
141 | for n=1:6, | ||
142 | tg = imag(r(n))/real(r(n)); | ||
143 | if (abs(tg)<1e-6)&(sign(real(r(n)))==sign(sk-s)), | ||
144 | co=co+1; | ||
145 | lam(co)=real(r(n)); | ||
146 | end | ||
147 | end | ||
148 | if min(abs(lam))==Inf & Warn, | ||
149 | display('Warning: Skew adjustment skipped!'); | ||
150 | lam=0; | ||
151 | end | ||
152 | |||
153 | p=[A B C D]; | ||
154 | |||
155 | if length(lam)>1, | ||
156 | foo=sign(polyval(p,lam)); | ||
157 | if any(foo==0), | ||
158 | lam = lam(find(foo==0)); | ||
159 | else | ||
160 | lam = lam(find(foo==sign(sk))); % rejects the symmetric solution | ||
161 | end | ||
162 | if length(lam)>0, | ||
163 | lam=lam(find(abs(lam)==min(abs(lam)))); % the smallest that fix the skew | ||
164 | lam=lam(1); | ||
165 | else | ||
166 | lam = 0; | ||
167 | end | ||
168 | end | ||
169 | end % if else | ||
170 | |||
171 | % Modify the channel | ||
172 | chm=ch+lam*(ch.^2-sd^2-sd*s*ch); % adjust the skewness | ||
173 | chm=chm*sqrt(m(2)/mean2(chm.^2)); % adjust the variance | ||
174 | chm=chm+me; % adjust the mean | ||
175 | % (These don't affect the skewness) | ||
176 | % Check the result | ||
177 | %mem=mean2(chm); | ||
178 | %sk2=mean2((chm-mem).^3)/mean2((chm-mem).^2).^(3/2); | ||
179 | %sk - sk2 | ||
180 | %SNR=snr(sk,sk-sk2) | ||
181 | |||
182 | |||
183 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/modulateFlip.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/modulateFlip.m deleted file mode 100755 index eb27303..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/modulateFlip.m +++ /dev/null | |||
@@ -1,19 +0,0 @@ | |||
1 | % [HFILT] = modulateFlipShift(LFILT) | ||
2 | % | ||
3 | % QMF/Wavelet highpass filter construction: modulate by (-1)^n, | ||
4 | % reverse order (and shift by one, which is handled by the convolution | ||
5 | % routines). This is an extension of the original definition of QMF's | ||
6 | % (e.g., see Simoncelli90). | ||
7 | |||
8 | % Eero Simoncelli, 7/96. | ||
9 | |||
10 | function [hfilt] = modulateFlipShift(lfilt) | ||
11 | |||
12 | lfilt = lfilt(:); | ||
13 | |||
14 | sz = size(lfilt,1); | ||
15 | sz2 = ceil(sz/2); | ||
16 | |||
17 | ind = [sz:-1:1]'; | ||
18 | |||
19 | hfilt = lfilt(ind) .* (-1).^(ind-sz2); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/namedFilter.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/namedFilter.m deleted file mode 100755 index 0689dbc..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/namedFilter.m +++ /dev/null | |||
@@ -1,71 +0,0 @@ | |||
1 | % KERNEL = NAMED_FILTER(NAME) | ||
2 | % | ||
3 | % Some standard 1D filter kernels. These are scaled such that | ||
4 | % their L2-norm is 1.0. | ||
5 | % | ||
6 | % binomN - binomial coefficient filter of order N-1 | ||
7 | % haar: - Haar wavelet. | ||
8 | % qmf8, qmf12, qmf16 - Symmetric Quadrature Mirror Filters [Johnston80] | ||
9 | % daub2,daub3,daub4 - Daubechies wavelet [Daubechies88]. | ||
10 | % qmf5, qmf9, qmf13: - Symmetric Quadrature Mirror Filters [Simoncelli88,Simoncelli90] | ||
11 | % | ||
12 | % See bottom of file for full citations. | ||
13 | |||
14 | % Eero Simoncelli, 6/96. | ||
15 | |||
16 | function [kernel] = named_filter(name) | ||
17 | |||
18 | if strcmp(name(1:min(5,size(name,2))), 'binom') | ||
19 | kernel = sqrt(2) * binomialFilter(str2num(name(6:size(name,2)))); | ||
20 | elseif strcmp(name,'qmf5') | ||
21 | kernel = [-0.076103 0.3535534 0.8593118 0.3535534 -0.076103]'; | ||
22 | elseif strcmp(name,'qmf9') | ||
23 | kernel = [0.02807382 -0.060944743 -0.073386624 0.41472545 0.7973934 ... | ||
24 | 0.41472545 -0.073386624 -0.060944743 0.02807382]'; | ||
25 | elseif strcmp(name,'qmf13') | ||
26 | kernel = [-0.014556438 0.021651438 0.039045125 -0.09800052 ... | ||
27 | -0.057827797 0.42995453 0.7737113 0.42995453 -0.057827797 ... | ||
28 | -0.09800052 0.039045125 0.021651438 -0.014556438]'; | ||
29 | elseif strcmp(name,'qmf8') | ||
30 | kernel = sqrt(2) * [0.00938715 -0.07065183 0.06942827 0.4899808 ... | ||
31 | 0.4899808 0.06942827 -0.07065183 0.00938715 ]'; | ||
32 | elseif strcmp(name,'qmf12') | ||
33 | kernel = sqrt(2) * [-0.003809699 0.01885659 -0.002710326 -0.08469594 ... | ||
34 | 0.08846992 0.4843894 0.4843894 0.08846992 -0.08469594 -0.002710326 ... | ||
35 | 0.01885659 -0.003809699 ]'; | ||
36 | elseif strcmp(name,'qmf16') | ||
37 | kernel = sqrt(2) * [0.001050167 -0.005054526 -0.002589756 0.0276414 -0.009666376 ... | ||
38 | -0.09039223 0.09779817 0.4810284 0.4810284 0.09779817 -0.09039223 -0.009666376 ... | ||
39 | 0.0276414 -0.002589756 -0.005054526 0.001050167 ]'; | ||
40 | elseif strcmp(name,'haar') | ||
41 | kernel = [1 1]' / sqrt(2); | ||
42 | elseif strcmp(name,'daub2') | ||
43 | kernel = [0.482962913145 0.836516303738 0.224143868042 -0.129409522551]'; | ||
44 | elseif strcmp(name,'daub3') | ||
45 | kernel = [0.332670552950 0.806891509311 0.459877502118 -0.135011020010 ... | ||
46 | -0.085441273882 0.035226291882]'; | ||
47 | elseif strcmp(name,'daub4') | ||
48 | kernel = [0.230377813309 0.714846570553 0.630880767930 -0.027983769417 ... | ||
49 | -0.187034811719 0.030841381836 0.032883011667 -0.010597401785]'; | ||
50 | elseif strcmp(name,'gauss5') % for backward-compatibility | ||
51 | kernel = sqrt(2) * [0.0625 0.25 0.375 0.25 0.0625]'; | ||
52 | elseif strcmp(name,'gauss3') % for backward-compatibility | ||
53 | kernel = sqrt(2) * [0.25 0.5 0.25]'; | ||
54 | else | ||
55 | error(sprintf('Bad filter name: %s\n',name)); | ||
56 | end | ||
57 | |||
58 | % [Johnston80] - J D Johnston, "A filter family designed for use in quadrature | ||
59 | % mirror filter banks", Proc. ICASSP, pp 291-294, 1980. | ||
60 | % | ||
61 | % [Daubechies88] - I Daubechies, "Orthonormal bases of compactly supported wavelets", | ||
62 | % Commun. Pure Appl. Math, vol. 42, pp 909-996, 1988. | ||
63 | % | ||
64 | % [Simoncelli88] - E P Simoncelli, "Orthogonal sub-band image transforms", | ||
65 | % PhD Thesis, MIT Dept. of Elec. Eng. and Comp. Sci. May 1988. | ||
66 | % Also available as: MIT Media Laboratory Vision and Modeling Technical | ||
67 | % Report #100. | ||
68 | % | ||
69 | % [Simoncelli90] - E P Simoncelli and E H Adelson, "Subband image coding", | ||
70 | % Subband Transforms, chapter 4, ed. John W Woods, Kluwer Academic | ||
71 | % Publishers, Norwell, MA, 1990, pp 143--192. | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/nextFig.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/nextFig.m deleted file mode 100755 index e0ac73f..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/nextFig.m +++ /dev/null | |||
@@ -1,19 +0,0 @@ | |||
1 | % nextFig (MAXFIGS, SKIP) | ||
2 | % | ||
3 | % Make figure number mod((GCF+SKIP), MAXFIGS) the current figure. | ||
4 | % MAXFIGS is optional, and defaults to 2. | ||
5 | % SKIP is optional, and defaults to 1. | ||
6 | |||
7 | % Eero Simoncelli, 2/97. | ||
8 | |||
9 | function nextFig(maxfigs, skip) | ||
10 | |||
11 | if (exist('maxfigs') ~= 1) | ||
12 | maxfigs = 2; | ||
13 | end | ||
14 | |||
15 | if (exist('skip') ~= 1) | ||
16 | skip = 1; | ||
17 | end | ||
18 | |||
19 | figure(1+mod(gcf-1+skip,maxfigs)); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/pgmRead.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/pgmRead.m deleted file mode 100755 index 86c3b62..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/pgmRead.m +++ /dev/null | |||
@@ -1,59 +0,0 @@ | |||
1 | % IM = pgmRead( FILENAME ) | ||
2 | % | ||
3 | % Load a pgm image into a MatLab matrix. | ||
4 | % This format is accessible from the XV image browsing utility. | ||
5 | % Only works for 8bit gray images (raw or ascii) | ||
6 | |||
7 | % Hany Farid, Spring '96. Modified by Eero Simoncelli, 6/96. | ||
8 | |||
9 | function im = pgmRead( fname ); | ||
10 | |||
11 | [fid,msg] = fopen( fname, 'r' ); | ||
12 | |||
13 | if (fid == -1) | ||
14 | error(msg); | ||
15 | end | ||
16 | |||
17 | %%% First line contains ID string: | ||
18 | %%% "P1" = ascii bitmap, "P2" = ascii greymap, | ||
19 | %%% "P3" = ascii pixmap, "P4" = raw bitmap, | ||
20 | %%% "P5" = raw greymap, "P6" = raw pixmap | ||
21 | TheLine = fgetl(fid); | ||
22 | format = TheLine; | ||
23 | |||
24 | if ~((format(1:2) == 'P2') | (format(1:2) == 'P5')) | ||
25 | error('PGM file must be of type P2 or P5'); | ||
26 | end | ||
27 | |||
28 | %%% Any number of comment lines | ||
29 | TheLine = fgetl(fid); | ||
30 | while TheLine(1) == '#' | ||
31 | TheLine = fgetl(fid); | ||
32 | end | ||
33 | |||
34 | %%% dimensions | ||
35 | sz = sscanf(TheLine,'%d',2); | ||
36 | xdim = sz(1); | ||
37 | ydim = sz(2); | ||
38 | sz = xdim * ydim; | ||
39 | |||
40 | %%% Maximum pixel value | ||
41 | TheLine = fgetl(fid); | ||
42 | maxval = sscanf(TheLine, '%d',1); | ||
43 | |||
44 | %%im = zeros(dim,1); | ||
45 | if (format(2) == '2') | ||
46 | [im,count] = fscanf(fid,'%d',sz); | ||
47 | else | ||
48 | [im,count] = fread(fid,sz,'uchar'); | ||
49 | end | ||
50 | |||
51 | fclose(fid); | ||
52 | |||
53 | if (count == sz) | ||
54 | im = reshape( im, xdim, ydim )'; | ||
55 | else | ||
56 | fprintf(1,'Warning: File ended early!'); | ||
57 | im = reshape( [im ; zeros(sz-count,1)], xdim, ydim)'; | ||
58 | end | ||
59 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/pgmWrite.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/pgmWrite.m deleted file mode 100755 index 09c14c9..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/pgmWrite.m +++ /dev/null | |||
@@ -1,120 +0,0 @@ | |||
1 | % RANGE = pgmWrite(MTX, FILENAME, RANGE, TYPE, COMMENT) | ||
2 | % | ||
3 | % Write a MatLab matrix to a pgm (graylevel image) file. | ||
4 | % This format is accessible from the XV image browsing utility. | ||
5 | % | ||
6 | % RANGE (optional) is a 2-vector specifying the values that map to | ||
7 | % black and white, respectively. Passing a value of 'auto' (default) | ||
8 | % sets RANGE=[min,max] (as in MatLab's imagesc). 'auto2' sets | ||
9 | % RANGE=[mean-2*stdev, mean+2*stdev]. 'auto3' sets | ||
10 | % RANGE=[p1-(p2-p1)/8, p2+(p2-p1)/8], where p1 is the 10th percentile | ||
11 | % value of the sorted MATRIX samples, and p2 is the 90th percentile | ||
12 | % value. | ||
13 | % | ||
14 | % TYPE (optional) should be 'raw' or 'ascii'. Defaults to 'raw'. | ||
15 | |||
16 | % Hany Farid, Spring '96. Modified by Eero Simoncelli, 6/96. | ||
17 | |||
18 | function range = pgmWrite(mtx, fname, range, type, comment ); | ||
19 | |||
20 | [fid,msg] = fopen( fname, 'w' ); | ||
21 | |||
22 | if (fid == -1) | ||
23 | error(msg); | ||
24 | end | ||
25 | |||
26 | %------------------------------------------------------------ | ||
27 | %% optional ARGS: | ||
28 | |||
29 | if (exist('range') ~= 1) | ||
30 | range = 'auto'; | ||
31 | end | ||
32 | |||
33 | if (exist('type') ~= 1) | ||
34 | type = 'raw'; | ||
35 | end | ||
36 | %------------------------------------------------------------ | ||
37 | |||
38 | %% Automatic range calculation: | ||
39 | if (strcmp(range,'auto1') | strcmp(range,'auto')) | ||
40 | [mn,mx] = range2(mtx); | ||
41 | range = [mn,mx]; | ||
42 | |||
43 | elseif strcmp(range,'auto2') | ||
44 | stdev = sqrt(var2(mtx)); | ||
45 | av = mean2(mtx); | ||
46 | range = [av-2*stdev,av+2*stdev]; % MAGIC NUMBER: 2 stdevs | ||
47 | |||
48 | elseif strcmp(range, 'auto3') | ||
49 | percentile = 0.1; % MAGIC NUMBER: 0<p<0.5 | ||
50 | [N,X] = histo(mtx); | ||
51 | binsz = X(2)-X(1); | ||
52 | N = N+1e-10; % Ensure cumsum will be monotonic for call to interp1 | ||
53 | cumN = [0, cumsum(N)]/sum(N); | ||
54 | cumX = [X(1)-binsz, X] + (binsz/2); | ||
55 | ctrRange = interp1(cumN,cumX, [percentile, 1-percentile]); | ||
56 | range = mean(ctrRange) + (ctrRange-mean(ctrRange))/(1-2*percentile); | ||
57 | |||
58 | elseif isstr(range) | ||
59 | error(sprintf('Bad RANGE argument: %s',range)) | ||
60 | |||
61 | end | ||
62 | |||
63 | if ((range(2) - range(1)) <= eps) | ||
64 | range(1) = range(1) - 0.5; | ||
65 | range(2) = range(2) + 0.5; | ||
66 | end | ||
67 | |||
68 | |||
69 | %%% First line contains ID string: | ||
70 | %%% "P1" = ascii bitmap, "P2" = ascii greymap, | ||
71 | %%% "P3" = ascii pixmap, "P4" = raw bitmap, | ||
72 | %%% "P5" = raw greymap, "P6" = raw pixmap | ||
73 | if strcmp(type,'raw') | ||
74 | fprintf(fid,'P5\n'); | ||
75 | format = 5; | ||
76 | elseif strcmp(type,'ascii') | ||
77 | fprintf(fid,'P2\n'); | ||
78 | format = 2; | ||
79 | else | ||
80 | error(sprintf('PGMWRITE: Bad type argument: %s',type)); | ||
81 | end | ||
82 | |||
83 | fprintf(fid,'# MatLab PGMWRITE file, saved %s\n',date); | ||
84 | |||
85 | if (exist('comment') == 1) | ||
86 | fprintf(fid,'# %s\n', comment); | ||
87 | end | ||
88 | |||
89 | %%% dimensions | ||
90 | fprintf(fid,'%d %d\n',size(mtx,2),size(mtx,1)); | ||
91 | |||
92 | %%% Maximum pixel value | ||
93 | fprintf(fid,'255\n'); | ||
94 | |||
95 | |||
96 | %% MatLab's "fprintf" floors when writing floats, so we compute | ||
97 | %% (mtx-r1)*255/(r2-r1)+0.5 | ||
98 | mult = (255 / (range(2)-range(1))); | ||
99 | mtx = (mult * mtx) + (0.5 - mult * range(1)); | ||
100 | |||
101 | mtx = max(-0.5+eps,min(255.5-eps,mtx)); | ||
102 | |||
103 | if (format == 2) | ||
104 | count = fprintf(fid,'%d ',mtx'); | ||
105 | elseif (format == 5) | ||
106 | count = fwrite(fid,mtx','uchar'); | ||
107 | end | ||
108 | |||
109 | fclose(fid); | ||
110 | |||
111 | if (count ~= size(mtx,1)*size(mtx,2)) | ||
112 | fprintf(1,'Warning: File output terminated early!'); | ||
113 | end | ||
114 | |||
115 | %%% TEST: | ||
116 | % foo = 257*rand(100)-1; | ||
117 | % pgmWrite(foo,'foo.pgm',[0 255]); | ||
118 | % foo2=pgmRead('foo.pgm'); | ||
119 | % size(find((foo2-round(foo))~=0)) | ||
120 | % foo(find((foo2-round(foo))~=0)) | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/pixelAxes.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/pixelAxes.m deleted file mode 100755 index f88210d..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/pixelAxes.m +++ /dev/null | |||
@@ -1,70 +0,0 @@ | |||
1 | % [ZOOM] = pixelAxes(DIMS, ZOOM) | ||
2 | % | ||
3 | % Set the axes of the current plot to cover a multiple of DIMS pixels, | ||
4 | % thereby eliminating screen aliasing artifacts when displaying an | ||
5 | % image of size DIMS. | ||
6 | % | ||
7 | % ZOOM (optional, default='same') expresses the desired number of | ||
8 | % samples displayed per screen pixel. It should be a scalar, which | ||
9 | % will be rounded to the nearest integer, or 1 over an integer. It | ||
10 | % may also be the string 'same' or 'auto', in which case the value is chosen so | ||
11 | % as to produce an image closest in size to the currently displayed | ||
12 | % image. It may also be the string 'full', in which case the image is | ||
13 | % made as large as possible while still fitting in the window. | ||
14 | |||
15 | % Eero Simoncelli, 2/97. | ||
16 | |||
17 | function [zoom] = pixelAxes(dims, zoom) | ||
18 | |||
19 | %------------------------------------------------------------ | ||
20 | %% OPTIONAL ARGS: | ||
21 | |||
22 | if (exist('zoom') ~= 1) | ||
23 | zoom = 'same'; | ||
24 | end | ||
25 | |||
26 | %% Reverse dimension order, since Figure Positions reported as (x,y). | ||
27 | dims = dims(2:-1:1); | ||
28 | |||
29 | %% Use MatLab's axis function to force square pixels, etc: | ||
30 | axis('image'); | ||
31 | ax = gca; | ||
32 | |||
33 | oldunits = get(ax,'Units'); | ||
34 | |||
35 | if strcmp(zoom,'full'); | ||
36 | set(ax,'Units','normalized'); | ||
37 | set(ax,'Position',[0 0 1 1]); | ||
38 | zoom = 'same'; | ||
39 | end | ||
40 | |||
41 | set(ax,'Units','pixels'); | ||
42 | pos = get(ax,'Position'); | ||
43 | ctr = pos(1:2)+pos(3:4)/2; | ||
44 | |||
45 | if (strcmp(zoom,'same') | strcmp(zoom,'auto')) | ||
46 | %% HACK: enlarge slightly so that floor doesn't round down | ||
47 | zoom = min( pos(3:4) ./ (dims - 1) ); | ||
48 | elseif isstr(zoom) | ||
49 | error(sprintf('Bad ZOOM argument: %s',zoom)); | ||
50 | end | ||
51 | |||
52 | %% Force zoom value to be an integer, or inverse integer. | ||
53 | if (zoom < 0.75) | ||
54 | zoom = 1/ceil(1/zoom); | ||
55 | %% Round upward, subtracting 0.5 to avoid floating point errors. | ||
56 | newsz = ceil(zoom*(dims-0.5)); | ||
57 | else | ||
58 | zoom = floor(zoom + 0.001); % Avoid floating pt errors | ||
59 | if (zoom < 1.5) % zoom=1 | ||
60 | zoom = 1; | ||
61 | newsz = dims + 0.5; | ||
62 | else | ||
63 | newsz = zoom*(dims-1) + mod(zoom,2); | ||
64 | end | ||
65 | end | ||
66 | |||
67 | set(ax,'Position', [floor(ctr-newsz/2)+0.5, newsz] ) | ||
68 | |||
69 | % Restore units | ||
70 | set(ax,'Units',oldunits); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/pointOp.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/pointOp.m deleted file mode 100755 index feb7750..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/pointOp.m +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
1 | % RES = pointOp(IM, LUT, ORIGIN, INCREMENT, WARNINGS) | ||
2 | % | ||
3 | % Apply a point operation, specified by lookup table LUT, to image IM. | ||
4 | % LUT must be a row or column vector, and is assumed to contain | ||
5 | % (equi-spaced) samples of the function. ORIGIN specifies the | ||
6 | % abscissa associated with the first sample, and INCREMENT specifies the | ||
7 | % spacing between samples. Between-sample values are estimated via | ||
8 | % linear interpolation. If WARNINGS is non-zero, the function prints | ||
9 | % a warning whenever the lookup table is extrapolated. | ||
10 | % | ||
11 | % This function is much faster than MatLab's interp1, and allows | ||
12 | % extrapolation beyond the lookup table domain. The drawbacks are | ||
13 | % that the lookup table must be equi-spaced, and the interpolation is | ||
14 | % linear. | ||
15 | |||
16 | % Eero Simoncelli, 8/96. | ||
17 | |||
18 | function res = pointOp(im, lut, origin, increment, warnings) | ||
19 | |||
20 | %% NOTE: THIS CODE IS NOT ACTUALLY USED! (MEX FILE IS CALLED INSTEAD) | ||
21 | |||
22 | %fprintf(1,'WARNING: You should compile the MEX version of "pointOp.c",\n found in the MEX subdirectory of matlabPyrTools, and put it in your matlab path. It is MUCH faster.\n'); | ||
23 | |||
24 | X = origin + increment*[0:size(lut(:),1)-1]; | ||
25 | Y = lut(:); | ||
26 | |||
27 | res = reshape(interp1(X, Y, im(:), 'linear', 'extrap'),size(im)); | ||
28 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/pwd2path.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/pwd2path.m deleted file mode 100755 index 15aecf0..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/pwd2path.m +++ /dev/null | |||
@@ -1,6 +0,0 @@ | |||
1 | % PWD2PATH() | ||
2 | % | ||
3 | % add current working directory (pwd) to path. | ||
4 | |||
5 | P = path; | ||
6 | path(pwd,P); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/pyrBand.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/pyrBand.m deleted file mode 100755 index 1fb6461..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/pyrBand.m +++ /dev/null | |||
@@ -1,11 +0,0 @@ | |||
1 | % RES = pyrBand(PYR, INDICES, BAND_NUM) | ||
2 | % | ||
3 | % Access a subband from a pyramid (gaussian, laplacian, QMF/wavelet, | ||
4 | % or steerable). Subbands are numbered consecutively, from finest | ||
5 | % (highest spatial frequency) to coarsest (lowest spatial frequency). | ||
6 | |||
7 | % Eero Simoncelli, 6/96. | ||
8 | |||
9 | function res = pyrBand(pyr, pind, band) | ||
10 | |||
11 | res = reshape( pyr(pyrBandIndices(pind,band)), pind(band,1), pind(band,2) ); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/pyrBandIndices.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/pyrBandIndices.m deleted file mode 100755 index f94c217..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/pyrBandIndices.m +++ /dev/null | |||
@@ -1,24 +0,0 @@ | |||
1 | % RES = pyrBandIndices(INDICES, BAND_NUM) | ||
2 | % | ||
3 | % Return indices for accessing a subband from a pyramid | ||
4 | % (gaussian, laplacian, QMF/wavelet, steerable). | ||
5 | |||
6 | % Eero Simoncelli, 6/96. | ||
7 | |||
8 | function indices = pyrBandIndices(pind,band) | ||
9 | |||
10 | if ((band > size(pind,1)) | (band < 1)) | ||
11 | error(sprintf('BAND_NUM must be between 1 and number of pyramid bands (%d).', ... | ||
12 | size(pind,1))); | ||
13 | end | ||
14 | |||
15 | if (size(pind,2) ~= 2) | ||
16 | error('INDICES must be an Nx2 matrix indicating the size of the pyramid subbands'); | ||
17 | end | ||
18 | |||
19 | ind = 1; | ||
20 | for l=1:band-1 | ||
21 | ind = ind + prod(pind(l,:)); | ||
22 | end | ||
23 | |||
24 | indices = ind:ind+prod(pind(band,:))-1; | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/pyrLow.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/pyrLow.m deleted file mode 100755 index 290e806..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/pyrLow.m +++ /dev/null | |||
@@ -1,12 +0,0 @@ | |||
1 | % RES = pyrLow(PYR, INDICES) | ||
2 | % | ||
3 | % Access the lowpass subband from a pyramid | ||
4 | % (gaussian, laplacian, QMF/wavelet, steerable). | ||
5 | |||
6 | % Eero Simoncelli, 6/96. | ||
7 | |||
8 | function res = pyrLow(pyr,pind) | ||
9 | |||
10 | band = size(pind,1); | ||
11 | |||
12 | res = reshape( pyr(pyrBandIndices(pind,band)), pind(band,1), pind(band,2) ); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/range2.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/range2.m deleted file mode 100755 index 082bbe1..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/range2.m +++ /dev/null | |||
@@ -1,18 +0,0 @@ | |||
1 | % [MIN, MAX] = range2(MTX) | ||
2 | % | ||
3 | % Compute minimum and maximum values of MTX, returning them as a 2-vector. | ||
4 | |||
5 | % Eero Simoncelli, 3/97. | ||
6 | |||
7 | function [mn, mx] = range2(mtx) | ||
8 | |||
9 | %% NOTE: THIS CODE IS NOT ACTUALLY USED! (MEX FILE IS CALLED INSTEAD) | ||
10 | |||
11 | %fprintf(1,'WARNING: You should compile the MEX version of "range2.c",\n found in the MEX subdirectory of matlabPyrTools, and put it in your matlab path. It is MUCH faster.\n'); | ||
12 | |||
13 | if (~isreal(mtx)) | ||
14 | error('MTX must be real-valued'); | ||
15 | end | ||
16 | |||
17 | mn = min(min(mtx)); | ||
18 | mx = max(max(mtx)); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/rconv2.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/rconv2.m deleted file mode 100755 index 0c12490..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/rconv2.m +++ /dev/null | |||
@@ -1,50 +0,0 @@ | |||
1 | % RES = RCONV2(MTX1, MTX2, CTR) | ||
2 | % | ||
3 | % Convolution of two matrices, with boundaries handled via reflection | ||
4 | % about the edge pixels. Result will be of size of LARGER matrix. | ||
5 | % | ||
6 | % The origin of the smaller matrix is assumed to be its center. | ||
7 | % For even dimensions, the origin is determined by the CTR (optional) | ||
8 | % argument: | ||
9 | % CTR origin | ||
10 | % 0 DIM/2 (default) | ||
11 | % 1 (DIM/2)+1 | ||
12 | |||
13 | % Eero Simoncelli, 6/96. | ||
14 | |||
15 | function c = rconv2(a,b,ctr) | ||
16 | |||
17 | if (exist('ctr') ~= 1) | ||
18 | ctr = 0; | ||
19 | end | ||
20 | |||
21 | if (( size(a,1) >= size(b,1) ) & ( size(a,2) >= size(b,2) )) | ||
22 | large = a; small = b; | ||
23 | elseif (( size(a,1) <= size(b,1) ) & ( size(a,2) <= size(b,2) )) | ||
24 | large = b; small = a; | ||
25 | else | ||
26 | error('one arg must be larger than the other in both dimensions!'); | ||
27 | end | ||
28 | |||
29 | ly = size(large,1); | ||
30 | lx = size(large,2); | ||
31 | sy = size(small,1); | ||
32 | sx = size(small,2); | ||
33 | |||
34 | %% These values are one less than the index of the small mtx that falls on | ||
35 | %% the border pixel of the large matrix when computing the first | ||
36 | %% convolution response sample: | ||
37 | sy2 = floor((sy+ctr-1)/2); | ||
38 | sx2 = floor((sx+ctr-1)/2); | ||
39 | |||
40 | % pad with reflected copies | ||
41 | clarge = [ | ||
42 | large(sy-sy2:-1:2,sx-sx2:-1:2), large(sy-sy2:-1:2,:), ... | ||
43 | large(sy-sy2:-1:2,lx-1:-1:lx-sx2); ... | ||
44 | large(:,sx-sx2:-1:2), large, large(:,lx-1:-1:lx-sx2); ... | ||
45 | large(ly-1:-1:ly-sy2,sx-sx2:-1:2), ... | ||
46 | large(ly-1:-1:ly-sy2,:), ... | ||
47 | large(ly-1:-1:ly-sy2,lx-1:-1:lx-sx2) ]; | ||
48 | |||
49 | c = conv2(clarge,small,'valid'); | ||
50 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/rcosFn.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/rcosFn.m deleted file mode 100755 index 5dac344..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/rcosFn.m +++ /dev/null | |||
@@ -1,45 +0,0 @@ | |||
1 | % [X, Y] = rcosFn(WIDTH, POSITION, VALUES) | ||
2 | % | ||
3 | % Return a lookup table (suitable for use by INTERP1) | ||
4 | % containing a "raised cosine" soft threshold function: | ||
5 | % | ||
6 | % Y = VALUES(1) + (VALUES(2)-VALUES(1)) * | ||
7 | % cos^2( PI/2 * (X - POSITION + WIDTH)/WIDTH ) | ||
8 | % | ||
9 | % WIDTH is the width of the region over which the transition occurs | ||
10 | % (default = 1). POSITION is the location of the center of the | ||
11 | % threshold (default = 0). VALUES (default = [0,1]) specifies the | ||
12 | % values to the left and right of the transition. | ||
13 | |||
14 | % Eero Simoncelli, 7/96. | ||
15 | |||
16 | function [X, Y] = rcosFn(width,position,values) | ||
17 | |||
18 | %------------------------------------------------------------ | ||
19 | % OPTIONAL ARGS: | ||
20 | |||
21 | if (exist('width') ~= 1) | ||
22 | width = 1; | ||
23 | end | ||
24 | |||
25 | if (exist('position') ~= 1) | ||
26 | position = 0; | ||
27 | end | ||
28 | |||
29 | if (exist('values') ~= 1) | ||
30 | values = [0,1]; | ||
31 | end | ||
32 | |||
33 | %------------------------------------------------------------ | ||
34 | |||
35 | sz = 256; %% arbitrary! | ||
36 | |||
37 | X = pi * [-sz-1:1] / (2*sz); | ||
38 | |||
39 | Y = values(1) + (values(2)-values(1)) * cos(X).^2; | ||
40 | |||
41 | % Make sure end values are repeated, for extrapolation... | ||
42 | Y(1) = Y(2); | ||
43 | Y(sz+3) = Y(sz+2); | ||
44 | |||
45 | X = position + (2*width/pi) * (X + pi/4); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/reconLpyr.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/reconLpyr.m deleted file mode 100755 index cddcc12..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/reconLpyr.m +++ /dev/null | |||
@@ -1,83 +0,0 @@ | |||
1 | % RES = reconLpyr(PYR, INDICES, LEVS, FILT2, EDGES) | ||
2 | % | ||
3 | % Reconstruct image from Laplacian pyramid, as created by buildLpyr. | ||
4 | % | ||
5 | % PYR is a vector containing the N pyramid subbands, ordered from fine | ||
6 | % to coarse. INDICES is an Nx2 matrix containing the sizes of | ||
7 | % each subband. This is compatible with the MatLab Wavelet toolbox. | ||
8 | % | ||
9 | % LEVS (optional) should be a list of levels to include, or the string | ||
10 | % 'all' (default). The finest scale is number 1. The lowpass band | ||
11 | % corresponds to lpyrHt(INDICES)+1. | ||
12 | % | ||
13 | % FILT2 (optional) can be a string naming a standard filter (see | ||
14 | % namedFilter), or a vector which will be used for (separable) | ||
15 | % convolution. Default = 'binom5'. EDGES specifies edge-handling, | ||
16 | % and defaults to 'reflect1' (see corrDn). | ||
17 | |||
18 | % Eero Simoncelli, 6/96 | ||
19 | |||
20 | function res = reconLpyr(pyr, ind, levs, filt2, edges) | ||
21 | |||
22 | if (nargin < 2) | ||
23 | error('First two arguments (PYR, INDICES) are required'); | ||
24 | end | ||
25 | |||
26 | %%------------------------------------------------------------ | ||
27 | %% DEFAULTS: | ||
28 | |||
29 | if (exist('levs') ~= 1) | ||
30 | levs = 'all'; | ||
31 | end | ||
32 | |||
33 | if (exist('filt2') ~= 1) | ||
34 | filt2 = 'binom5'; | ||
35 | end | ||
36 | |||
37 | if (exist('edges') ~= 1) | ||
38 | edges= 'reflect1'; | ||
39 | end | ||
40 | %%------------------------------------------------------------ | ||
41 | |||
42 | maxLev = 1+lpyrHt(ind); | ||
43 | if strcmp(levs,'all') | ||
44 | levs = [1:maxLev]'; | ||
45 | else | ||
46 | if (any(levs > maxLev)) | ||
47 | error(sprintf('Level numbers must be in the range [1, %d].', maxLev)); | ||
48 | end | ||
49 | levs = levs(:); | ||
50 | end | ||
51 | |||
52 | if isstr(filt2) | ||
53 | filt2 = namedFilter(filt2); | ||
54 | end | ||
55 | |||
56 | filt2 = filt2(:); | ||
57 | res_sz = ind(1,:); | ||
58 | |||
59 | if any(levs > 1) | ||
60 | |||
61 | int_sz = [ind(1,1), ind(2,2)]; | ||
62 | |||
63 | nres = reconLpyr( pyr(prod(res_sz)+1:size(pyr,1)), ... | ||
64 | ind(2:size(ind,1),:), levs-1, filt2, edges); | ||
65 | |||
66 | if (res_sz(1) == 1) | ||
67 | res = upConv(nres, filt2', edges, [1 2], [1 1], res_sz); | ||
68 | elseif (res_sz(2) == 1) | ||
69 | res = upConv(nres, filt2, edges, [2 1], [1 1], res_sz); | ||
70 | else | ||
71 | hi = upConv(nres, filt2, edges, [2 1], [1 1], int_sz); | ||
72 | res = upConv(hi, filt2', edges, [1 2], [1 1], res_sz); | ||
73 | end | ||
74 | |||
75 | else | ||
76 | |||
77 | res = zeros(res_sz); | ||
78 | |||
79 | end | ||
80 | |||
81 | if any(levs == 1) | ||
82 | res = res + pyrBand(pyr,ind,1); | ||
83 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/reconSCFpyr.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/reconSCFpyr.m deleted file mode 100755 index a86f03d..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/reconSCFpyr.m +++ /dev/null | |||
@@ -1,87 +0,0 @@ | |||
1 | % RES = reconSCFpyr(PYR, INDICES, LEVS, BANDS, TWIDTH) | ||
2 | % | ||
3 | % The inverse of buildSCFpyr: Reconstruct image from its complex steerable pyramid representation, | ||
4 | % in the Fourier domain. | ||
5 | % | ||
6 | % The image is reconstructed by forcing the complex subbands to be analytic | ||
7 | % (zero on half of the 2D Fourier plane, as they are supossed to be unless | ||
8 | % they have being modified), and reconstructing from the real part of those | ||
9 | % analytic subbands. That is equivalent to compute the Hilbert transforms of | ||
10 | % the imaginary parts of the subbands, average them with their real | ||
11 | % counterparts, and then reconstructing from the resulting real subbands. | ||
12 | % | ||
13 | % PYR is a vector containing the N pyramid subbands, ordered from fine | ||
14 | % to coarse. INDICES is an Nx2 matrix containing the sizes of | ||
15 | % each subband. This is compatible with the MatLab Wavelet toolbox. | ||
16 | % | ||
17 | % LEVS (optional) should be a list of levels to include, or the string | ||
18 | % 'all' (default). 0 corresonds to the residual highpass subband. | ||
19 | % 1 corresponds to the finest oriented scale. The lowpass band | ||
20 | % corresponds to number spyrHt(INDICES)+1. | ||
21 | % | ||
22 | % BANDS (optional) should be a list of bands to include, or the string | ||
23 | % 'all' (default). 1 = vertical, rest proceeding anti-clockwise. | ||
24 | % | ||
25 | % TWIDTH is the width of the transition region of the radial lowpass | ||
26 | % function, in octaves (default = 1, which gives a raised cosine for | ||
27 | % the bandpass filters). | ||
28 | |||
29 | % Javier Portilla, 7/04, basing on Eero Simoncelli's Matlab Pyrtools code | ||
30 | % and our common code on texture synthesis (textureSynthesis.m). | ||
31 | |||
32 | function res = reconSCFpyr(pyr, indices, levs, bands, twidth) | ||
33 | |||
34 | %%------------------------------------------------------------ | ||
35 | %% DEFAULTS: | ||
36 | |||
37 | if ~exist('levs'), | ||
38 | levs = 'all'; | ||
39 | end | ||
40 | |||
41 | if ~exist('bands') | ||
42 | bands = 'all'; | ||
43 | end | ||
44 | |||
45 | if ~exist('twidth'), | ||
46 | twidth = 1; | ||
47 | elseif (twidth <= 0) | ||
48 | fprintf(1,'Warning: TWIDTH must be positive. Setting to 1.\n'); | ||
49 | twidth = 1; | ||
50 | end | ||
51 | |||
52 | %%------------------------------------------------------------ | ||
53 | |||
54 | |||
55 | pind = indices; | ||
56 | Nsc = log2(pind(1,1)/pind(end,1)); | ||
57 | Nor = (size(pind,1)-2)/Nsc; | ||
58 | |||
59 | for nsc = 1:Nsc, | ||
60 | firstBnum = (nsc-1)*Nor+2; | ||
61 | |||
62 | %% Re-create analytic subbands | ||
63 | dims = pind(firstBnum,:); | ||
64 | ctr = ceil((dims+0.5)/2); | ||
65 | ang = mkAngle(dims, 0, ctr); | ||
66 | ang(ctr(1),ctr(2)) = -pi/2; | ||
67 | for nor = 1:Nor, | ||
68 | nband = (nsc-1)*Nor+nor+1; | ||
69 | ind = pyrBandIndices(pind,nband); | ||
70 | ch = pyrBand(pyr, pind, nband); | ||
71 | ang0 = pi*(nor-1)/Nor; | ||
72 | xang = mod(ang-ang0+pi, 2*pi) - pi; | ||
73 | amask = 2*(abs(xang) < pi/2) + (abs(xang) == pi/2); | ||
74 | amask(ctr(1),ctr(2)) = 1; | ||
75 | amask(:,1) = 1; | ||
76 | amask(1,:) = 1; | ||
77 | amask = fftshift(amask); | ||
78 | ch = ifft2(amask.*fft2(ch)); % "Analytic" version | ||
79 | %f = 1.000008; % With this factor the reconstruction SNR goes up around 6 dB! | ||
80 | f = 1; | ||
81 | ch = f*0.5*real(ch); % real part | ||
82 | pyr(ind) = ch; | ||
83 | end % nor | ||
84 | end % nsc | ||
85 | |||
86 | res = reconSFpyr(pyr, indices, levs, bands, twidth); | ||
87 | |||
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))); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/reconSFpyrLevs.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/reconSFpyrLevs.m deleted file mode 100755 index 420f278..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/reconSFpyrLevs.m +++ /dev/null | |||
@@ -1,69 +0,0 @@ | |||
1 | % RESDFT = reconSFpyrLevs(PYR,INDICES,LOGRAD,XRCOS,YRCOS,ANGLE,NBANDS,LEVS,BANDS) | ||
2 | % | ||
3 | % Recursive function for reconstructing levels of a steerable pyramid | ||
4 | % representation. This is called by reconSFpyr, and is not usually | ||
5 | % called directly. | ||
6 | |||
7 | % Eero Simoncelli, 5/97. | ||
8 | |||
9 | function resdft = reconSFpyrLevs(pyr,pind,log_rad,Xrcos,Yrcos,angle,nbands,levs,bands); | ||
10 | |||
11 | lo_ind = nbands+1; | ||
12 | dims = pind(1,:); | ||
13 | ctr = ceil((dims+0.5)/2); | ||
14 | |||
15 | % log_rad = log_rad + 1; | ||
16 | Xrcos = Xrcos - log2(2); % shift origin of lut by 1 octave. | ||
17 | |||
18 | if any(levs > 1) | ||
19 | |||
20 | lodims = ceil((dims-0.5)/2); | ||
21 | loctr = ceil((lodims+0.5)/2); | ||
22 | lostart = ctr-loctr+1; | ||
23 | loend = lostart+lodims-1; | ||
24 | nlog_rad = log_rad(lostart(1):loend(1),lostart(2):loend(2)); | ||
25 | nangle = angle(lostart(1):loend(1),lostart(2):loend(2)); | ||
26 | |||
27 | if (size(pind,1) > lo_ind) | ||
28 | nresdft = reconSFpyrLevs( pyr(1+sum(prod(pind(1:lo_ind-1,:)')):size(pyr,1)),... | ||
29 | pind(lo_ind:size(pind,1),:), ... | ||
30 | nlog_rad, Xrcos, Yrcos, nangle, nbands,levs-1, bands); | ||
31 | else | ||
32 | nresdft = fftshift(fft2(pyrBand(pyr,pind,lo_ind))); | ||
33 | end | ||
34 | |||
35 | YIrcos = sqrt(abs(1.0 - Yrcos.^2)); | ||
36 | lomask = pointOp(nlog_rad, YIrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); | ||
37 | |||
38 | resdft = zeros(dims); | ||
39 | resdft(lostart(1):loend(1),lostart(2):loend(2)) = nresdft .* lomask; | ||
40 | |||
41 | else | ||
42 | |||
43 | resdft = zeros(dims); | ||
44 | |||
45 | end | ||
46 | |||
47 | |||
48 | if any(levs == 1) | ||
49 | |||
50 | lutsize = 1024; | ||
51 | Xcosn = pi*[-(2*lutsize+1):(lutsize+1)]/lutsize; % [-2*pi:pi] | ||
52 | order = nbands-1; | ||
53 | %% divide by sqrt(sum_(n=0)^(N-1) cos(pi*n/N)^(2(N-1)) ) | ||
54 | const = (2^(2*order))*(factorial(order)^2)/(nbands*factorial(2*order)); | ||
55 | Ycosn = sqrt(const) * (cos(Xcosn)).^order; | ||
56 | himask = pointOp(log_rad, Yrcos, Xrcos(1), Xrcos(2)-Xrcos(1),0); | ||
57 | |||
58 | ind = 1; | ||
59 | for b = 1:nbands | ||
60 | if any(bands == b) | ||
61 | anglemask = pointOp(angle,Ycosn,Xcosn(1)+pi*(b-1)/nbands,Xcosn(2)-Xcosn(1)); | ||
62 | band = reshape(pyr(ind:ind+prod(dims)-1), dims(1), dims(2)); | ||
63 | banddft = fftshift(fft2(band)); | ||
64 | resdft = resdft + (sqrt(-1))^(nbands-1) * banddft.*anglemask.*himask; | ||
65 | end | ||
66 | ind = ind + prod(dims); | ||
67 | end | ||
68 | end | ||
69 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/reconSpyr.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/reconSpyr.m deleted file mode 100755 index 270009d..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/reconSpyr.m +++ /dev/null | |||
@@ -1,96 +0,0 @@ | |||
1 | % RES = reconSpyr(PYR, INDICES, FILTFILE, EDGES, LEVS, BANDS) | ||
2 | % | ||
3 | % Reconstruct image from its steerable pyramid representation, as created | ||
4 | % by buildSpyr. | ||
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 | % FILTFILE (optional) should be a string referring to an m-file that returns | ||
11 | % the rfilters. examples: sp0Filters, sp1Filters, sp3Filters | ||
12 | % (default = 'sp1Filters'). | ||
13 | % EDGES specifies edge-handling, and defaults to 'reflect1' (see | ||
14 | % corrDn). | ||
15 | % | ||
16 | % LEVS (optional) should be a list of levels to include, or the string | ||
17 | % 'all' (default). 0 corresonds to the residual highpass subband. | ||
18 | % 1 corresponds to the finest oriented scale. The lowpass band | ||
19 | % corresponds to number spyrHt(INDICES)+1. | ||
20 | % | ||
21 | % BANDS (optional) should be a list of bands to include, or the string | ||
22 | % 'all' (default). 1 = vertical, rest proceeding anti-clockwise. | ||
23 | |||
24 | % Eero Simoncelli, 6/96. | ||
25 | |||
26 | function res = reconSpyr(pyr, pind, filtfile, edges, levs, bands) | ||
27 | |||
28 | %%------------------------------------------------------------ | ||
29 | %% DEFAULTS: | ||
30 | |||
31 | if (exist('filtfile') ~= 1) | ||
32 | filtfile = 'sp1Filters'; | ||
33 | end | ||
34 | |||
35 | if (exist('edges') ~= 1) | ||
36 | edges= 'reflect1'; | ||
37 | end | ||
38 | |||
39 | if (exist('levs') ~= 1) | ||
40 | levs = 'all'; | ||
41 | end | ||
42 | |||
43 | if (exist('bands') ~= 1) | ||
44 | bands = 'all'; | ||
45 | end | ||
46 | |||
47 | %%------------------------------------------------------------ | ||
48 | |||
49 | if (isstr(filtfile) & (exist(filtfile) == 2)) | ||
50 | [lo0filt,hi0filt,lofilt,bfilts,steermtx,harmonics] = eval(filtfile); | ||
51 | nbands = spyrNumBands(pind); | ||
52 | if ((nbands > 0) & (size(bfilts,2) ~= nbands)) | ||
53 | error('Number of pyramid bands is inconsistent with filter file'); | ||
54 | end | ||
55 | else | ||
56 | error('filtfile argument must be the name of an M-file containing SPYR filters.'); | ||
57 | end | ||
58 | |||
59 | maxLev = 1+spyrHt(pind); | ||
60 | if strcmp(levs,'all') | ||
61 | levs = [0:maxLev]'; | ||
62 | else | ||
63 | if (any(levs > maxLev) | any(levs < 0)) | ||
64 | error(sprintf('Level numbers must be in the range [0, %d].', maxLev)); | ||
65 | end | ||
66 | levs = levs(:); | ||
67 | end | ||
68 | |||
69 | if strcmp(bands,'all') | ||
70 | bands = [1:nbands]'; | ||
71 | else | ||
72 | if (any(bands < 1) | any(bands > nbands)) | ||
73 | error(sprintf('Band numbers must be in the range [1,3].', nbands)); | ||
74 | end | ||
75 | bands = bands(:); | ||
76 | end | ||
77 | |||
78 | if (spyrHt(pind) == 0) | ||
79 | if (any(levs==1)) | ||
80 | res1 = pyrBand(pyr,pind,2); | ||
81 | else | ||
82 | res1 = zeros(pind(2,:)); | ||
83 | end | ||
84 | else | ||
85 | res1 = reconSpyrLevs(pyr(1+prod(pind(1,:)):size(pyr,1)), ... | ||
86 | pind(2:size(pind,1),:), ... | ||
87 | lofilt, bfilts, edges, levs, bands); | ||
88 | end | ||
89 | |||
90 | res = upConv(res1, lo0filt, edges); | ||
91 | |||
92 | %% residual highpass subband | ||
93 | if any(levs == 0) | ||
94 | upConv( subMtx(pyr, pind(1,:)), hi0filt, edges, [1 1], [1 1], size(res), res); | ||
95 | end | ||
96 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/reconSpyrLevs.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/reconSpyrLevs.m deleted file mode 100755 index f8e456c..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/reconSpyrLevs.m +++ /dev/null | |||
@@ -1,46 +0,0 @@ | |||
1 | % RES = reconSpyrLevs(PYR,INDICES,LOFILT,BFILTS,EDGES,LEVS,BANDS) | ||
2 | % | ||
3 | % Recursive function for reconstructing levels of a steerable pyramid | ||
4 | % representation. This is called by reconSpyr, and is not usually | ||
5 | % called directly. | ||
6 | |||
7 | % Eero Simoncelli, 6/96. | ||
8 | |||
9 | function res = reconSpyrLevs(pyr,pind,lofilt,bfilts,edges,levs,bands); | ||
10 | |||
11 | nbands = size(bfilts,2); | ||
12 | lo_ind = nbands+1; | ||
13 | res_sz = pind(1,:); | ||
14 | |||
15 | % Assume square filters: | ||
16 | bfiltsz = round(sqrt(size(bfilts,1))); | ||
17 | |||
18 | if any(levs > 1) | ||
19 | |||
20 | if (size(pind,1) > lo_ind) | ||
21 | nres = reconSpyrLevs( pyr(1+sum(prod(pind(1:lo_ind-1,:)')):size(pyr,1)), ... | ||
22 | pind(lo_ind:size(pind,1),:), ... | ||
23 | lofilt, bfilts, edges, levs-1, bands); | ||
24 | else | ||
25 | nres = pyrBand(pyr,pind,lo_ind); % lowpass subband | ||
26 | end | ||
27 | |||
28 | res = upConv(nres, lofilt, edges, [2 2], [1 1], res_sz); | ||
29 | |||
30 | else | ||
31 | |||
32 | res = zeros(res_sz); | ||
33 | |||
34 | end | ||
35 | |||
36 | if any(levs == 1) | ||
37 | ind = 1; | ||
38 | for b = 1:nbands | ||
39 | if any(bands == b) | ||
40 | bfilt = reshape(bfilts(:,b), bfiltsz, bfiltsz); | ||
41 | upConv(reshape(pyr(ind:ind+prod(res_sz)-1), res_sz(1), res_sz(2)), ... | ||
42 | bfilt, edges, [1 1], [1 1], res_sz, res); | ||
43 | end | ||
44 | ind = ind + prod(res_sz); | ||
45 | end | ||
46 | end | ||
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 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/script_run_profile.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/script_run_profile.m deleted file mode 100755 index 133ca50..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/script_run_profile.m +++ /dev/null | |||
@@ -1,142 +0,0 @@ | |||
1 | % Example 2: Seamless blending of real and synthetic texture in an | ||
2 | % image, using Portilla-Simoncelli texture analysis/synthesis code, | ||
3 | % based on alternate projections onto statistical constraints in a | ||
4 | % complex overcomplete wavelet representation. | ||
5 | % | ||
6 | % See Readme.txt, and headers of textureAnalysis.m and | ||
7 | % textureSynthesis.m for more details. | ||
8 | % | ||
9 | % Javier Portilla (javier@decsai.ugr.es). March, 2001 | ||
10 | |||
11 | function script_run_profile(dataDir, resultDir, type, common,toolDir) | ||
12 | |||
13 | path(path, common); | ||
14 | Files = dir([dataDir,'/1.bmp']); | ||
15 | inputFile = fullfile(dataDir,Files(1).name); | ||
16 | |||
17 | close all | ||
18 | |||
19 | Nsc = 4; % Number of scales | ||
20 | Nor = 4; % Number of orientations | ||
21 | Na = 5; % Spatial neighborhood is Na x Na coefficients | ||
22 | % It must be an odd number! | ||
23 | Niter = 25; % Number of iterations of synthesis loop | ||
24 | Nsx = 192; % Size of synthetic image is Nsy x Nsx | ||
25 | Nsy = 192; % Warning: both dimensions must be multiple of 2^(Nsc+2) | ||
26 | |||
27 | if(strcmp(type,'qcif')) | ||
28 | Nsc = 4; | ||
29 | Nor = 4; | ||
30 | Na = 5; | ||
31 | Niter = 5; | ||
32 | elseif(strcmp(type,'sqcif')) | ||
33 | Nsc = 2; | ||
34 | Nor = 2; | ||
35 | Na = 3; | ||
36 | Niter = 5; | ||
37 | elseif(strcmp(type, 'test')) | ||
38 | Nsc = 2; % Number of scales | ||
39 | Nor = 2; % Number of orientations | ||
40 | Na = 1; % Spatial neighborhood is Na x Na coefficients | ||
41 | % It must be an odd number! | ||
42 | Niter = 1; % Number of iterations of synthesis loop | ||
43 | Nsx = 16; % Size of synthetic image is Nsy x Nsx | ||
44 | Nsy = 16; % Warning: both dimensions must be multiple of 2^(Nsc+2) | ||
45 | |||
46 | elseif(strcmp(type, 'sim_fast')) | ||
47 | Nsc = 2; % Number of scales | ||
48 | Nor = 2; % Number of orientations | ||
49 | Na = 3; % Spatial neighborhood is Na x Na coefficients | ||
50 | % It must be an odd number! | ||
51 | Niter = 2; % Number of iterations of synthesis loop | ||
52 | Nsx = 16; % Size of synthetic image is Nsy x Nsx | ||
53 | Nsy = 16; % Warning: both dimensions must be multiple of 2^(Nsc+2) | ||
54 | |||
55 | elseif(strcmp(type, 'sim')) | ||
56 | Nsc = 2; % Number of scales | ||
57 | Nor = 2; % Number of orientations | ||
58 | Na = 3; % Spatial neighborhood is Na x Na coefficients | ||
59 | % It must be an odd number! | ||
60 | Niter = 1; % Number of iterations of synthesis loop | ||
61 | Nsx = 32; % Size of synthetic image is Nsy x Nsx | ||
62 | Nsy = 32; % Warning: both dimensions must be multiple of 2^(Nsc+2) | ||
63 | |||
64 | elseif(strcmp(type, 'vga')) | ||
65 | Nsc = 2; % Number of scales | ||
66 | Nor = 2; % Number of orientations | ||
67 | Na = 3; % Spatial neighborhood is Na x Na coefficients | ||
68 | % It must be an odd number! | ||
69 | Niter = 1; % Number of iterations of synthesis loop | ||
70 | Nsx = 640; % Size of synthetic image is Nsy x Nsx | ||
71 | Nsy = 480; % Warning: both dimensions must be multiple of 2^(Nsc+2) | ||
72 | |||
73 | elseif(strcmp(type, 'real')) | ||
74 | Nsc = 2; % Number of scales | ||
75 | Nor = 2; % Number of orientations | ||
76 | Na = 3; % Spatial neighborhood is Na x Na coefficients | ||
77 | % It must be an odd number! | ||
78 | Niter = 1; % Number of iterations of synthesis loop | ||
79 | Nsx = 1920; % Size of synthetic image is Nsy x Nsx | ||
80 | Nsy = 1200; % Warning: both dimensions must be multiple of 2^(Nsc+2) | ||
81 | |||
82 | end | ||
83 | |||
84 | im0 = readImage(inputFile); % Warning: im0 is a double float matrix! | ||
85 | rows = size(im0,1); | ||
86 | cols = size(im0,2); | ||
87 | fprintf(1,'Input size\t\t- (%dx%d)\n', rows, cols); | ||
88 | |||
89 | %% Self check params | ||
90 | tol = 0.1; | ||
91 | elapsed = zeros(1,2); | ||
92 | |||
93 | %% Timing | ||
94 | start = photonStartTiming; | ||
95 | |||
96 | params = textureAnalysis(im0, Nsc, Nor, Na); | ||
97 | |||
98 | %% Timing | ||
99 | stop = photonEndTiming; | ||
100 | |||
101 | temp = photonReportTiming(start, stop); | ||
102 | elapsed(1) = elapsed(1) + temp(1); | ||
103 | elapsed(2) = elapsed(2) + temp(2); | ||
104 | |||
105 | % Use a mask and the original image to synthesize an image with the | ||
106 | % left side synthetic and the right side real data. | ||
107 | % The effective mask is M = (mask>0), its smoothness is for avoiding | ||
108 | % border effects. | ||
109 | ramp = meshgrid(1:Nsx/4,1:Nsy)*4/Nsy; | ||
110 | mask = [zeros(Nsy,Nsx/2) ramp ramp(:,Nsx/4:-1:1)]; | ||
111 | mask = 1/2*(1-cos(pi*mask)); | ||
112 | |||
113 | imKeep = zeros(Nsx*Nsy,2); | ||
114 | imKeep(:,1) = reshape(mask, [Nsy*Nsx,1]); | ||
115 | imKeep(:,2) = reshape(im0(1:Nsy,1:Nsx), [Nsy*Nsx,1]); % Original | ||
116 | |||
117 | %% Timing | ||
118 | start = photonStartTiming; | ||
119 | |||
120 | res = textureSynthesis(params, [Nsy Nsx], Niter,[],imKeep); | ||
121 | |||
122 | %% Timing | ||
123 | stop = photonEndTiming; | ||
124 | |||
125 | temp = photonReportTiming(start, stop); | ||
126 | elapsed(1) = elapsed(1) + temp(1); | ||
127 | elapsed(2) = elapsed(2) + temp(2); | ||
128 | |||
129 | %% Self checking | ||
130 | fWriteMatrix(res, dataDir); | ||
131 | |||
132 | rows = Nsy; | ||
133 | cols = Nsx; | ||
134 | |||
135 | %% Timing | ||
136 | photonPrintTiming(elapsed); | ||
137 | |||
138 | %close all | ||
139 | %figure(1);showIm(mask>0, 'auto', 'auto', 'Mask'); | ||
140 | %figure(2);showIm(im0, 'auto', 'auto', 'Original Texture'); | ||
141 | %figure(3);showIm(res, 'auto', 'auto', 'Blended Original and Synthetic Texture'); | ||
142 | %pause; | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/script_run_profile1.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/script_run_profile1.m deleted file mode 100755 index 2a7a0dc..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/script_run_profile1.m +++ /dev/null | |||
@@ -1,34 +0,0 @@ | |||
1 | % Example 1: Synthesis of a "text" texture image, using | ||
2 | % Portilla-Simoncelli texture analysis/synthesis code, based on | ||
3 | % alternate projections onto statistical constraints in a complex | ||
4 | % overcomplete wavelet representation. | ||
5 | % | ||
6 | % See Readme.txt, and headers of textureAnalysis.m and | ||
7 | % textureSynthesis.m for more details. | ||
8 | % | ||
9 | % Javier Portilla (javier@decsai.ugr.es). March, 2001 | ||
10 | |||
11 | close all | ||
12 | |||
13 | im0 = imread('/u/kvs/VisionBenchmark/texture_synthesis/result/text.pgm'); % im0 is a double float matrix! | ||
14 | |||
15 | Nsc = 4; % Number of scales | ||
16 | Nor = 4; % Number of orientations | ||
17 | Na = 9; % Spatial neighborhood is Na x Na coefficients | ||
18 | % It must be an odd number! | ||
19 | |||
20 | params = textureAnalysis(im0, Nsc, Nor, Na); | ||
21 | |||
22 | Niter = 25; % Number of iterations of synthesis loop | ||
23 | Nsx = 192; % Size of synthetic image is Nsy x Nsx | ||
24 | Nsy = 128; % WARNING: Both dimensions must be multiple of 2^(Nsc+2) | ||
25 | |||
26 | res = textureSynthesis(params, [Nsy Nsx], Niter); | ||
27 | |||
28 | close all | ||
29 | figure(1) | ||
30 | showIm(im0, 'auto', 1, 'Original texture'); | ||
31 | figure(2) | ||
32 | showIm(res, 'auto', 1, 'Synthesized texture'); | ||
33 | |||
34 | % Can you read the NEW text? ;-) | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/setPyrBand.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/setPyrBand.m deleted file mode 100755 index baa9f77..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/setPyrBand.m +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | % NEWPYR = setPyrBand(PYR, INDICES, BAND, BAND_NUM) | ||
2 | % | ||
3 | % Insert an image (BAND) into a pyramid (gaussian, laplacian, QMF/wavelet, | ||
4 | % or steerable). Subbands are numbered consecutively, from finest | ||
5 | % (highest spatial frequency) to coarsest (lowest spatial frequency). | ||
6 | |||
7 | % Eero Simoncelli, 1/03. | ||
8 | |||
9 | function pyr = pyrBand(pyr, pind, band, bandNum) | ||
10 | |||
11 | %% Check: PIND a valid index matrix? | ||
12 | if ( ~(ndims(pind) == 2) | ~(size(pind,2) == 2) | ~all(pind==round(pind)) ) | ||
13 | pind | ||
14 | error('pyrTools:badArg',... | ||
15 | 'PIND argument is not an Nbands X 2 matrix of integers'); | ||
16 | end | ||
17 | |||
18 | %% Check: PIND consistent with size of PYR? | ||
19 | if ( length(pyr) ~= sum(prod(pind,2)) ) | ||
20 | error('pyrTools:badPyr',... | ||
21 | 'Pyramid data vector length is inconsistent with index matrix PIND'); | ||
22 | end | ||
23 | |||
24 | %% Check: size of BAND consistent with desired BANDNUM? | ||
25 | if (~all(size(band) == pind(bandNum,:))) | ||
26 | size(band) | ||
27 | pind(bandNum,:) | ||
28 | error('pyrTools:badArg',... | ||
29 | 'size of BAND to be inserted is inconsistent with BAND_NUM'); | ||
30 | end | ||
31 | |||
32 | pyr(pyrBandIndices(pind,bandNum)) = vectify(band); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/shift.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/shift.m deleted file mode 100755 index 497297e..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/shift.m +++ /dev/null | |||
@@ -1,15 +0,0 @@ | |||
1 | % [RES] = shift(MTX, OFFSET) | ||
2 | % | ||
3 | % Circular shift 2D matrix samples by OFFSET (a [Y,X] 2-vector), | ||
4 | % such that RES(POS) = MTX(POS-OFFSET). | ||
5 | |||
6 | function res = shift(mtx, offset) | ||
7 | |||
8 | dims = size(mtx); | ||
9 | |||
10 | offset = mod(-offset,dims); | ||
11 | |||
12 | res = [ mtx(offset(1)+1:dims(1), offset(2)+1:dims(2)), ... | ||
13 | mtx(offset(1)+1:dims(1), 1:offset(2)); ... | ||
14 | mtx(1:offset(1), offset(2)+1:dims(2)), ... | ||
15 | mtx(1:offset(1), 1:offset(2)) ]; | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/showIm.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/showIm.m deleted file mode 100755 index a9e2bd1..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/showIm.m +++ /dev/null | |||
@@ -1,221 +0,0 @@ | |||
1 | % RANGE = showIm (MATRIX, RANGE, ZOOM, LABEL, NSHADES ) | ||
2 | % | ||
3 | % Display a MatLab MATRIX as a grayscale image in the current figure, | ||
4 | % inside the current axes. If MATRIX is complex, the real and imaginary | ||
5 | % parts are shown side-by-side, with the same grayscale mapping. | ||
6 | % | ||
7 | % If MATRIX is a string, it should be the name of a variable bound to a | ||
8 | % MATRIX in the base (global) environment. This matrix is displayed as an | ||
9 | % image, with the title set to the string. | ||
10 | % | ||
11 | % RANGE (optional) is a 2-vector specifying the values that map to | ||
12 | % black and white, respectively. Passing a value of 'auto' (default) | ||
13 | % sets RANGE=[min,max] (as in MatLab's imagesc). 'auto2' sets | ||
14 | % RANGE=[mean-2*stdev, mean+2*stdev]. 'auto3' sets | ||
15 | % RANGE=[p1-(p2-p1)/8, p2+(p2-p1)/8], where p1 is the 10th percentile | ||
16 | % value of the sorted MATRIX samples, and p2 is the 90th percentile | ||
17 | % value. | ||
18 | % | ||
19 | % ZOOM specifies the number of matrix samples per screen pixel. It | ||
20 | % will be rounded to an integer, or 1 divided by an integer. A value | ||
21 | % of 'same' or 'auto' (default) causes the zoom value to be chosen | ||
22 | % automatically to fit the image into the current axes. A value of | ||
23 | % 'full' fills the axis region (leaving no room for labels). See | ||
24 | % pixelAxes.m. | ||
25 | % | ||
26 | % If LABEL (optional, default = 1, unless zoom='full') is non-zero, the range | ||
27 | % of values that are mapped into the gray colormap and the dimensions | ||
28 | % (size) of the matrix and zoom factor are printed below the image. If label | ||
29 | % is a string, it is used as a title. | ||
30 | % | ||
31 | % NSHADES (optional) specifies the number of gray shades, and defaults | ||
32 | % to the size of the current colormap. | ||
33 | |||
34 | % Eero Simoncelli, 6/96. | ||
35 | |||
36 | %%TODO: should use "newplot" | ||
37 | |||
38 | function range = showIm( im, range, zoom, label, nshades ); | ||
39 | |||
40 | %------------------------------------------------------------ | ||
41 | %% OPTIONAL ARGS: | ||
42 | |||
43 | if (nargin < 1) | ||
44 | error('Requires at least one input argument.'); | ||
45 | end | ||
46 | |||
47 | MLv = version; | ||
48 | |||
49 | if isstr(im) | ||
50 | if (strcmp(MLv(1),'4')) | ||
51 | error('Cannot pass string arg for MATRIX in MatLab version 4.x'); | ||
52 | end | ||
53 | label = im; | ||
54 | im = evalin('base',im); | ||
55 | end | ||
56 | |||
57 | if (exist('range') ~= 1) | ||
58 | range = 'auto1'; | ||
59 | end | ||
60 | |||
61 | if (exist('nshades') ~= 1) | ||
62 | nshades = size(colormap,1); | ||
63 | end | ||
64 | nshades = max( nshades, 2 ); | ||
65 | |||
66 | if (exist('zoom') ~= 1) | ||
67 | zoom = 'auto'; | ||
68 | end | ||
69 | |||
70 | if (exist('label') ~= 1) | ||
71 | if strcmp(zoom,'full') | ||
72 | label = 0; % no labeling | ||
73 | else | ||
74 | label = 1; % just print grayrange & dims | ||
75 | end | ||
76 | end | ||
77 | |||
78 | %------------------------------------------------------------ | ||
79 | |||
80 | %% Automatic range calculation: | ||
81 | if (strcmp(range,'auto1') | strcmp(range,'auto')) | ||
82 | if isreal(im) | ||
83 | [mn,mx] = range2(im); | ||
84 | else | ||
85 | [mn1,mx1] = range2(real(im)); | ||
86 | [mn2,mx2] = range2(imag(im)); | ||
87 | mn = min(mn1,mn2); | ||
88 | mx = max(mx1,mx2); | ||
89 | end | ||
90 | if any(size(im)==1) | ||
91 | pad = (mx-mn)/12; % MAGIC NUMBER: graph padding | ||
92 | range = [mn-pad, mx+pad]; | ||
93 | else | ||
94 | range = [mn,mx]; | ||
95 | end | ||
96 | |||
97 | elseif strcmp(range,'auto2') | ||
98 | if isreal(im) | ||
99 | stdev = sqrt(var2(im)); | ||
100 | av = mean2(im); | ||
101 | else | ||
102 | stdev = sqrt((var2(real(im)) + var2(imag(im)))/2); | ||
103 | av = (mean2(real(im)) + mean2(imag(im)))/2; | ||
104 | end | ||
105 | range = [av-2*stdev,av+2*stdev]; % MAGIC NUMBER: 2 stdevs | ||
106 | |||
107 | elseif strcmp(range, 'auto3') | ||
108 | percentile = 0.1; % MAGIC NUMBER: 0<p<0.5 | ||
109 | [N,X] = histo(im); | ||
110 | binsz = X(2)-X(1); | ||
111 | N = N+1e-10; % Ensure cumsum will be monotonic for call to interp1 | ||
112 | cumN = [0, cumsum(N)]/sum(N); | ||
113 | cumX = [X(1)-binsz, X] + (binsz/2); | ||
114 | ctrRange = interp1(cumN,cumX, [percentile, 1-percentile]); | ||
115 | range = mean(ctrRange) + (ctrRange-mean(ctrRange))/(1-2*percentile); | ||
116 | |||
117 | elseif isstr(range) | ||
118 | error(sprintf('Bad RANGE argument: %s',range)) | ||
119 | |||
120 | end | ||
121 | |||
122 | if ((range(2) - range(1)) <= eps) | ||
123 | range(1) = range(1) - 0.5; | ||
124 | range(2) = range(2) + 0.5; | ||
125 | end | ||
126 | |||
127 | |||
128 | if isreal(im) | ||
129 | factor=1; | ||
130 | else | ||
131 | factor = 1+sqrt(-1); | ||
132 | end | ||
133 | |||
134 | xlbl_offset = 0; % default value | ||
135 | |||
136 | if (~any(size(im)==1)) | ||
137 | %% MatLab's "image" rounds when mapping to the colormap, so we compute | ||
138 | %% (im-r1)*(nshades-1)/(r2-r1) + 1.5 | ||
139 | mult = ((nshades-1) / (range(2)-range(1))); | ||
140 | d_im = (mult * im) + factor*(1.5 - range(1)*mult); | ||
141 | end | ||
142 | |||
143 | if isreal(im) | ||
144 | if (any(size(im)==1)) | ||
145 | hh = plot( im); | ||
146 | axis([1, prod(size(im)), range]); | ||
147 | else | ||
148 | hh = image( d_im ); | ||
149 | axis('off'); | ||
150 | zoom = pixelAxes(size(d_im),zoom); | ||
151 | end | ||
152 | else | ||
153 | if (any(size(im)==1)) | ||
154 | subplot(2,1,1); | ||
155 | hh = plot(real(im)); | ||
156 | axis([1, prod(size(im)), range]); | ||
157 | subplot(2,1,2); | ||
158 | hh = plot(imag(im)); | ||
159 | axis([1, prod(size(im)), range]); | ||
160 | else | ||
161 | subplot(1,2,1); | ||
162 | hh = image(real(d_im)); | ||
163 | axis('off'); zoom = pixelAxes(size(d_im),zoom); | ||
164 | ax = gca; orig_units = get(ax,'Units'); | ||
165 | set(ax,'Units','points'); | ||
166 | pos1 = get(ax,'Position'); | ||
167 | set(ax,'Units',orig_units); | ||
168 | subplot(1,2,2); | ||
169 | hh = image(imag(d_im)); | ||
170 | axis('off'); zoom = pixelAxes(size(d_im),zoom); | ||
171 | ax = gca; orig_units = get(ax,'Units'); | ||
172 | set(ax,'Units','points'); | ||
173 | pos2 = get(ax,'Position'); | ||
174 | set(ax,'Units',orig_units); | ||
175 | xlbl_offset = (pos1(1)-pos2(1))/2; | ||
176 | end | ||
177 | end | ||
178 | |||
179 | if ~any(size(im)==1) | ||
180 | colormap(gray(nshades)); | ||
181 | end | ||
182 | |||
183 | if ((label ~= 0)) | ||
184 | if isstr(label) | ||
185 | title(label); | ||
186 | h = get(gca,'Title'); | ||
187 | orig_units = get(h,'Units'); | ||
188 | set(h,'Units','points'); | ||
189 | pos = get(h,'Position'); | ||
190 | pos(1:2) = pos(1:2) + [xlbl_offset, -3]; % MAGIC NUMBER: y pixel offset | ||
191 | set(h,'Position',pos); | ||
192 | set(h,'Units',orig_units); | ||
193 | end | ||
194 | |||
195 | if (~any(size(im)==1)) | ||
196 | if (zoom > 1) | ||
197 | zformat = sprintf('* %d',round(zoom)); | ||
198 | else | ||
199 | zformat = sprintf('/ %d',round(1/zoom)); | ||
200 | end | ||
201 | if isreal(im) | ||
202 | format=[' Range: [%.3g, %.3g] \n Dims: [%d, %d] ', zformat]; | ||
203 | else | ||
204 | format=['Range: [%.3g, %.3g] ---- Dims: [%d, %d]', zformat]; | ||
205 | end | ||
206 | xlabel(sprintf(format, range(1), range(2), size(im,1), size(im,2))); | ||
207 | h = get(gca,'Xlabel'); | ||
208 | set(h,'FontSize', 9); % MAGIC NUMBER: font size!!! | ||
209 | |||
210 | orig_units = get(h,'Units'); | ||
211 | set(h,'Units','points'); | ||
212 | pos = get(h,'Position'); | ||
213 | pos(1:2) = pos(1:2) + [xlbl_offset, 10]; % MAGIC NUMBER: y offset in points | ||
214 | set(h,'Position',pos); | ||
215 | set(h,'Units',orig_units); | ||
216 | |||
217 | set(h,'Visible','on'); % axis('image') turned the xlabel off... | ||
218 | end | ||
219 | end | ||
220 | |||
221 | return; | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/showLpyr.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/showLpyr.m deleted file mode 100755 index 0d85f9d..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/showLpyr.m +++ /dev/null | |||
@@ -1,202 +0,0 @@ | |||
1 | % RANGE = showLpyr (PYR, INDICES, RANGE, GAP, LEVEL_SCALE_FACTOR) | ||
2 | % | ||
3 | % Display a Laplacian (or Gaussian) pyramid, specified by PYR and | ||
4 | % INDICES (see buildLpyr), 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-normalalized 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] = showLpyr(pyr, pind, range, gap, scale); | ||
30 | |||
31 | % Determine 1D or 2D pyramid: | ||
32 | if ((pind(1,1) == 1) | (pind(1,2) ==1)) | ||
33 | oned = 1; | ||
34 | else | ||
35 | oned = 0; | ||
36 | end | ||
37 | |||
38 | %------------------------------------------------------------ | ||
39 | %% OPTIONAL ARGS: | ||
40 | |||
41 | if (exist('range') ~= 1) | ||
42 | if (oned==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 (oned == 1) | ||
55 | scale = sqrt(2); | ||
56 | else | ||
57 | scale = 2; | ||
58 | end | ||
59 | end | ||
60 | |||
61 | %------------------------------------------------------------ | ||
62 | |||
63 | nind = size(pind,1); | ||
64 | |||
65 | %% Auto range calculations: | ||
66 | if strcmp(range,'auto1') | ||
67 | range = zeros(nind,1); | ||
68 | mn = 0.0; mx = 0.0; | ||
69 | for bnum = 1:(nind-1) | ||
70 | band = pyrBand(pyr,pind,bnum)/(scale^(bnum-1)); | ||
71 | range(bnum) = scale^(bnum-1); | ||
72 | [bmn,bmx] = range2(band); | ||
73 | mn = min(mn, bmn); mx = max(mx, bmx); | ||
74 | end | ||
75 | if (oned == 1) | ||
76 | pad = (mx-mn)/12; % *** MAGIC NUMBER!! | ||
77 | mn = mn-pad; mx = mx+pad; | ||
78 | end | ||
79 | range = range * [mn mx]; % outer product | ||
80 | band = pyrLow(pyr,pind); | ||
81 | [mn,mx] = range2(band); | ||
82 | if (oned == 1) | ||
83 | pad = (mx-mn)/12; % *** MAGIC NUMBER!! | ||
84 | mn = mn-pad; mx = mx+pad; | ||
85 | end | ||
86 | range(nind,:) = [mn, mx]; | ||
87 | |||
88 | elseif strcmp(range,'indep1') | ||
89 | range = zeros(nind,2); | ||
90 | for bnum = 1:nind | ||
91 | band = pyrBand(pyr,pind,bnum); | ||
92 | [mn,mx] = range2(band); | ||
93 | if (oned == 1) | ||
94 | pad = (mx-mn)/12; % *** MAGIC NUMBER!! | ||
95 | mn = mn-pad; mx = mx+pad; | ||
96 | end | ||
97 | range(bnum,:) = [mn mx]; | ||
98 | end | ||
99 | |||
100 | elseif strcmp(range,'auto2') | ||
101 | range = zeros(nind,1); | ||
102 | sqsum = 0; numpixels = 0; | ||
103 | for bnum = 1:(nind-1) | ||
104 | band = pyrBand(pyr,pind,bnum)/(scale^(bnum-1)); | ||
105 | sqsum = sqsum + sum(sum(band.^2)); | ||
106 | numpixels = numpixels + prod(size(band)); | ||
107 | range(bnum) = scale^(bnum-1); | ||
108 | end | ||
109 | stdev = sqrt(sqsum/(numpixels-1)); | ||
110 | range = range * [ -3*stdev 3*stdev ]; % outer product | ||
111 | band = pyrLow(pyr,pind); | ||
112 | av = mean2(band); stdev = sqrt(var2(band)); | ||
113 | range(nind,:) = [av-2*stdev,av+2*stdev]; | ||
114 | |||
115 | elseif strcmp(range,'indep2') | ||
116 | range = zeros(nind,2); | ||
117 | for bnum = 1:(nind-1) | ||
118 | band = pyrBand(pyr,pind,bnum); | ||
119 | stdev = sqrt(var2(band)); | ||
120 | range(bnum,:) = [ -3*stdev 3*stdev ]; | ||
121 | end | ||
122 | band = pyrLow(pyr,pind); | ||
123 | av = mean2(band); stdev = sqrt(var2(band)); | ||
124 | range(nind,:) = [av-2*stdev,av+2*stdev]; | ||
125 | |||
126 | elseif isstr(range) | ||
127 | error(sprintf('Bad RANGE argument: %s',range)) | ||
128 | |||
129 | elseif ((size(range,1) == 1) & (size(range,2) == 2)) | ||
130 | scales = scale.^[0:nind-1]; | ||
131 | range = scales(:) * range; % outer product | ||
132 | band = pyrLow(pyr,pind); | ||
133 | range(nind,:) = range(nind,:) + mean2(band) - mean(range(nind,:)); | ||
134 | |||
135 | end | ||
136 | |||
137 | %% Clear Figure | ||
138 | clf; | ||
139 | |||
140 | if (oned == 1) | ||
141 | |||
142 | %%%%% 1D signal: | ||
143 | for bnum=1:nind | ||
144 | band = pyrBand(pyr,pind,bnum); | ||
145 | subplot(nind,1,nind-bnum+1); | ||
146 | plot(band); | ||
147 | axis([1, prod(size(band)), range(bnum,:)]); | ||
148 | end | ||
149 | |||
150 | else | ||
151 | |||
152 | %%%%% 2D signal: | ||
153 | colormap(gray); | ||
154 | cmap = get(gcf,'Colormap'); | ||
155 | nshades = size(cmap,1); | ||
156 | |||
157 | % Find background color index: | ||
158 | clr = get(gcf,'Color'); | ||
159 | bg = 1; | ||
160 | dist = norm(cmap(bg,:)-clr); | ||
161 | for n = 1:nshades | ||
162 | ndist = norm(cmap(n,:)-clr); | ||
163 | if (ndist < dist) | ||
164 | dist = ndist; | ||
165 | bg = n; | ||
166 | end | ||
167 | end | ||
168 | |||
169 | %% Compute positions of subbands: | ||
170 | llpos = ones(nind,2); | ||
171 | dir = [-1 -1]; | ||
172 | ctr = [pind(1,1)+1+gap 1]; | ||
173 | sz = [0 0]; | ||
174 | for bnum = 1:nind | ||
175 | prevsz = sz; | ||
176 | sz = pind(bnum,:); | ||
177 | |||
178 | % Determine center position of new band: | ||
179 | ctr = ctr + gap*dir/2 + dir.* floor((prevsz+(dir>0))/2); | ||
180 | dir = dir * [0 -1; 1 0]; % ccw rotation | ||
181 | ctr = ctr + gap*dir/2 + dir.* floor((sz+(dir<0))/2); | ||
182 | llpos(bnum,:) = ctr - floor(sz./2); | ||
183 | end | ||
184 | |||
185 | %% Make position list positive, and allocate appropriate image: | ||
186 | llpos = llpos - ones(nind,1)*min(llpos) + 1; | ||
187 | urpos = llpos + pind - 1; | ||
188 | d_im = bg + zeros(max(urpos)); | ||
189 | |||
190 | %% Paste bands into image, (im-r1)*(nshades-1)/(r2-r1) + 1.5 | ||
191 | for bnum=1:nind | ||
192 | mult = (nshades-1) / (range(bnum,2)-range(bnum,1)); | ||
193 | d_im(llpos(bnum,1):urpos(bnum,1), llpos(bnum,2):urpos(bnum,2)) = ... | ||
194 | mult*pyrBand(pyr,pind,bnum) + (1.5-mult*range(bnum,1)); | ||
195 | end | ||
196 | |||
197 | hh = image(d_im); | ||
198 | axis('off'); | ||
199 | pixelAxes(size(d_im),'full'); | ||
200 | set(hh,'UserData',range); | ||
201 | |||
202 | end | ||
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 | |||
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; | ||
190 | d_im = bg + zeros(max(urpos)); | ||
191 | |||
192 | %% Paste bands into image, (im-r1)*(nshades-1)/(r2-r1) + 1.5 | ||
193 | for bnum=1:nind | ||
194 | mult = (nshades-1) / (range(bnum,2)-range(bnum,1)); | ||
195 | d_im(llpos(bnum,1):urpos(bnum,1), llpos(bnum,2):urpos(bnum,2)) = ... | ||
196 | mult*pyrBand(pyr,pind,bnum) + (1.5-mult*range(bnum,1)); | ||
197 | end | ||
198 | |||
199 | hh = image(d_im); | ||
200 | axis('off'); | ||
201 | pixelAxes(size(d_im),'full'); | ||
202 | set(hh,'UserData',range); | ||
203 | |||
204 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/shrink.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/shrink.m deleted file mode 100755 index 7af0151..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/shrink.m +++ /dev/null | |||
@@ -1,25 +0,0 @@ | |||
1 | function ts=shrink(t,f) | ||
2 | |||
3 | % It shrinks an image in a factor f | ||
4 | % in each dimension. | ||
5 | % ts = shrink(t,f) | ||
6 | % ts may also be complex. | ||
7 | % See also: expand.m, blurDn.m | ||
8 | % JPM, April 95, Instituto de Optica, CSIC, Madrid. | ||
9 | |||
10 | [my,mx]=size(t); | ||
11 | T=fftshift(fft2(t))/f^2; | ||
12 | Ts=zeros(my/f,mx/f); | ||
13 | y1=my/2+2-my/(2*f); | ||
14 | y2=my/2+my/(2*f); | ||
15 | x1=mx/2+2-mx/(2*f); | ||
16 | x2=mx/2+mx/(2*f); | ||
17 | Ts(2:my/f,2:mx/f)=T(y1:y2,x1:x2); | ||
18 | Ts(1,2:mx/f)=(T(y1-1,x1:x2)+T(y2+1,x1:x2))/2; | ||
19 | Ts(2:my/f,1)=(T(y1:y2,x1-1)+T(y1:y2,x2+1))/2; | ||
20 | Ts(1,1)=(T(y1-1,x1-1)+T(y1-1,x2+1)+T(y2+1,x1-1)+T(y2+1,x2+1))/4; | ||
21 | Ts=fftshift(Ts); | ||
22 | ts=ifft2(Ts); | ||
23 | if all(imag(t)==0), | ||
24 | ts = real(ts); | ||
25 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/skew2.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/skew2.m deleted file mode 100755 index 623d6ca..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/skew2.m +++ /dev/null | |||
@@ -1,21 +0,0 @@ | |||
1 | % S = SKEW2(MTX,MEAN,VAR) | ||
2 | % | ||
3 | % Sample skew (third moment divided by variance^3/2) of a matrix. | ||
4 | % MEAN (optional) and VAR (optional) make the computation faster. | ||
5 | |||
6 | function res = skew2(mtx, mn, v) | ||
7 | |||
8 | if (exist('mn') ~= 1) | ||
9 | mn = mean2(mtx); | ||
10 | end | ||
11 | |||
12 | if (exist('v') ~= 1) | ||
13 | v = var2(mtx,mn); | ||
14 | end | ||
15 | |||
16 | if (isreal(mtx)) | ||
17 | res = mean(mean((mtx-mn).^3)) / (v^(3/2)); | ||
18 | else | ||
19 | res = mean(mean(real(mtx-mn).^3)) / (real(v)^(3/2)) + ... | ||
20 | i * mean(mean(imag(mtx-mn).^3)) / (imag(v)^(3/2)); | ||
21 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/snr.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/snr.m deleted file mode 100755 index 3945d90..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/snr.m +++ /dev/null | |||
@@ -1,10 +0,0 @@ | |||
1 | function X=SNR(s,n); | ||
2 | |||
3 | % Compute the signal-to-noise ratio in dB | ||
4 | % X=SNR(signal,noise); | ||
5 | % (it does not subtract the means). | ||
6 | |||
7 | es=sum(sum(abs(s).^2))+0.0000001; | ||
8 | en=sum(sum(abs(n).^2))+0.0000001; | ||
9 | X=10*log10(es/en); | ||
10 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/sp0Filters.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/sp0Filters.m deleted file mode 100755 index 6b25e36..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/sp0Filters.m +++ /dev/null | |||
@@ -1,72 +0,0 @@ | |||
1 | % Steerable pyramid filters. Transform described in: | ||
2 | % | ||
3 | % @INPROCEEDINGS{Simoncelli95b, | ||
4 | % TITLE = "The Steerable Pyramid: A Flexible Architecture for | ||
5 | % Multi-Scale Derivative Computation", | ||
6 | % AUTHOR = "E P Simoncelli and W T Freeman", | ||
7 | % BOOKTITLE = "Second Int'l Conf on Image Processing", | ||
8 | % ADDRESS = "Washington, DC", MONTH = "October", YEAR = 1995 } | ||
9 | % | ||
10 | % Filter kernel design described in: | ||
11 | % | ||
12 | %@INPROCEEDINGS{Karasaridis96, | ||
13 | % TITLE = "A Filter Design Technique for | ||
14 | % Steerable Pyramid Image Transforms", | ||
15 | % AUTHOR = "A Karasaridis and E P Simoncelli", | ||
16 | % BOOKTITLE = "ICASSP", ADDRESS = "Atlanta, GA", | ||
17 | % MONTH = "May", YEAR = 1996 } | ||
18 | |||
19 | % Eero Simoncelli, 6/96. | ||
20 | |||
21 | function [lo0filt,hi0filt,lofilt,bfilts,mtx,harmonics] = sp0Filters(); | ||
22 | |||
23 | harmonics = [ 0 ]; | ||
24 | |||
25 | lo0filt = [ ... | ||
26 | -4.514000e-04 -1.137100e-04 -3.725800e-04 -3.743860e-03 -3.725800e-04 -1.137100e-04 -4.514000e-04 | ||
27 | -1.137100e-04 -6.119520e-03 -1.344160e-02 -7.563200e-03 -1.344160e-02 -6.119520e-03 -1.137100e-04 | ||
28 | -3.725800e-04 -1.344160e-02 6.441488e-02 1.524935e-01 6.441488e-02 -1.344160e-02 -3.725800e-04 | ||
29 | -3.743860e-03 -7.563200e-03 1.524935e-01 3.153017e-01 1.524935e-01 -7.563200e-03 -3.743860e-03 | ||
30 | -3.725800e-04 -1.344160e-02 6.441488e-02 1.524935e-01 6.441488e-02 -1.344160e-02 -3.725800e-04 | ||
31 | -1.137100e-04 -6.119520e-03 -1.344160e-02 -7.563200e-03 -1.344160e-02 -6.119520e-03 -1.137100e-04 | ||
32 | -4.514000e-04 -1.137100e-04 -3.725800e-04 -3.743860e-03 -3.725800e-04 -1.137100e-04 -4.514000e-04]; | ||
33 | |||
34 | lofilt = [ ... | ||
35 | -2.257000e-04 -8.064400e-04 -5.686000e-05 8.741400e-04 -1.862800e-04 -1.031640e-03 -1.871920e-03 -1.031640e-03 -1.862800e-04 8.741400e-04 -5.686000e-05 -8.064400e-04 -2.257000e-04 | ||
36 | -8.064400e-04 1.417620e-03 -1.903800e-04 -2.449060e-03 -4.596420e-03 -7.006740e-03 -6.948900e-03 -7.006740e-03 -4.596420e-03 -2.449060e-03 -1.903800e-04 1.417620e-03 -8.064400e-04 | ||
37 | -5.686000e-05 -1.903800e-04 -3.059760e-03 -6.401000e-03 -6.720800e-03 -5.236180e-03 -3.781600e-03 -5.236180e-03 -6.720800e-03 -6.401000e-03 -3.059760e-03 -1.903800e-04 -5.686000e-05 | ||
38 | 8.741400e-04 -2.449060e-03 -6.401000e-03 -5.260020e-03 3.938620e-03 1.722078e-02 2.449600e-02 1.722078e-02 3.938620e-03 -5.260020e-03 -6.401000e-03 -2.449060e-03 8.741400e-04 | ||
39 | -1.862800e-04 -4.596420e-03 -6.720800e-03 3.938620e-03 3.220744e-02 6.306262e-02 7.624674e-02 6.306262e-02 3.220744e-02 3.938620e-03 -6.720800e-03 -4.596420e-03 -1.862800e-04 | ||
40 | -1.031640e-03 -7.006740e-03 -5.236180e-03 1.722078e-02 6.306262e-02 1.116388e-01 1.348999e-01 1.116388e-01 6.306262e-02 1.722078e-02 -5.236180e-03 -7.006740e-03 -1.031640e-03 | ||
41 | -1.871920e-03 -6.948900e-03 -3.781600e-03 2.449600e-02 7.624674e-02 1.348999e-01 1.576508e-01 1.348999e-01 7.624674e-02 2.449600e-02 -3.781600e-03 -6.948900e-03 -1.871920e-03 | ||
42 | -1.031640e-03 -7.006740e-03 -5.236180e-03 1.722078e-02 6.306262e-02 1.116388e-01 1.348999e-01 1.116388e-01 6.306262e-02 1.722078e-02 -5.236180e-03 -7.006740e-03 -1.031640e-03 | ||
43 | -1.862800e-04 -4.596420e-03 -6.720800e-03 3.938620e-03 3.220744e-02 6.306262e-02 7.624674e-02 6.306262e-02 3.220744e-02 3.938620e-03 -6.720800e-03 -4.596420e-03 -1.862800e-04 | ||
44 | 8.741400e-04 -2.449060e-03 -6.401000e-03 -5.260020e-03 3.938620e-03 1.722078e-02 2.449600e-02 1.722078e-02 3.938620e-03 -5.260020e-03 -6.401000e-03 -2.449060e-03 8.741400e-04 | ||
45 | -5.686000e-05 -1.903800e-04 -3.059760e-03 -6.401000e-03 -6.720800e-03 -5.236180e-03 -3.781600e-03 -5.236180e-03 -6.720800e-03 -6.401000e-03 -3.059760e-03 -1.903800e-04 -5.686000e-05 | ||
46 | -8.064400e-04 1.417620e-03 -1.903800e-04 -2.449060e-03 -4.596420e-03 -7.006740e-03 -6.948900e-03 -7.006740e-03 -4.596420e-03 -2.449060e-03 -1.903800e-04 1.417620e-03 -8.064400e-04 | ||
47 | -2.257000e-04 -8.064400e-04 -5.686000e-05 8.741400e-04 -1.862800e-04 -1.031640e-03 -1.871920e-03 -1.031640e-03 -1.862800e-04 8.741400e-04 -5.686000e-05 -8.064400e-04 -2.257000e-04]; | ||
48 | |||
49 | mtx = [ 1.000000 ]; | ||
50 | |||
51 | hi0filt = [... | ||
52 | 5.997200e-04 -6.068000e-05 -3.324900e-04 -3.325600e-04 -2.406600e-04 -3.325600e-04 -3.324900e-04 -6.068000e-05 5.997200e-04 | ||
53 | -6.068000e-05 1.263100e-04 4.927100e-04 1.459700e-04 -3.732100e-04 1.459700e-04 4.927100e-04 1.263100e-04 -6.068000e-05 | ||
54 | -3.324900e-04 4.927100e-04 -1.616650e-03 -1.437358e-02 -2.420138e-02 -1.437358e-02 -1.616650e-03 4.927100e-04 -3.324900e-04 | ||
55 | -3.325600e-04 1.459700e-04 -1.437358e-02 -6.300923e-02 -9.623594e-02 -6.300923e-02 -1.437358e-02 1.459700e-04 -3.325600e-04 | ||
56 | -2.406600e-04 -3.732100e-04 -2.420138e-02 -9.623594e-02 8.554893e-01 -9.623594e-02 -2.420138e-02 -3.732100e-04 -2.406600e-04 | ||
57 | -3.325600e-04 1.459700e-04 -1.437358e-02 -6.300923e-02 -9.623594e-02 -6.300923e-02 -1.437358e-02 1.459700e-04 -3.325600e-04 | ||
58 | -3.324900e-04 4.927100e-04 -1.616650e-03 -1.437358e-02 -2.420138e-02 -1.437358e-02 -1.616650e-03 4.927100e-04 -3.324900e-04 | ||
59 | -6.068000e-05 1.263100e-04 4.927100e-04 1.459700e-04 -3.732100e-04 1.459700e-04 4.927100e-04 1.263100e-04 -6.068000e-05 | ||
60 | 5.997200e-04 -6.068000e-05 -3.324900e-04 -3.325600e-04 -2.406600e-04 -3.325600e-04 -3.324900e-04 -6.068000e-05 5.997200e-04 ]; | ||
61 | |||
62 | bfilts = [ ... | ||
63 | -9.066000e-05 -1.738640e-03 -4.942500e-03 -7.889390e-03 -1.009473e-02 -7.889390e-03 -4.942500e-03 -1.738640e-03 -9.066000e-05 ... | ||
64 | -1.738640e-03 -4.625150e-03 -7.272540e-03 -7.623410e-03 -9.091950e-03 -7.623410e-03 -7.272540e-03 -4.625150e-03 -1.738640e-03 ... | ||
65 | -4.942500e-03 -7.272540e-03 -2.129540e-02 -2.435662e-02 -3.487008e-02 -2.435662e-02 -2.129540e-02 -7.272540e-03 -4.942500e-03 ... | ||
66 | -7.889390e-03 -7.623410e-03 -2.435662e-02 -1.730466e-02 -3.158605e-02 -1.730466e-02 -2.435662e-02 -7.623410e-03 -7.889390e-03 ... | ||
67 | -1.009473e-02 -9.091950e-03 -3.487008e-02 -3.158605e-02 9.464195e-01 -3.158605e-02 -3.487008e-02 -9.091950e-03 -1.009473e-02 ... | ||
68 | -7.889390e-03 -7.623410e-03 -2.435662e-02 -1.730466e-02 -3.158605e-02 -1.730466e-02 -2.435662e-02 -7.623410e-03 -7.889390e-03 ... | ||
69 | -4.942500e-03 -7.272540e-03 -2.129540e-02 -2.435662e-02 -3.487008e-02 -2.435662e-02 -2.129540e-02 -7.272540e-03 -4.942500e-03 ... | ||
70 | -1.738640e-03 -4.625150e-03 -7.272540e-03 -7.623410e-03 -9.091950e-03 -7.623410e-03 -7.272540e-03 -4.625150e-03 -1.738640e-03 ... | ||
71 | -9.066000e-05 -1.738640e-03 -4.942500e-03 -7.889390e-03 -1.009473e-02 -7.889390e-03 -4.942500e-03 -1.738640e-03 -9.066000e-05 ]'; | ||
72 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/sp1Filters.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/sp1Filters.m deleted file mode 100755 index 215e651..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/sp1Filters.m +++ /dev/null | |||
@@ -1,91 +0,0 @@ | |||
1 | % Steerable pyramid filters. Transform described in: | ||
2 | % | ||
3 | % @INPROCEEDINGS{Simoncelli95b, | ||
4 | % TITLE = "The Steerable Pyramid: A Flexible Architecture for | ||
5 | % Multi-Scale Derivative Computation", | ||
6 | % AUTHOR = "E P Simoncelli and W T Freeman", | ||
7 | % BOOKTITLE = "Second Int'l Conf on Image Processing", | ||
8 | % ADDRESS = "Washington, DC", MONTH = "October", YEAR = 1995 } | ||
9 | % | ||
10 | % Filter kernel design described in: | ||
11 | % | ||
12 | %@INPROCEEDINGS{Karasaridis96, | ||
13 | % TITLE = "A Filter Design Technique for | ||
14 | % Steerable Pyramid Image Transforms", | ||
15 | % AUTHOR = "A Karasaridis and E P Simoncelli", | ||
16 | % BOOKTITLE = "ICASSP", ADDRESS = "Atlanta, GA", | ||
17 | % MONTH = "May", YEAR = 1996 } | ||
18 | |||
19 | % Eero Simoncelli, 6/96. | ||
20 | |||
21 | function [lo0filt,hi0filt,lofilt,bfilts,mtx,harmonics] = sp1Filters(); | ||
22 | |||
23 | harmonics = [ 1 ]; | ||
24 | |||
25 | %% filters only contain first harmonic. | ||
26 | mtx = eye(2); | ||
27 | |||
28 | lo0filt = [ ... | ||
29 | -8.701000e-05 -1.354280e-03 -1.601260e-03 -5.033700e-04 2.524010e-03 -5.033700e-04 -1.601260e-03 -1.354280e-03 -8.701000e-05 | ||
30 | -1.354280e-03 2.921580e-03 7.522720e-03 8.224420e-03 1.107620e-03 8.224420e-03 7.522720e-03 2.921580e-03 -1.354280e-03 | ||
31 | -1.601260e-03 7.522720e-03 -7.061290e-03 -3.769487e-02 -3.297137e-02 -3.769487e-02 -7.061290e-03 7.522720e-03 -1.601260e-03 | ||
32 | -5.033700e-04 8.224420e-03 -3.769487e-02 4.381320e-02 1.811603e-01 4.381320e-02 -3.769487e-02 8.224420e-03 -5.033700e-04 | ||
33 | 2.524010e-03 1.107620e-03 -3.297137e-02 1.811603e-01 4.376250e-01 1.811603e-01 -3.297137e-02 1.107620e-03 2.524010e-03 | ||
34 | -5.033700e-04 8.224420e-03 -3.769487e-02 4.381320e-02 1.811603e-01 4.381320e-02 -3.769487e-02 8.224420e-03 -5.033700e-04 | ||
35 | -1.601260e-03 7.522720e-03 -7.061290e-03 -3.769487e-02 -3.297137e-02 -3.769487e-02 -7.061290e-03 7.522720e-03 -1.601260e-03 | ||
36 | -1.354280e-03 2.921580e-03 7.522720e-03 8.224420e-03 1.107620e-03 8.224420e-03 7.522720e-03 2.921580e-03 -1.354280e-03 | ||
37 | -8.701000e-05 -1.354280e-03 -1.601260e-03 -5.033700e-04 2.524010e-03 -5.033700e-04 -1.601260e-03 -1.354280e-03 -8.701000e-05 | ||
38 | ]; | ||
39 | |||
40 | lofilt = [ ... | ||
41 | -4.350000e-05 1.207800e-04 -6.771400e-04 -1.243400e-04 -8.006400e-04 -1.597040e-03 -2.516800e-04 -4.202000e-04 1.262000e-03 -4.202000e-04 -2.516800e-04 -1.597040e-03 -8.006400e-04 -1.243400e-04 -6.771400e-04 1.207800e-04 -4.350000e-05 ; ... | ||
42 | 1.207800e-04 4.460600e-04 -5.814600e-04 5.621600e-04 -1.368800e-04 2.325540e-03 2.889860e-03 4.287280e-03 5.589400e-03 4.287280e-03 2.889860e-03 2.325540e-03 -1.368800e-04 5.621600e-04 -5.814600e-04 4.460600e-04 1.207800e-04 ; ... | ||
43 | -6.771400e-04 -5.814600e-04 1.460780e-03 2.160540e-03 3.761360e-03 3.080980e-03 4.112200e-03 2.221220e-03 5.538200e-04 2.221220e-03 4.112200e-03 3.080980e-03 3.761360e-03 2.160540e-03 1.460780e-03 -5.814600e-04 -6.771400e-04 ; ... | ||
44 | -1.243400e-04 5.621600e-04 2.160540e-03 3.175780e-03 3.184680e-03 -1.777480e-03 -7.431700e-03 -9.056920e-03 -9.637220e-03 -9.056920e-03 -7.431700e-03 -1.777480e-03 3.184680e-03 3.175780e-03 2.160540e-03 5.621600e-04 -1.243400e-04 ; ... | ||
45 | -8.006400e-04 -1.368800e-04 3.761360e-03 3.184680e-03 -3.530640e-03 -1.260420e-02 -1.884744e-02 -1.750818e-02 -1.648568e-02 -1.750818e-02 -1.884744e-02 -1.260420e-02 -3.530640e-03 3.184680e-03 3.761360e-03 -1.368800e-04 -8.006400e-04 ; ... | ||
46 | -1.597040e-03 2.325540e-03 3.080980e-03 -1.777480e-03 -1.260420e-02 -2.022938e-02 -1.109170e-02 3.955660e-03 1.438512e-02 3.955660e-03 -1.109170e-02 -2.022938e-02 -1.260420e-02 -1.777480e-03 3.080980e-03 2.325540e-03 -1.597040e-03 ; ... | ||
47 | -2.516800e-04 2.889860e-03 4.112200e-03 -7.431700e-03 -1.884744e-02 -1.109170e-02 2.190660e-02 6.806584e-02 9.058014e-02 6.806584e-02 2.190660e-02 -1.109170e-02 -1.884744e-02 -7.431700e-03 4.112200e-03 2.889860e-03 -2.516800e-04 ; ... | ||
48 | -4.202000e-04 4.287280e-03 2.221220e-03 -9.056920e-03 -1.750818e-02 3.955660e-03 6.806584e-02 1.445500e-01 1.773651e-01 1.445500e-01 6.806584e-02 3.955660e-03 -1.750818e-02 -9.056920e-03 2.221220e-03 4.287280e-03 -4.202000e-04 ; ... | ||
49 | 1.262000e-03 5.589400e-03 5.538200e-04 -9.637220e-03 -1.648568e-02 1.438512e-02 9.058014e-02 1.773651e-01 2.120374e-01 1.773651e-01 9.058014e-02 1.438512e-02 -1.648568e-02 -9.637220e-03 5.538200e-04 5.589400e-03 1.262000e-03 ; ... | ||
50 | -4.202000e-04 4.287280e-03 2.221220e-03 -9.056920e-03 -1.750818e-02 3.955660e-03 6.806584e-02 1.445500e-01 1.773651e-01 1.445500e-01 6.806584e-02 3.955660e-03 -1.750818e-02 -9.056920e-03 2.221220e-03 4.287280e-03 -4.202000e-04 ; ... | ||
51 | -2.516800e-04 2.889860e-03 4.112200e-03 -7.431700e-03 -1.884744e-02 -1.109170e-02 2.190660e-02 6.806584e-02 9.058014e-02 6.806584e-02 2.190660e-02 -1.109170e-02 -1.884744e-02 -7.431700e-03 4.112200e-03 2.889860e-03 -2.516800e-04 ; ... | ||
52 | -1.597040e-03 2.325540e-03 3.080980e-03 -1.777480e-03 -1.260420e-02 -2.022938e-02 -1.109170e-02 3.955660e-03 1.438512e-02 3.955660e-03 -1.109170e-02 -2.022938e-02 -1.260420e-02 -1.777480e-03 3.080980e-03 2.325540e-03 -1.597040e-03 ; ... | ||
53 | -8.006400e-04 -1.368800e-04 3.761360e-03 3.184680e-03 -3.530640e-03 -1.260420e-02 -1.884744e-02 -1.750818e-02 -1.648568e-02 -1.750818e-02 -1.884744e-02 -1.260420e-02 -3.530640e-03 3.184680e-03 3.761360e-03 -1.368800e-04 -8.006400e-04 ; ... | ||
54 | -1.243400e-04 5.621600e-04 2.160540e-03 3.175780e-03 3.184680e-03 -1.777480e-03 -7.431700e-03 -9.056920e-03 -9.637220e-03 -9.056920e-03 -7.431700e-03 -1.777480e-03 3.184680e-03 3.175780e-03 2.160540e-03 5.621600e-04 -1.243400e-04 ; ... | ||
55 | -6.771400e-04 -5.814600e-04 1.460780e-03 2.160540e-03 3.761360e-03 3.080980e-03 4.112200e-03 2.221220e-03 5.538200e-04 2.221220e-03 4.112200e-03 3.080980e-03 3.761360e-03 2.160540e-03 1.460780e-03 -5.814600e-04 -6.771400e-04 ; ... | ||
56 | 1.207800e-04 4.460600e-04 -5.814600e-04 5.621600e-04 -1.368800e-04 2.325540e-03 2.889860e-03 4.287280e-03 5.589400e-03 4.287280e-03 2.889860e-03 2.325540e-03 -1.368800e-04 5.621600e-04 -5.814600e-04 4.460600e-04 1.207800e-04 ; ... | ||
57 | -4.350000e-05 1.207800e-04 -6.771400e-04 -1.243400e-04 -8.006400e-04 -1.597040e-03 -2.516800e-04 -4.202000e-04 1.262000e-03 -4.202000e-04 -2.516800e-04 -1.597040e-03 -8.006400e-04 -1.243400e-04 -6.771400e-04 1.207800e-04 -4.350000e-05 ]; | ||
58 | |||
59 | hi0filt = [... | ||
60 | -9.570000e-04 -2.424100e-04 -1.424720e-03 -8.742600e-04 -1.166810e-03 -8.742600e-04 -1.424720e-03 -2.424100e-04 -9.570000e-04 ; ... | ||
61 | -2.424100e-04 -4.317530e-03 8.998600e-04 9.156420e-03 1.098012e-02 9.156420e-03 8.998600e-04 -4.317530e-03 -2.424100e-04 ; ... | ||
62 | -1.424720e-03 8.998600e-04 1.706347e-02 1.094866e-02 -5.897780e-03 1.094866e-02 1.706347e-02 8.998600e-04 -1.424720e-03 ; ... | ||
63 | -8.742600e-04 9.156420e-03 1.094866e-02 -7.841370e-02 -1.562827e-01 -7.841370e-02 1.094866e-02 9.156420e-03 -8.742600e-04 ; ... | ||
64 | -1.166810e-03 1.098012e-02 -5.897780e-03 -1.562827e-01 7.282593e-01 -1.562827e-01 -5.897780e-03 1.098012e-02 -1.166810e-03 ; ... | ||
65 | -8.742600e-04 9.156420e-03 1.094866e-02 -7.841370e-02 -1.562827e-01 -7.841370e-02 1.094866e-02 9.156420e-03 -8.742600e-04 ; ... | ||
66 | -1.424720e-03 8.998600e-04 1.706347e-02 1.094866e-02 -5.897780e-03 1.094866e-02 1.706347e-02 8.998600e-04 -1.424720e-03 ; ... | ||
67 | -2.424100e-04 -4.317530e-03 8.998600e-04 9.156420e-03 1.098012e-02 9.156420e-03 8.998600e-04 -4.317530e-03 -2.424100e-04 ; ... | ||
68 | -9.570000e-04 -2.424100e-04 -1.424720e-03 -8.742600e-04 -1.166810e-03 -8.742600e-04 -1.424720e-03 -2.424100e-04 -9.570000e-04 ]; | ||
69 | |||
70 | bfilts = -[ ... | ||
71 | 6.125880e-03 -8.052600e-03 -2.103714e-02 -1.536890e-02 -1.851466e-02 -1.536890e-02 -2.103714e-02 -8.052600e-03 6.125880e-03 ... | ||
72 | -1.287416e-02 -9.611520e-03 1.023569e-02 6.009450e-03 1.872620e-03 6.009450e-03 1.023569e-02 -9.611520e-03 -1.287416e-02 ... | ||
73 | -5.641530e-03 4.168400e-03 -2.382180e-02 -5.375324e-02 -2.076086e-02 -5.375324e-02 -2.382180e-02 4.168400e-03 -5.641530e-03 ... | ||
74 | -8.957260e-03 -1.751170e-03 -1.836909e-02 1.265655e-01 2.996168e-01 1.265655e-01 -1.836909e-02 -1.751170e-03 -8.957260e-03 ... | ||
75 | 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 ... | ||
76 | 8.957260e-03 1.751170e-03 1.836909e-02 -1.265655e-01 -2.996168e-01 -1.265655e-01 1.836909e-02 1.751170e-03 8.957260e-03 ... | ||
77 | 5.641530e-03 -4.168400e-03 2.382180e-02 5.375324e-02 2.076086e-02 5.375324e-02 2.382180e-02 -4.168400e-03 5.641530e-03 ... | ||
78 | 1.287416e-02 9.611520e-03 -1.023569e-02 -6.009450e-03 -1.872620e-03 -6.009450e-03 -1.023569e-02 9.611520e-03 1.287416e-02 ... | ||
79 | -6.125880e-03 8.052600e-03 2.103714e-02 1.536890e-02 1.851466e-02 1.536890e-02 2.103714e-02 8.052600e-03 -6.125880e-03; ... | ||
80 | ... | ||
81 | -6.125880e-03 1.287416e-02 5.641530e-03 8.957260e-03 0.000000e+00 -8.957260e-03 -5.641530e-03 -1.287416e-02 6.125880e-03 ... | ||
82 | 8.052600e-03 9.611520e-03 -4.168400e-03 1.751170e-03 0.000000e+00 -1.751170e-03 4.168400e-03 -9.611520e-03 -8.052600e-03 ... | ||
83 | 2.103714e-02 -1.023569e-02 2.382180e-02 1.836909e-02 0.000000e+00 -1.836909e-02 -2.382180e-02 1.023569e-02 -2.103714e-02 ... | ||
84 | 1.536890e-02 -6.009450e-03 5.375324e-02 -1.265655e-01 0.000000e+00 1.265655e-01 -5.375324e-02 6.009450e-03 -1.536890e-02 ... | ||
85 | 1.851466e-02 -1.872620e-03 2.076086e-02 -2.996168e-01 0.000000e+00 2.996168e-01 -2.076086e-02 1.872620e-03 -1.851466e-02 ... | ||
86 | 1.536890e-02 -6.009450e-03 5.375324e-02 -1.265655e-01 0.000000e+00 1.265655e-01 -5.375324e-02 6.009450e-03 -1.536890e-02 ... | ||
87 | 2.103714e-02 -1.023569e-02 2.382180e-02 1.836909e-02 0.000000e+00 -1.836909e-02 -2.382180e-02 1.023569e-02 -2.103714e-02 ... | ||
88 | 8.052600e-03 9.611520e-03 -4.168400e-03 1.751170e-03 0.000000e+00 -1.751170e-03 4.168400e-03 -9.611520e-03 -8.052600e-03 ... | ||
89 | -6.125880e-03 1.287416e-02 5.641530e-03 8.957260e-03 0.000000e+00 -8.957260e-03 -5.641530e-03 -1.287416e-02 6.125880e-03 ... | ||
90 | ]'; | ||
91 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/sp3Filters.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/sp3Filters.m deleted file mode 100755 index c9cfaaf..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/sp3Filters.m +++ /dev/null | |||
@@ -1,121 +0,0 @@ | |||
1 | % Steerable pyramid filters. Transform described in: | ||
2 | % | ||
3 | % @INPROCEEDINGS{Simoncelli95b, | ||
4 | % TITLE = "The Steerable Pyramid: A Flexible Architecture for | ||
5 | % Multi-Scale Derivative Computation", | ||
6 | % AUTHOR = "E P Simoncelli and W T Freeman", | ||
7 | % BOOKTITLE = "Second Int'l Conf on Image Processing", | ||
8 | % ADDRESS = "Washington, DC", MONTH = "October", YEAR = 1995 } | ||
9 | % | ||
10 | % Filter kernel design described in: | ||
11 | % | ||
12 | %@INPROCEEDINGS{Karasaridis96, | ||
13 | % TITLE = "A Filter Design Technique for | ||
14 | % Steerable Pyramid Image Transforms", | ||
15 | % AUTHOR = "A Karasaridis and E P Simoncelli", | ||
16 | % BOOKTITLE = "ICASSP", ADDRESS = "Atlanta, GA", | ||
17 | % MONTH = "May", YEAR = 1996 } | ||
18 | |||
19 | % Eero Simoncelli, 6/96. | ||
20 | |||
21 | function [lo0filt,hi0filt,lofilt,bfilts,mtx,harmonics] = sp3Filters(); | ||
22 | |||
23 | harmonics = [1 3]; | ||
24 | |||
25 | mtx = [ ... | ||
26 | 0.5000 0.3536 0 -0.3536 | ||
27 | -0.0000 0.3536 0.5000 0.3536 | ||
28 | 0.5000 -0.3536 0 0.3536 | ||
29 | -0.0000 0.3536 -0.5000 0.3536]; | ||
30 | |||
31 | hi0filt = [ | ||
32 | -4.0483998600E-4 -6.2596000498E-4 -3.7829999201E-5 8.8387000142E-4 1.5450799838E-3 1.9235999789E-3 2.0687500946E-3 2.0898699295E-3 2.0687500946E-3 1.9235999789E-3 1.5450799838E-3 8.8387000142E-4 -3.7829999201E-5 -6.2596000498E-4 -4.0483998600E-4 | ||
33 | -6.2596000498E-4 -3.2734998967E-4 7.7435001731E-4 1.5874400269E-3 2.1750701126E-3 2.5626500137E-3 2.2892199922E-3 1.9755100366E-3 2.2892199922E-3 2.5626500137E-3 2.1750701126E-3 1.5874400269E-3 7.7435001731E-4 -3.2734998967E-4 -6.2596000498E-4 | ||
34 | -3.7829999201E-5 7.7435001731E-4 1.1793200392E-3 1.4050999889E-3 2.2253401112E-3 2.1145299543E-3 3.3578000148E-4 -8.3368999185E-4 3.3578000148E-4 2.1145299543E-3 2.2253401112E-3 1.4050999889E-3 1.1793200392E-3 7.7435001731E-4 -3.7829999201E-5 | ||
35 | 8.8387000142E-4 1.5874400269E-3 1.4050999889E-3 1.2960999738E-3 -4.9274001503E-4 -3.1295299996E-3 -4.5751798898E-3 -5.1014497876E-3 -4.5751798898E-3 -3.1295299996E-3 -4.9274001503E-4 1.2960999738E-3 1.4050999889E-3 1.5874400269E-3 8.8387000142E-4 | ||
36 | 1.5450799838E-3 2.1750701126E-3 2.2253401112E-3 -4.9274001503E-4 -6.3222697936E-3 -2.7556000277E-3 5.3632198833E-3 7.3032598011E-3 5.3632198833E-3 -2.7556000277E-3 -6.3222697936E-3 -4.9274001503E-4 2.2253401112E-3 2.1750701126E-3 1.5450799838E-3 | ||
37 | 1.9235999789E-3 2.5626500137E-3 2.1145299543E-3 -3.1295299996E-3 -2.7556000277E-3 1.3962360099E-2 7.8046298586E-3 -9.3812197447E-3 7.8046298586E-3 1.3962360099E-2 -2.7556000277E-3 -3.1295299996E-3 2.1145299543E-3 2.5626500137E-3 1.9235999789E-3 | ||
38 | 2.0687500946E-3 2.2892199922E-3 3.3578000148E-4 -4.5751798898E-3 5.3632198833E-3 7.8046298586E-3 -7.9501636326E-2 -0.1554141641 -7.9501636326E-2 7.8046298586E-3 5.3632198833E-3 -4.5751798898E-3 3.3578000148E-4 2.2892199922E-3 2.0687500946E-3 | ||
39 | 2.0898699295E-3 1.9755100366E-3 -8.3368999185E-4 -5.1014497876E-3 7.3032598011E-3 -9.3812197447E-3 -0.1554141641 0.7303866148 -0.1554141641 -9.3812197447E-3 7.3032598011E-3 -5.1014497876E-3 -8.3368999185E-4 1.9755100366E-3 2.0898699295E-3 | ||
40 | 2.0687500946E-3 2.2892199922E-3 3.3578000148E-4 -4.5751798898E-3 5.3632198833E-3 7.8046298586E-3 -7.9501636326E-2 -0.1554141641 -7.9501636326E-2 7.8046298586E-3 5.3632198833E-3 -4.5751798898E-3 3.3578000148E-4 2.2892199922E-3 2.0687500946E-3 | ||
41 | 1.9235999789E-3 2.5626500137E-3 2.1145299543E-3 -3.1295299996E-3 -2.7556000277E-3 1.3962360099E-2 7.8046298586E-3 -9.3812197447E-3 7.8046298586E-3 1.3962360099E-2 -2.7556000277E-3 -3.1295299996E-3 2.1145299543E-3 2.5626500137E-3 1.9235999789E-3 | ||
42 | 1.5450799838E-3 2.1750701126E-3 2.2253401112E-3 -4.9274001503E-4 -6.3222697936E-3 -2.7556000277E-3 5.3632198833E-3 7.3032598011E-3 5.3632198833E-3 -2.7556000277E-3 -6.3222697936E-3 -4.9274001503E-4 2.2253401112E-3 2.1750701126E-3 1.5450799838E-3 | ||
43 | 8.8387000142E-4 1.5874400269E-3 1.4050999889E-3 1.2960999738E-3 -4.9274001503E-4 -3.1295299996E-3 -4.5751798898E-3 -5.1014497876E-3 -4.5751798898E-3 -3.1295299996E-3 -4.9274001503E-4 1.2960999738E-3 1.4050999889E-3 1.5874400269E-3 8.8387000142E-4 | ||
44 | -3.7829999201E-5 7.7435001731E-4 1.1793200392E-3 1.4050999889E-3 2.2253401112E-3 2.1145299543E-3 3.3578000148E-4 -8.3368999185E-4 3.3578000148E-4 2.1145299543E-3 2.2253401112E-3 1.4050999889E-3 1.1793200392E-3 7.7435001731E-4 -3.7829999201E-5 | ||
45 | -6.2596000498E-4 -3.2734998967E-4 7.7435001731E-4 1.5874400269E-3 2.1750701126E-3 2.5626500137E-3 2.2892199922E-3 1.9755100366E-3 2.2892199922E-3 2.5626500137E-3 2.1750701126E-3 1.5874400269E-3 7.7435001731E-4 -3.2734998967E-4 -6.2596000498E-4 | ||
46 | -4.0483998600E-4 -6.2596000498E-4 -3.7829999201E-5 8.8387000142E-4 1.5450799838E-3 1.9235999789E-3 2.0687500946E-3 2.0898699295E-3 2.0687500946E-3 1.9235999789E-3 1.5450799838E-3 8.8387000142E-4 -3.7829999201E-5 -6.2596000498E-4 -4.0483998600E-4 | ||
47 | ]; | ||
48 | |||
49 | lo0filt = [ | ||
50 | -8.7009997515E-5 -1.3542800443E-3 -1.6012600390E-3 -5.0337001448E-4 2.5240099058E-3 -5.0337001448E-4 -1.6012600390E-3 -1.3542800443E-3 -8.7009997515E-5 | ||
51 | -1.3542800443E-3 2.9215801042E-3 7.5227199122E-3 8.2244202495E-3 1.1076199589E-3 8.2244202495E-3 7.5227199122E-3 2.9215801042E-3 -1.3542800443E-3 | ||
52 | -1.6012600390E-3 7.5227199122E-3 -7.0612900890E-3 -3.7694871426E-2 -3.2971370965E-2 -3.7694871426E-2 -7.0612900890E-3 7.5227199122E-3 -1.6012600390E-3 | ||
53 | -5.0337001448E-4 8.2244202495E-3 -3.7694871426E-2 4.3813198805E-2 0.1811603010 4.3813198805E-2 -3.7694871426E-2 8.2244202495E-3 -5.0337001448E-4 | ||
54 | 2.5240099058E-3 1.1076199589E-3 -3.2971370965E-2 0.1811603010 0.4376249909 0.1811603010 -3.2971370965E-2 1.1076199589E-3 2.5240099058E-3 | ||
55 | -5.0337001448E-4 8.2244202495E-3 -3.7694871426E-2 4.3813198805E-2 0.1811603010 4.3813198805E-2 -3.7694871426E-2 8.2244202495E-3 -5.0337001448E-4 | ||
56 | -1.6012600390E-3 7.5227199122E-3 -7.0612900890E-3 -3.7694871426E-2 -3.2971370965E-2 -3.7694871426E-2 -7.0612900890E-3 7.5227199122E-3 -1.6012600390E-3 | ||
57 | -1.3542800443E-3 2.9215801042E-3 7.5227199122E-3 8.2244202495E-3 1.1076199589E-3 8.2244202495E-3 7.5227199122E-3 2.9215801042E-3 -1.3542800443E-3 | ||
58 | -8.7009997515E-5 -1.3542800443E-3 -1.6012600390E-3 -5.0337001448E-4 2.5240099058E-3 -5.0337001448E-4 -1.6012600390E-3 -1.3542800443E-3 -8.7009997515E-5 | ||
59 | ]; | ||
60 | |||
61 | lofilt = [ | ||
62 | -4.3500000174E-5 1.2078000145E-4 -6.7714002216E-4 -1.2434000382E-4 -8.0063997302E-4 -1.5970399836E-3 -2.5168000138E-4 -4.2019999819E-4 1.2619999470E-3 -4.2019999819E-4 -2.5168000138E-4 -1.5970399836E-3 -8.0063997302E-4 -1.2434000382E-4 -6.7714002216E-4 1.2078000145E-4 -4.3500000174E-5 | ||
63 | 1.2078000145E-4 4.4606000301E-4 -5.8146001538E-4 5.6215998484E-4 -1.3688000035E-4 2.3255399428E-3 2.8898599558E-3 4.2872801423E-3 5.5893999524E-3 4.2872801423E-3 2.8898599558E-3 2.3255399428E-3 -1.3688000035E-4 5.6215998484E-4 -5.8146001538E-4 4.4606000301E-4 1.2078000145E-4 | ||
64 | -6.7714002216E-4 -5.8146001538E-4 1.4607800404E-3 2.1605400834E-3 3.7613599561E-3 3.0809799209E-3 4.1121998802E-3 2.2212199401E-3 5.5381999118E-4 2.2212199401E-3 4.1121998802E-3 3.0809799209E-3 3.7613599561E-3 2.1605400834E-3 1.4607800404E-3 -5.8146001538E-4 -6.7714002216E-4 | ||
65 | -1.2434000382E-4 5.6215998484E-4 2.1605400834E-3 3.1757799443E-3 3.1846798956E-3 -1.7774800071E-3 -7.4316998944E-3 -9.0569201857E-3 -9.6372198313E-3 -9.0569201857E-3 -7.4316998944E-3 -1.7774800071E-3 3.1846798956E-3 3.1757799443E-3 2.1605400834E-3 5.6215998484E-4 -1.2434000382E-4 | ||
66 | -8.0063997302E-4 -1.3688000035E-4 3.7613599561E-3 3.1846798956E-3 -3.5306399222E-3 -1.2604200281E-2 -1.8847439438E-2 -1.7508180812E-2 -1.6485679895E-2 -1.7508180812E-2 -1.8847439438E-2 -1.2604200281E-2 -3.5306399222E-3 3.1846798956E-3 3.7613599561E-3 -1.3688000035E-4 -8.0063997302E-4 | ||
67 | -1.5970399836E-3 2.3255399428E-3 3.0809799209E-3 -1.7774800071E-3 -1.2604200281E-2 -2.0229380578E-2 -1.1091699824E-2 3.9556599222E-3 1.4385120012E-2 3.9556599222E-3 -1.1091699824E-2 -2.0229380578E-2 -1.2604200281E-2 -1.7774800071E-3 3.0809799209E-3 2.3255399428E-3 -1.5970399836E-3 | ||
68 | -2.5168000138E-4 2.8898599558E-3 4.1121998802E-3 -7.4316998944E-3 -1.8847439438E-2 -1.1091699824E-2 2.1906599402E-2 6.8065837026E-2 9.0580143034E-2 6.8065837026E-2 2.1906599402E-2 -1.1091699824E-2 -1.8847439438E-2 -7.4316998944E-3 4.1121998802E-3 2.8898599558E-3 -2.5168000138E-4 | ||
69 | -4.2019999819E-4 4.2872801423E-3 2.2212199401E-3 -9.0569201857E-3 -1.7508180812E-2 3.9556599222E-3 6.8065837026E-2 0.1445499808 0.1773651242 0.1445499808 6.8065837026E-2 3.9556599222E-3 -1.7508180812E-2 -9.0569201857E-3 2.2212199401E-3 4.2872801423E-3 -4.2019999819E-4 | ||
70 | 1.2619999470E-3 5.5893999524E-3 5.5381999118E-4 -9.6372198313E-3 -1.6485679895E-2 1.4385120012E-2 9.0580143034E-2 0.1773651242 0.2120374441 0.1773651242 9.0580143034E-2 1.4385120012E-2 -1.6485679895E-2 -9.6372198313E-3 5.5381999118E-4 5.5893999524E-3 1.2619999470E-3 | ||
71 | -4.2019999819E-4 4.2872801423E-3 2.2212199401E-3 -9.0569201857E-3 -1.7508180812E-2 3.9556599222E-3 6.8065837026E-2 0.1445499808 0.1773651242 0.1445499808 6.8065837026E-2 3.9556599222E-3 -1.7508180812E-2 -9.0569201857E-3 2.2212199401E-3 4.2872801423E-3 -4.2019999819E-4 | ||
72 | -2.5168000138E-4 2.8898599558E-3 4.1121998802E-3 -7.4316998944E-3 -1.8847439438E-2 -1.1091699824E-2 2.1906599402E-2 6.8065837026E-2 9.0580143034E-2 6.8065837026E-2 2.1906599402E-2 -1.1091699824E-2 -1.8847439438E-2 -7.4316998944E-3 4.1121998802E-3 2.8898599558E-3 -2.5168000138E-4 | ||
73 | -1.5970399836E-3 2.3255399428E-3 3.0809799209E-3 -1.7774800071E-3 -1.2604200281E-2 -2.0229380578E-2 -1.1091699824E-2 3.9556599222E-3 1.4385120012E-2 3.9556599222E-3 -1.1091699824E-2 -2.0229380578E-2 -1.2604200281E-2 -1.7774800071E-3 3.0809799209E-3 2.3255399428E-3 -1.5970399836E-3 | ||
74 | -8.0063997302E-4 -1.3688000035E-4 3.7613599561E-3 3.1846798956E-3 -3.5306399222E-3 -1.2604200281E-2 -1.8847439438E-2 -1.7508180812E-2 -1.6485679895E-2 -1.7508180812E-2 -1.8847439438E-2 -1.2604200281E-2 -3.5306399222E-3 3.1846798956E-3 3.7613599561E-3 -1.3688000035E-4 -8.0063997302E-4 | ||
75 | -1.2434000382E-4 5.6215998484E-4 2.1605400834E-3 3.1757799443E-3 3.1846798956E-3 -1.7774800071E-3 -7.4316998944E-3 -9.0569201857E-3 -9.6372198313E-3 -9.0569201857E-3 -7.4316998944E-3 -1.7774800071E-3 3.1846798956E-3 3.1757799443E-3 2.1605400834E-3 5.6215998484E-4 -1.2434000382E-4 | ||
76 | -6.7714002216E-4 -5.8146001538E-4 1.4607800404E-3 2.1605400834E-3 3.7613599561E-3 3.0809799209E-3 4.1121998802E-3 2.2212199401E-3 5.5381999118E-4 2.2212199401E-3 4.1121998802E-3 3.0809799209E-3 3.7613599561E-3 2.1605400834E-3 1.4607800404E-3 -5.8146001538E-4 -6.7714002216E-4 | ||
77 | 1.2078000145E-4 4.4606000301E-4 -5.8146001538E-4 5.6215998484E-4 -1.3688000035E-4 2.3255399428E-3 2.8898599558E-3 4.2872801423E-3 5.5893999524E-3 4.2872801423E-3 2.8898599558E-3 2.3255399428E-3 -1.3688000035E-4 5.6215998484E-4 -5.8146001538E-4 4.4606000301E-4 1.2078000145E-4 | ||
78 | -4.3500000174E-5 1.2078000145E-4 -6.7714002216E-4 -1.2434000382E-4 -8.0063997302E-4 -1.5970399836E-3 -2.5168000138E-4 -4.2019999819E-4 1.2619999470E-3 -4.2019999819E-4 -2.5168000138E-4 -1.5970399836E-3 -8.0063997302E-4 -1.2434000382E-4 -6.7714002216E-4 1.2078000145E-4 -4.3500000174E-5 | ||
79 | ]; | ||
80 | |||
81 | bfilts = [... | ||
82 | -8.1125000725E-4 4.4451598078E-3 1.2316980399E-2 1.3955879956E-2 1.4179450460E-2 1.3955879956E-2 1.2316980399E-2 4.4451598078E-3 -8.1125000725E-4 ... | ||
83 | 3.9103501476E-3 4.4565401040E-3 -5.8724298142E-3 -2.8760801069E-3 8.5267601535E-3 -2.8760801069E-3 -5.8724298142E-3 4.4565401040E-3 3.9103501476E-3 ... | ||
84 | 1.3462699717E-3 -3.7740699481E-3 8.2581602037E-3 3.9442278445E-2 5.3605638444E-2 3.9442278445E-2 8.2581602037E-3 -3.7740699481E-3 1.3462699717E-3 ... | ||
85 | 7.4700999539E-4 -3.6522001028E-4 -2.2522680461E-2 -0.1105690673 -0.1768419296 -0.1105690673 -2.2522680461E-2 -3.6522001028E-4 7.4700999539E-4 ... | ||
86 | 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 ... | ||
87 | -7.4700999539E-4 3.6522001028E-4 2.2522680461E-2 0.1105690673 0.1768419296 0.1105690673 2.2522680461E-2 3.6522001028E-4 -7.4700999539E-4 ... | ||
88 | -1.3462699717E-3 3.7740699481E-3 -8.2581602037E-3 -3.9442278445E-2 -5.3605638444E-2 -3.9442278445E-2 -8.2581602037E-3 3.7740699481E-3 -1.3462699717E-3 ... | ||
89 | -3.9103501476E-3 -4.4565401040E-3 5.8724298142E-3 2.8760801069E-3 -8.5267601535E-3 2.8760801069E-3 5.8724298142E-3 -4.4565401040E-3 -3.9103501476E-3 ... | ||
90 | 8.1125000725E-4 -4.4451598078E-3 -1.2316980399E-2 -1.3955879956E-2 -1.4179450460E-2 -1.3955879956E-2 -1.2316980399E-2 -4.4451598078E-3 8.1125000725E-4; ... | ||
91 | ... | ||
92 | 0.0000000000 -8.2846998703E-4 -5.7109999034E-5 4.0110000555E-5 4.6670897864E-3 8.0871898681E-3 1.4807609841E-2 8.6204400286E-3 -3.1221499667E-3 ... | ||
93 | 8.2846998703E-4 0.0000000000 -9.7479997203E-4 -6.9718998857E-3 -2.0865600090E-3 2.3298799060E-3 -4.4814897701E-3 1.4917500317E-2 8.6204400286E-3 ... | ||
94 | 5.7109999034E-5 9.7479997203E-4 0.0000000000 -1.2145539746E-2 -2.4427289143E-2 5.0797060132E-2 3.2785870135E-2 -4.4814897701E-3 1.4807609841E-2 ... | ||
95 | -4.0110000555E-5 6.9718998857E-3 1.2145539746E-2 0.0000000000 -0.1510555595 -8.2495503128E-2 5.0797060132E-2 2.3298799060E-3 8.0871898681E-3 ... | ||
96 | -4.6670897864E-3 2.0865600090E-3 2.4427289143E-2 0.1510555595 0.0000000000 -0.1510555595 -2.4427289143E-2 -2.0865600090E-3 4.6670897864E-3 ... | ||
97 | -8.0871898681E-3 -2.3298799060E-3 -5.0797060132E-2 8.2495503128E-2 0.1510555595 0.0000000000 -1.2145539746E-2 -6.9718998857E-3 4.0110000555E-5 ... | ||
98 | -1.4807609841E-2 4.4814897701E-3 -3.2785870135E-2 -5.0797060132E-2 2.4427289143E-2 1.2145539746E-2 0.0000000000 -9.7479997203E-4 -5.7109999034E-5 ... | ||
99 | -8.6204400286E-3 -1.4917500317E-2 4.4814897701E-3 -2.3298799060E-3 2.0865600090E-3 6.9718998857E-3 9.7479997203E-4 0.0000000000 -8.2846998703E-4 ... | ||
100 | 3.1221499667E-3 -8.6204400286E-3 -1.4807609841E-2 -8.0871898681E-3 -4.6670897864E-3 -4.0110000555E-5 5.7109999034E-5 8.2846998703E-4 0.0000000000; ... | ||
101 | ... | ||
102 | 8.1125000725E-4 -3.9103501476E-3 -1.3462699717E-3 -7.4700999539E-4 0.0000000000 7.4700999539E-4 1.3462699717E-3 3.9103501476E-3 -8.1125000725E-4 ... | ||
103 | -4.4451598078E-3 -4.4565401040E-3 3.7740699481E-3 3.6522001028E-4 0.0000000000 -3.6522001028E-4 -3.7740699481E-3 4.4565401040E-3 4.4451598078E-3 ... | ||
104 | -1.2316980399E-2 5.8724298142E-3 -8.2581602037E-3 2.2522680461E-2 0.0000000000 -2.2522680461E-2 8.2581602037E-3 -5.8724298142E-3 1.2316980399E-2 ... | ||
105 | -1.3955879956E-2 2.8760801069E-3 -3.9442278445E-2 0.1105690673 0.0000000000 -0.1105690673 3.9442278445E-2 -2.8760801069E-3 1.3955879956E-2 ... | ||
106 | -1.4179450460E-2 -8.5267601535E-3 -5.3605638444E-2 0.1768419296 0.0000000000 -0.1768419296 5.3605638444E-2 8.5267601535E-3 1.4179450460E-2 ... | ||
107 | -1.3955879956E-2 2.8760801069E-3 -3.9442278445E-2 0.1105690673 0.0000000000 -0.1105690673 3.9442278445E-2 -2.8760801069E-3 1.3955879956E-2 ... | ||
108 | -1.2316980399E-2 5.8724298142E-3 -8.2581602037E-3 2.2522680461E-2 0.0000000000 -2.2522680461E-2 8.2581602037E-3 -5.8724298142E-3 1.2316980399E-2 ... | ||
109 | -4.4451598078E-3 -4.4565401040E-3 3.7740699481E-3 3.6522001028E-4 0.0000000000 -3.6522001028E-4 -3.7740699481E-3 4.4565401040E-3 4.4451598078E-3 ... | ||
110 | 8.1125000725E-4 -3.9103501476E-3 -1.3462699717E-3 -7.4700999539E-4 0.0000000000 7.4700999539E-4 1.3462699717E-3 3.9103501476E-3 -8.1125000725E-4; ... | ||
111 | ... | ||
112 | 3.1221499667E-3 -8.6204400286E-3 -1.4807609841E-2 -8.0871898681E-3 -4.6670897864E-3 -4.0110000555E-5 5.7109999034E-5 8.2846998703E-4 0.0000000000 ... | ||
113 | -8.6204400286E-3 -1.4917500317E-2 4.4814897701E-3 -2.3298799060E-3 2.0865600090E-3 6.9718998857E-3 9.7479997203E-4 -0.0000000000 -8.2846998703E-4 ... | ||
114 | -1.4807609841E-2 4.4814897701E-3 -3.2785870135E-2 -5.0797060132E-2 2.4427289143E-2 1.2145539746E-2 0.0000000000 -9.7479997203E-4 -5.7109999034E-5 ... | ||
115 | -8.0871898681E-3 -2.3298799060E-3 -5.0797060132E-2 8.2495503128E-2 0.1510555595 -0.0000000000 -1.2145539746E-2 -6.9718998857E-3 4.0110000555E-5 ... | ||
116 | -4.6670897864E-3 2.0865600090E-3 2.4427289143E-2 0.1510555595 0.0000000000 -0.1510555595 -2.4427289143E-2 -2.0865600090E-3 4.6670897864E-3 ... | ||
117 | -4.0110000555E-5 6.9718998857E-3 1.2145539746E-2 0.0000000000 -0.1510555595 -8.2495503128E-2 5.0797060132E-2 2.3298799060E-3 8.0871898681E-3 ... | ||
118 | 5.7109999034E-5 9.7479997203E-4 -0.0000000000 -1.2145539746E-2 -2.4427289143E-2 5.0797060132E-2 3.2785870135E-2 -4.4814897701E-3 1.4807609841E-2 ... | ||
119 | 8.2846998703E-4 -0.0000000000 -9.7479997203E-4 -6.9718998857E-3 -2.0865600090E-3 2.3298799060E-3 -4.4814897701E-3 1.4917500317E-2 8.6204400286E-3 ... | ||
120 | 0.0000000000 -8.2846998703E-4 -5.7109999034E-5 4.0110000555E-5 4.6670897864E-3 8.0871898681E-3 1.4807609841E-2 8.6204400286E-3 -3.1221499667E-3 ... | ||
121 | ]'; | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/sp5Filters.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/sp5Filters.m deleted file mode 100755 index 4cddcfd..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/sp5Filters.m +++ /dev/null | |||
@@ -1,110 +0,0 @@ | |||
1 | % Steerable pyramid filters. Transform described in: | ||
2 | % | ||
3 | % @INPROCEEDINGS{Simoncelli95b, | ||
4 | % TITLE = "The Steerable Pyramid: A Flexible Architecture for | ||
5 | % Multi-Scale Derivative Computation", | ||
6 | % AUTHOR = "E P Simoncelli and W T Freeman", | ||
7 | % BOOKTITLE = "Second Int'l Conf on Image Processing", | ||
8 | % ADDRESS = "Washington, DC", MONTH = "October", YEAR = 1995 } | ||
9 | % | ||
10 | % Filter kernel design described in: | ||
11 | % | ||
12 | %@INPROCEEDINGS{Karasaridis96, | ||
13 | % TITLE = "A Filter Design Technique for | ||
14 | % Steerable Pyramid Image Transforms", | ||
15 | % AUTHOR = "A Karasaridis and E P Simoncelli", | ||
16 | % BOOKTITLE = "ICASSP", ADDRESS = "Atlanta, GA", | ||
17 | % MONTH = "May", YEAR = 1996 } | ||
18 | |||
19 | % Eero Simoncelli, 6/96. | ||
20 | |||
21 | function [lo0filt,hi0filt,lofilt,bfilts,mtx,harmonics] = sp5Filters(); | ||
22 | |||
23 | harmonics = [1 3 5]; | ||
24 | |||
25 | mtx = [ ... | ||
26 | 0.3333 0.2887 0.1667 0.0000 -0.1667 -0.2887 | ||
27 | 0.0000 0.1667 0.2887 0.3333 0.2887 0.1667 | ||
28 | 0.3333 -0.0000 -0.3333 -0.0000 0.3333 -0.0000 | ||
29 | 0.0000 0.3333 0.0000 -0.3333 0.0000 0.3333 | ||
30 | 0.3333 -0.2887 0.1667 -0.0000 -0.1667 0.2887 | ||
31 | -0.0000 0.1667 -0.2887 0.3333 -0.2887 0.1667]; | ||
32 | |||
33 | hi0filt = [ | ||
34 | -0.00033429 -0.00113093 -0.00171484 -0.00133542 -0.00080639 -0.00133542 -0.00171484 -0.00113093 -0.00033429 | ||
35 | -0.00113093 -0.00350017 -0.00243812 0.00631653 0.01261227 0.00631653 -0.00243812 -0.00350017 -0.00113093 | ||
36 | -0.00171484 -0.00243812 -0.00290081 -0.00673482 -0.00981051 -0.00673482 -0.00290081 -0.00243812 -0.00171484 | ||
37 | -0.00133542 0.00631653 -0.00673482 -0.07027679 -0.11435863 -0.07027679 -0.00673482 0.00631653 -0.00133542 | ||
38 | -0.00080639 0.01261227 -0.00981051 -0.11435863 0.81380200 -0.11435863 -0.00981051 0.01261227 -0.00080639 | ||
39 | -0.00133542 0.00631653 -0.00673482 -0.07027679 -0.11435863 -0.07027679 -0.00673482 0.00631653 -0.00133542 | ||
40 | -0.00171484 -0.00243812 -0.00290081 -0.00673482 -0.00981051 -0.00673482 -0.00290081 -0.00243812 -0.00171484 | ||
41 | -0.00113093 -0.00350017 -0.00243812 0.00631653 0.01261227 0.00631653 -0.00243812 -0.00350017 -0.00113093 | ||
42 | -0.00033429 -0.00113093 -0.00171484 -0.00133542 -0.00080639 -0.00133542 -0.00171484 -0.00113093 -0.00033429]; | ||
43 | |||
44 | |||
45 | lo0filt = [ | ||
46 | 0.00341614 -0.01551246 -0.03848215 -0.01551246 0.00341614 | ||
47 | -0.01551246 0.05586982 0.15925570 0.05586982 -0.01551246 | ||
48 | -0.03848215 0.15925570 0.40304148 0.15925570 -0.03848215 | ||
49 | -0.01551246 0.05586982 0.15925570 0.05586982 -0.01551246 | ||
50 | 0.00341614 -0.01551246 -0.03848215 -0.01551246 0.00341614]; | ||
51 | |||
52 | lofilt = 2*[ | ||
53 | 0.00085404 -0.00244917 -0.00387812 -0.00944432 -0.00962054 -0.00944432 -0.00387812 -0.00244917 0.00085404 | ||
54 | -0.00244917 -0.00523281 -0.00661117 0.00410600 0.01002988 0.00410600 -0.00661117 -0.00523281 -0.00244917 | ||
55 | -0.00387812 -0.00661117 0.01396746 0.03277038 0.03981393 0.03277038 0.01396746 -0.00661117 -0.00387812 | ||
56 | -0.00944432 0.00410600 0.03277038 0.06426333 0.08169618 0.06426333 0.03277038 0.00410600 -0.00944432 | ||
57 | -0.00962054 0.01002988 0.03981393 0.08169618 0.10096540 0.08169618 0.03981393 0.01002988 -0.00962054 | ||
58 | -0.00944432 0.00410600 0.03277038 0.06426333 0.08169618 0.06426333 0.03277038 0.00410600 -0.00944432 | ||
59 | -0.00387812 -0.00661117 0.01396746 0.03277038 0.03981393 0.03277038 0.01396746 -0.00661117 -0.00387812 | ||
60 | -0.00244917 -0.00523281 -0.00661117 0.00410600 0.01002988 0.00410600 -0.00661117 -0.00523281 -0.00244917 | ||
61 | 0.00085404 -0.00244917 -0.00387812 -0.00944432 -0.00962054 -0.00944432 -0.00387812 -0.00244917 0.00085404]; | ||
62 | |||
63 | bfilts = [... | ||
64 | 0.00277643 0.00496194 0.01026699 0.01455399 0.01026699 0.00496194 0.00277643 ... | ||
65 | -0.00986904 -0.00893064 0.01189859 0.02755155 0.01189859 -0.00893064 -0.00986904 ... | ||
66 | -0.01021852 -0.03075356 -0.08226445 -0.11732297 -0.08226445 -0.03075356 -0.01021852 ... | ||
67 | 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 ... | ||
68 | 0.01021852 0.03075356 0.08226445 0.11732297 0.08226445 0.03075356 0.01021852 ... | ||
69 | 0.00986904 0.00893064 -0.01189859 -0.02755155 -0.01189859 0.00893064 0.00986904 ... | ||
70 | -0.00277643 -0.00496194 -0.01026699 -0.01455399 -0.01026699 -0.00496194 -0.00277643; | ||
71 | ... | ||
72 | -0.00343249 -0.00640815 -0.00073141 0.01124321 0.00182078 0.00285723 0.01166982 ... | ||
73 | -0.00358461 -0.01977507 -0.04084211 -0.00228219 0.03930573 0.01161195 0.00128000 ... | ||
74 | 0.01047717 0.01486305 -0.04819057 -0.12227230 -0.05394139 0.00853965 -0.00459034 ... | ||
75 | 0.00790407 0.04435647 0.09454202 -0.00000000 -0.09454202 -0.04435647 -0.00790407 ... | ||
76 | 0.00459034 -0.00853965 0.05394139 0.12227230 0.04819057 -0.01486305 -0.01047717 ... | ||
77 | -0.00128000 -0.01161195 -0.03930573 0.00228219 0.04084211 0.01977507 0.00358461 ... | ||
78 | -0.01166982 -0.00285723 -0.00182078 -0.01124321 0.00073141 0.00640815 0.00343249; | ||
79 | ... | ||
80 | 0.00343249 0.00358461 -0.01047717 -0.00790407 -0.00459034 0.00128000 0.01166982 ... | ||
81 | 0.00640815 0.01977507 -0.01486305 -0.04435647 0.00853965 0.01161195 0.00285723 ... | ||
82 | 0.00073141 0.04084211 0.04819057 -0.09454202 -0.05394139 0.03930573 0.00182078 ... | ||
83 | -0.01124321 0.00228219 0.12227230 -0.00000000 -0.12227230 -0.00228219 0.01124321 ... | ||
84 | -0.00182078 -0.03930573 0.05394139 0.09454202 -0.04819057 -0.04084211 -0.00073141 ... | ||
85 | -0.00285723 -0.01161195 -0.00853965 0.04435647 0.01486305 -0.01977507 -0.00640815 ... | ||
86 | -0.01166982 -0.00128000 0.00459034 0.00790407 0.01047717 -0.00358461 -0.00343249; | ||
87 | ... | ||
88 | -0.00277643 0.00986904 0.01021852 -0.00000000 -0.01021852 -0.00986904 0.00277643 ... | ||
89 | -0.00496194 0.00893064 0.03075356 -0.00000000 -0.03075356 -0.00893064 0.00496194 ... | ||
90 | -0.01026699 -0.01189859 0.08226445 -0.00000000 -0.08226445 0.01189859 0.01026699 ... | ||
91 | -0.01455399 -0.02755155 0.11732297 -0.00000000 -0.11732297 0.02755155 0.01455399 ... | ||
92 | -0.01026699 -0.01189859 0.08226445 -0.00000000 -0.08226445 0.01189859 0.01026699 ... | ||
93 | -0.00496194 0.00893064 0.03075356 -0.00000000 -0.03075356 -0.00893064 0.00496194 ... | ||
94 | -0.00277643 0.00986904 0.01021852 -0.00000000 -0.01021852 -0.00986904 0.00277643; | ||
95 | ... | ||
96 | -0.01166982 -0.00128000 0.00459034 0.00790407 0.01047717 -0.00358461 -0.00343249 ... | ||
97 | -0.00285723 -0.01161195 -0.00853965 0.04435647 0.01486305 -0.01977507 -0.00640815 ... | ||
98 | -0.00182078 -0.03930573 0.05394139 0.09454202 -0.04819057 -0.04084211 -0.00073141 ... | ||
99 | -0.01124321 0.00228219 0.12227230 -0.00000000 -0.12227230 -0.00228219 0.01124321 ... | ||
100 | 0.00073141 0.04084211 0.04819057 -0.09454202 -0.05394139 0.03930573 0.00182078 ... | ||
101 | 0.00640815 0.01977507 -0.01486305 -0.04435647 0.00853965 0.01161195 0.00285723 ... | ||
102 | 0.00343249 0.00358461 -0.01047717 -0.00790407 -0.00459034 0.00128000 0.01166982; | ||
103 | ... | ||
104 | -0.01166982 -0.00285723 -0.00182078 -0.01124321 0.00073141 0.00640815 0.00343249 ... | ||
105 | -0.00128000 -0.01161195 -0.03930573 0.00228219 0.04084211 0.01977507 0.00358461 ... | ||
106 | 0.00459034 -0.00853965 0.05394139 0.12227230 0.04819057 -0.01486305 -0.01047717 ... | ||
107 | 0.00790407 0.04435647 0.09454202 -0.00000000 -0.09454202 -0.04435647 -0.00790407 ... | ||
108 | 0.01047717 0.01486305 -0.04819057 -0.12227230 -0.05394139 0.00853965 -0.00459034 ... | ||
109 | -0.00358461 -0.01977507 -0.04084211 -0.00228219 0.03930573 0.01161195 0.00128000 ... | ||
110 | -0.00343249 -0.00640815 -0.00073141 0.01124321 0.00182078 0.00285723 0.01166982]'; | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/spyrBand.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/spyrBand.m deleted file mode 100755 index 474a8dc..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/spyrBand.m +++ /dev/null | |||
@@ -1,34 +0,0 @@ | |||
1 | % [LEV,IND] = spyrBand(PYR,INDICES,LEVEL,BAND) | ||
2 | % | ||
3 | % Access a band from a steerable pyramid. | ||
4 | % | ||
5 | % LEVEL indicates the scale (finest = 1, coarsest = spyrHt(INDICES)). | ||
6 | % | ||
7 | % BAND (optional, default=1) indicates which subband | ||
8 | % (1 = vertical, rest proceeding anti-clockwise). | ||
9 | |||
10 | % Eero Simoncelli, 6/96. | ||
11 | |||
12 | function res = spyrBand(pyr,pind,level,band) | ||
13 | |||
14 | if (exist('level') ~= 1) | ||
15 | level = 1; | ||
16 | end | ||
17 | |||
18 | if (exist('band') ~= 1) | ||
19 | band = 1; | ||
20 | end | ||
21 | |||
22 | nbands = spyrNumBands(pind); | ||
23 | if ((band > nbands) | (band < 1)) | ||
24 | error(sprintf('Bad band number (%d) should be in range [1,%d].', band, nbands)); | ||
25 | end | ||
26 | |||
27 | maxLev = spyrHt(pind); | ||
28 | if ((level > maxLev) | (level < 1)) | ||
29 | error(sprintf('Bad level number (%d), should be in range [1,%d].', level, maxLev)); | ||
30 | end | ||
31 | |||
32 | firstband = 1 + band + nbands*(level-1); | ||
33 | res = pyrBand(pyr, pind, firstband); | ||
34 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/spyrHigh.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/spyrHigh.m deleted file mode 100755 index f91b466..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/spyrHigh.m +++ /dev/null | |||
@@ -1,10 +0,0 @@ | |||
1 | % RES = spyrHigh(PYR, INDICES) | ||
2 | % | ||
3 | % Access the highpass residual band from a steerable pyramid. | ||
4 | |||
5 | % Eero Simoncelli, 6/96. | ||
6 | |||
7 | function res = spyrHigh(pyr,pind) | ||
8 | |||
9 | res = pyrBand(pyr, pind, 1); | ||
10 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/spyrHt.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/spyrHt.m deleted file mode 100755 index 8706b9e..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/spyrHt.m +++ /dev/null | |||
@@ -1,16 +0,0 @@ | |||
1 | % [HEIGHT] = spyrHt(INDICES) | ||
2 | % | ||
3 | % Compute height of steerable pyramid with given index matrix. | ||
4 | |||
5 | % Eero Simoncelli, 6/96. | ||
6 | |||
7 | function [ht] = spyrHt(pind) | ||
8 | |||
9 | nbands = spyrNumBands(pind); | ||
10 | |||
11 | % Don't count lowpass, or highpass residual bands | ||
12 | if (size(pind,1) > 2) | ||
13 | ht = (size(pind,1)-2)/nbands; | ||
14 | else | ||
15 | ht = 0; | ||
16 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/spyrLev.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/spyrLev.m deleted file mode 100755 index 5cb4a85..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/spyrLev.m +++ /dev/null | |||
@@ -1,24 +0,0 @@ | |||
1 | % [LEV,IND] = spyrLev(PYR,INDICES,LEVEL) | ||
2 | % | ||
3 | % Access a level from a steerable pyramid. | ||
4 | % Return as an SxB matrix, B = number of bands, S = total size of a band. | ||
5 | % Also returns an Bx2 matrix containing dimensions of the subbands. | ||
6 | |||
7 | % Eero Simoncelli, 6/96. | ||
8 | |||
9 | function [lev,ind] = spyrLev(pyr,pind,level) | ||
10 | |||
11 | nbands = spyrNumBands(pind); | ||
12 | |||
13 | if ((level > spyrHt(pind)) | (level < 1)) | ||
14 | error(sprintf('Level number must be in the range [1, %d].', spyrHt(pind))); | ||
15 | end | ||
16 | |||
17 | firstband = 2 + nbands*(level-1); | ||
18 | firstind = 1; | ||
19 | for l=1:firstband-1 | ||
20 | firstind = firstind + prod(pind(l,:)); | ||
21 | end | ||
22 | |||
23 | ind = pind(firstband:firstband+nbands-1,:); | ||
24 | lev = pyr(firstind:firstind+sum(prod(ind'))-1); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/spyrNumBands.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/spyrNumBands.m deleted file mode 100755 index 68aec3f..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/spyrNumBands.m +++ /dev/null | |||
@@ -1,20 +0,0 @@ | |||
1 | % [NBANDS] = spyrNumBands(INDICES) | ||
2 | % | ||
3 | % Compute number of orientation bands in a steerable pyramid with | ||
4 | % given index matrix. If the pyramid contains only the highpass and | ||
5 | % lowpass bands (i.e., zero levels), returns 0. | ||
6 | |||
7 | % Eero Simoncelli, 2/97. | ||
8 | |||
9 | function [nbands] = spyrNumBands(pind) | ||
10 | |||
11 | if (size(pind,1) == 2) | ||
12 | nbands = 0; | ||
13 | else | ||
14 | % Count number of orientation bands: | ||
15 | b = 3; | ||
16 | while ((b <= size(pind,1)) & all( pind(b,:) == pind(2,:)) ) | ||
17 | b = b+1; | ||
18 | end | ||
19 | nbands = b-2; | ||
20 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/steer.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/steer.m deleted file mode 100755 index 8f9c2ac..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/steer.m +++ /dev/null | |||
@@ -1,68 +0,0 @@ | |||
1 | % RES = STEER(BASIS, ANGLE, HARMONICS, STEERMTX) | ||
2 | % | ||
3 | % Steer BASIS to the specfied ANGLE. | ||
4 | % | ||
5 | % BASIS should be a matrix whose columns are vectorized rotated copies of a | ||
6 | % steerable function, or the responses of a set of steerable filters. | ||
7 | % | ||
8 | % ANGLE can be a scalar, or a column vector the size of the basis. | ||
9 | % | ||
10 | % HARMONICS (optional, default is N even or odd low frequencies, as for | ||
11 | % derivative filters) should be a list of harmonic numbers indicating | ||
12 | % the angular harmonic content of the basis. | ||
13 | % | ||
14 | % STEERMTX (optional, default assumes cosine phase harmonic components, | ||
15 | % and filter positions at 2pi*n/N) should be a matrix which maps | ||
16 | % the filters onto Fourier series components (ordered [cos0 cos1 sin1 | ||
17 | % cos2 sin2 ... sinN]). See steer2HarmMtx.m | ||
18 | |||
19 | % Eero Simoncelli, 7/96. | ||
20 | |||
21 | function res = steer(basis,angle,harmonics,steermtx) | ||
22 | |||
23 | num = size(basis,2); | ||
24 | |||
25 | if ( any(size(angle) ~= [size(basis,1) 1]) & any(size(angle) ~= [1 1]) ) | ||
26 | error('ANGLE must be a scalar, or a column vector the size of the basis elements'); | ||
27 | end | ||
28 | |||
29 | %% If HARMONICS are not passed, assume derivatives. | ||
30 | if (exist('harmonics') ~= 1) | ||
31 | if (mod(num,2) == 0) | ||
32 | harmonics = [0:(num/2)-1]'*2 + 1; | ||
33 | else | ||
34 | harmonics = [0:(num-1)/2]'*2; | ||
35 | end | ||
36 | else | ||
37 | harmonics = harmonics(:); | ||
38 | if ((2*size(harmonics,1)-any(harmonics == 0)) ~= num) | ||
39 | error('harmonics list is incompatible with basis size'); | ||
40 | end | ||
41 | end | ||
42 | |||
43 | %% If STEERMTX not passed, assume evenly distributed cosine-phase filters: | ||
44 | if (exist('steermtx') ~= 1) | ||
45 | steermtx = steer2HarmMtx(harmonics, pi*[0:num-1]/num, 'even'); | ||
46 | end | ||
47 | |||
48 | steervect = zeros(size(angle,1),num); | ||
49 | arg = angle * harmonics(find(harmonics~=0))'; | ||
50 | if (all(harmonics)) | ||
51 | steervect(:, 1:2:num) = cos(arg); | ||
52 | steervect(:, 2:2:num) = sin(arg); | ||
53 | else | ||
54 | steervect(:, 1) = ones(size(arg,1),1); | ||
55 | steervect(:, 2:2:num) = cos(arg); | ||
56 | steervect(:, 3:2:num) = sin(arg); | ||
57 | end | ||
58 | |||
59 | steervect = steervect * steermtx; | ||
60 | |||
61 | if (size(steervect,1) > 1) | ||
62 | tmp = basis' .* steervect'; | ||
63 | res = sum(tmp)'; | ||
64 | else | ||
65 | res = basis * steervect'; | ||
66 | end | ||
67 | |||
68 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/steer2HarmMtx.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/steer2HarmMtx.m deleted file mode 100755 index 1f3e80e..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/steer2HarmMtx.m +++ /dev/null | |||
@@ -1,71 +0,0 @@ | |||
1 | % MTX = steer2HarmMtx(HARMONICS, ANGLES, REL_PHASES) | ||
2 | % | ||
3 | % Compute a steering matrix (maps a directional basis set onto the | ||
4 | % angular Fourier harmonics). HARMONICS is a vector specifying the | ||
5 | % angular harmonics contained in the steerable basis/filters. ANGLES | ||
6 | % (optional) is a vector specifying the angular position of each filter. | ||
7 | % REL_PHASES (optional, default = 'even') specifies whether the harmonics | ||
8 | % are cosine or sine phase aligned about those positions. | ||
9 | % The result matrix is suitable for passing to the function STEER. | ||
10 | |||
11 | % Eero Simoncelli, 7/96. | ||
12 | |||
13 | function mtx = steer2HarmMtx(harmonics, angles, evenorodd) | ||
14 | |||
15 | %%================================================================= | ||
16 | %%% Optional Parameters: | ||
17 | |||
18 | if (exist('evenorodd') ~= 1) | ||
19 | evenorodd = 'even'; | ||
20 | end | ||
21 | |||
22 | % Make HARMONICS a row vector | ||
23 | harmonics = harmonics(:)'; | ||
24 | |||
25 | numh = 2*size(harmonics,2) - any(harmonics == 0); | ||
26 | |||
27 | if (exist('angles') ~= 1) | ||
28 | angles = pi * [0:numh-1]'/numh; | ||
29 | else | ||
30 | angles = angles(:); | ||
31 | end | ||
32 | |||
33 | %%================================================================= | ||
34 | |||
35 | if isstr(evenorodd) | ||
36 | if strcmp(evenorodd,'even') | ||
37 | evenorodd = 0; | ||
38 | elseif strcmp(evenorodd,'odd') | ||
39 | evenorodd = 1; | ||
40 | else | ||
41 | error('EVEN_OR_ODD should be the string EVEN or ODD'); | ||
42 | end | ||
43 | end | ||
44 | |||
45 | %% Compute inverse matrix, which maps Fourier components onto | ||
46 | %% steerable basis. | ||
47 | imtx = zeros(size(angles,1),numh); | ||
48 | col = 1; | ||
49 | for h=harmonics | ||
50 | args = h*angles; | ||
51 | if (h == 0) | ||
52 | imtx(:,col) = ones(size(angles)); | ||
53 | col = col+1; | ||
54 | elseif evenorodd | ||
55 | imtx(:,col) = sin(args); | ||
56 | imtx(:,col+1) = -cos(args); | ||
57 | col = col+2; | ||
58 | else | ||
59 | imtx(:,col) = cos(args); | ||
60 | imtx(:,col+1) = sin(args); | ||
61 | col = col+2; | ||
62 | end | ||
63 | end | ||
64 | |||
65 | r = rank(imtx); | ||
66 | if (( r ~= numh ) & ( r ~= size(angles,1) )) | ||
67 | fprintf(2,'WARNING: matrix is not full rank'); | ||
68 | end | ||
69 | |||
70 | mtx = pinv(imtx); | ||
71 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/subMtx.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/subMtx.m deleted file mode 100755 index ea3c2ea..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/subMtx.m +++ /dev/null | |||
@@ -1,21 +0,0 @@ | |||
1 | % MTX = subMtx(VEC, DIMENSIONS, START_INDEX) | ||
2 | % | ||
3 | % Reshape a portion of VEC starting from START_INDEX (optional, | ||
4 | % default=1) to the given dimensions. | ||
5 | |||
6 | % Eero Simoncelli, 6/96. | ||
7 | |||
8 | function mtx = subMtx(vec, sz, offset) | ||
9 | |||
10 | if (exist('offset') ~= 1) | ||
11 | offset = 1; | ||
12 | end | ||
13 | |||
14 | vec = vec(:); | ||
15 | sz = sz(:); | ||
16 | |||
17 | if (size(sz,1) ~= 2) | ||
18 | error('DIMENSIONS must be a 2-vector.'); | ||
19 | end | ||
20 | |||
21 | mtx = reshape( vec(offset:offset+prod(sz)-1), sz(1), sz(2) ); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/textureAnalysis.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/textureAnalysis.m deleted file mode 100755 index d7a0ec1..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/textureAnalysis.m +++ /dev/null | |||
@@ -1,245 +0,0 @@ | |||
1 | function [params] = textureAnalysis(im0, Nsc, Nor, Na) | ||
2 | |||
3 | % Analyze texture for application of Portilla-Simoncelli model/algorithm. | ||
4 | % | ||
5 | % [params] = textureAnalysis(im0, Nsc, Nor, Na); | ||
6 | % im0: original image | ||
7 | % Nsc: number of scales | ||
8 | % Nor: number of orientations | ||
9 | % Na: spatial neighborhood considered (Na x Na) | ||
10 | % | ||
11 | % Example: Nsc=4; Nor=4; Na=7; | ||
12 | % | ||
13 | % See also textureSynthesis. | ||
14 | |||
15 | % Javier Portilla and Eero Simoncelli. | ||
16 | % Work described in: | ||
17 | % "A Parametric Texture Model based on Joint Statistics of Complex Wavelet Coefficients". | ||
18 | % J Portilla and E P Simoncelli. Int'l Journal of Computer Vision, | ||
19 | % vol.40(1), pp. 49-71, Dec 2000. | ||
20 | % | ||
21 | % Please refer to this publication if you use the program for research or | ||
22 | % for technical applications. Thank you. | ||
23 | % | ||
24 | % Copyright, Center for Neural Science, New York University, January 2001. | ||
25 | % All rights reserved. | ||
26 | |||
27 | |||
28 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
29 | |||
30 | Warn = 0; % Set to 1 if you want to see warning messages | ||
31 | |||
32 | %% Check required args are passed | ||
33 | if (nargin < 4) | ||
34 | error('Function called with too few input arguments'); | ||
35 | end | ||
36 | |||
37 | %% 1D interpolation filter, for scale cross-correlations: | ||
38 | interp = [-1/16 0 9/16 1 9/16 0 -1/16]/sqrt(2); | ||
39 | |||
40 | if ( mod(Na,2) == 0 ) | ||
41 | error('Na is not an odd integer'); | ||
42 | end | ||
43 | |||
44 | %% If the spatial neighborhood Na is too big for the lower scales, | ||
45 | %% "modacor22.m" will make it as big as the spatial support at | ||
46 | %% each scale: | ||
47 | |||
48 | [Ny,Nx] = size(im0); | ||
49 | nth = log2(min(Ny,Nx)/Na); | ||
50 | if nth<Nsc & Warn, | ||
51 | fprintf(1,'Warning: Na will be cut off for levels above #%d !\n', floor(nth+1)); | ||
52 | end | ||
53 | |||
54 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
55 | |||
56 | la = floor((Na-1)/2); | ||
57 | |||
58 | %% Pixel statistics | ||
59 | [mn0 mx0] = size(im0); | ||
60 | mean0 = mean2(im0); | ||
61 | var0 = var2(im0, mean0); | ||
62 | skew0 = skew2(im0, mean0, var0); | ||
63 | kurt0 = kurt2(im0, mean0, var0); | ||
64 | statg0 = [mean0 var0 skew0 kurt0 mn0 mx0]; | ||
65 | |||
66 | % Add a little bit of noise to the original, in case it has been | ||
67 | % artificially generated, to avoid instability crated by symmetric | ||
68 | % conditions at the synthesis stage. | ||
69 | |||
70 | %im0 = im0 + (mx0-mn0)/1000*randn(size(im0)); %kvs | ||
71 | |||
72 | %% Build the steerable pyramid | ||
73 | [pyr0,pind0] = buildSCFpyr(im0,Nsc,Nor-1); | ||
74 | |||
75 | if ( any(vector(mod(pind0,2))) ) | ||
76 | error('Algorithm will fail: Some bands have odd dimensions!'); | ||
77 | end | ||
78 | |||
79 | %% Subtract mean of lowBand: | ||
80 | nband = size(pind0,1); | ||
81 | pyr0(pyrBandIndices(pind0,nband)) = ... | ||
82 | real(pyrBand(pyr0,pind0,nband)) - mean2(real(pyrBand(pyr0,pind0,nband))); | ||
83 | |||
84 | rpyr0 = real(pyr0); | ||
85 | apyr0 = abs(pyr0); | ||
86 | |||
87 | figure(gcf) | ||
88 | clf | ||
89 | showIm(im0,'auto',1); title('Original'); drawnow | ||
90 | |||
91 | %% Subtract mean of magnitude: | ||
92 | magMeans0 = zeros(size(pind0,1), 1); | ||
93 | for nband = 1:size(pind0,1) | ||
94 | indices = pyrBandIndices(pind0,nband); | ||
95 | magMeans0(nband) = mean2(apyr0(indices)); | ||
96 | apyr0(indices) = apyr0(indices) - magMeans0(nband); | ||
97 | end | ||
98 | |||
99 | %% Compute central autoCorr of lowband | ||
100 | acr = NaN * ones(Na,Na,Nsc+1); | ||
101 | nband = size(pind0,1); | ||
102 | ch = pyrBand(pyr0,pind0,nband); | ||
103 | [mpyr,mpind] = buildSFpyr(real(ch),0,0); | ||
104 | im = pyrBand(mpyr,mpind,2); | ||
105 | [Nly Nlx] = size(ch); | ||
106 | Sch = min(Nly,Nlx); %size of low band | ||
107 | le = min(Sch/2-1,la); | ||
108 | cy = Nly/2+1; | ||
109 | cx = Nlx/2+1; | ||
110 | ac = fftshift(real(ifft2(abs(fft2(im)).^2)))/prod(size(ch)); | ||
111 | ac = ac(cy-le:cy+le,cx-le:cx+le); | ||
112 | acr(la-le+1:la+le+1,la-le+1:la+le+1,Nsc+1) = ac; | ||
113 | skew0p = zeros(Nsc+1,1); | ||
114 | kurt0p = zeros(Nsc+1,1); | ||
115 | vari = ac(le+1,le+1); | ||
116 | if vari/var0 > 1e-6, | ||
117 | skew0p(Nsc+1) = mean2(im.^3)/vari^1.5; | ||
118 | kurt0p(Nsc+1) = mean2(im.^4)/vari^2; | ||
119 | else | ||
120 | skew0p(Nsc+1) = 0; | ||
121 | kurt0p(Nsc+1) = 3; | ||
122 | end | ||
123 | |||
124 | %% Compute central autoCorr of each Mag band, and the autoCorr of the | ||
125 | %% combined (non-oriented) band. | ||
126 | ace = NaN * ones(Na,Na,Nsc,Nor); | ||
127 | for nsc = Nsc:-1:1, | ||
128 | for nor = 1:Nor, | ||
129 | nband = (nsc-1)*Nor+nor+1; | ||
130 | ch = pyrBand(apyr0,pind0,nband); | ||
131 | [Nly, Nlx] = size(ch); | ||
132 | Sch = min(Nlx, Nly); | ||
133 | le = min(Sch/2-1,la); | ||
134 | cx = Nlx/2+1; %Assumes Nlx even | ||
135 | cy = Nly/2+1; | ||
136 | ac = fftshift(real(ifft2(abs(fft2(ch)).^2)))/prod(size(ch)); | ||
137 | ac = ac(cy-le:cy+le,cx-le:cx+le); | ||
138 | ace(la-le+1:la+le+1,la-le+1:la+le+1,nsc,nor) = ac; | ||
139 | end | ||
140 | |||
141 | %% Combine ori bands | ||
142 | |||
143 | bandNums = [1:Nor] + (nsc-1)*Nor+1; %ori bands only | ||
144 | ind1 = pyrBandIndices(pind0, bandNums(1)); | ||
145 | indN = pyrBandIndices(pind0, bandNums(Nor)); | ||
146 | bandInds = [ind1(1):indN(length(indN))]; | ||
147 | %% Make fake pyramid, containing dummy hi, ori, lo | ||
148 | fakePind = [pind0(bandNums(1),:);pind0(bandNums(1):bandNums(Nor)+1,:)]; | ||
149 | fakePyr = [zeros(prod(fakePind(1,:)),1);... | ||
150 | rpyr0(bandInds); zeros(prod(fakePind(size(fakePind,1),:)),1);]; | ||
151 | ch = reconSFpyr(fakePyr, fakePind, [1]); % recon ori bands only | ||
152 | im = real(expand(im,2))/4; | ||
153 | im = im + ch; | ||
154 | ac = fftshift(real(ifft2(abs(fft2(im)).^2)))/prod(size(ch)); | ||
155 | ac = ac(cy-le:cy+le,cx-le:cx+le); | ||
156 | acr(la-le+1:la+le+1,la-le+1:la+le+1,nsc) = ac; | ||
157 | vari = ac(le+1,le+1); | ||
158 | if vari/var0 > 1e-6, | ||
159 | skew0p(nsc) = mean2(im.^3)/vari^1.5; | ||
160 | kurt0p(nsc) = mean2(im.^4)/vari^2; | ||
161 | else | ||
162 | skew0p(nsc) = 0; | ||
163 | kurt0p(nsc) = 3; | ||
164 | end | ||
165 | end | ||
166 | |||
167 | %% Compute the cross-correlation matrices of the coefficient magnitudes | ||
168 | %% pyramid at the different levels and orientations | ||
169 | |||
170 | C0 = zeros(Nor,Nor,Nsc+1); | ||
171 | Cx0 = zeros(Nor,Nor,Nsc); | ||
172 | |||
173 | Cr0 = zeros(2*Nor,2*Nor,Nsc+1); | ||
174 | Crx0 = zeros(2*Nor,2*Nor,Nsc); | ||
175 | |||
176 | for nsc = 1:Nsc, | ||
177 | firstBnum = (nsc-1)*Nor+2; | ||
178 | cousinSz = prod(pind0(firstBnum,:)); | ||
179 | ind = pyrBandIndices(pind0,firstBnum); | ||
180 | cousinInd = ind(1) + [0:Nor*cousinSz-1]; | ||
181 | |||
182 | if (nsc<Nsc) | ||
183 | parents = zeros(cousinSz,Nor); | ||
184 | rparents = zeros(cousinSz,Nor*2); | ||
185 | for nor=1:Nor, | ||
186 | nband = (nsc-1+1)*Nor+nor+1; | ||
187 | |||
188 | tmp = expand(pyrBand(pyr0, pind0, nband),2)/4; | ||
189 | rtmp = real(tmp); itmp = imag(tmp); | ||
190 | %% Double phase: | ||
191 | tmp = sqrt(rtmp.^2 + itmp.^2) .* exp(2 * sqrt(-1) * atan2(rtmp,itmp)); | ||
192 | rparents(:,nor) = vector(real(tmp)); | ||
193 | rparents(:,Nor+nor) = vector(imag(tmp)); | ||
194 | |||
195 | tmp = abs(tmp); | ||
196 | parents(:,nor) = vector(tmp - mean2(tmp)); | ||
197 | end | ||
198 | else | ||
199 | tmp = real(expand(pyrLow(rpyr0,pind0),2))/4; | ||
200 | rparents = [vector(tmp),... | ||
201 | vector(shift(tmp,[0 1])), vector(shift(tmp,[0 -1])), ... | ||
202 | vector(shift(tmp,[1 0])), vector(shift(tmp,[-1 0]))]; | ||
203 | parents = []; | ||
204 | end | ||
205 | |||
206 | cousins = reshape(apyr0(cousinInd), [cousinSz Nor]); | ||
207 | nc = size(cousins,2); np = size(parents,2); | ||
208 | C0(1:nc,1:nc,nsc) = innerProd(cousins)/cousinSz; | ||
209 | if (np > 0) | ||
210 | Cx0(1:nc,1:np,nsc) = (cousins'*parents)/cousinSz; | ||
211 | if (nsc==Nsc) | ||
212 | C0(1:np,1:np,Nsc+1) = innerProd(parents)/(cousinSz/4); | ||
213 | end | ||
214 | end | ||
215 | |||
216 | cousins = reshape(real(pyr0(cousinInd)), [cousinSz Nor]); | ||
217 | nrc = size(cousins,2); nrp = size(rparents,2); | ||
218 | Cr0(1:nrc,1:nrc,nsc) = innerProd(cousins)/cousinSz; | ||
219 | if (nrp > 0) | ||
220 | Crx0(1:nrc,1:nrp,nsc) = (cousins'*rparents)/cousinSz; | ||
221 | if (nsc==Nsc) | ||
222 | Cr0(1:nrp,1:nrp,Nsc+1) = innerProd(rparents)/(cousinSz/4); | ||
223 | end | ||
224 | end | ||
225 | end | ||
226 | |||
227 | %% Calculate the mean, range and variance of the LF and HF residuals' energy. | ||
228 | |||
229 | channel = pyr0(pyrBandIndices(pind0,1)); | ||
230 | vHPR0 = mean2(channel.^2); | ||
231 | |||
232 | statsLPim = [skew0p kurt0p]; | ||
233 | |||
234 | params = struct('pixelStats', statg0, ... | ||
235 | 'pixelLPStats', statsLPim, ... | ||
236 | 'autoCorrReal', acr, ... | ||
237 | 'autoCorrMag', ace, ... | ||
238 | 'magMeans', magMeans0, ... | ||
239 | 'cousinMagCorr', C0, ... | ||
240 | 'parentMagCorr', Cx0, ... | ||
241 | 'cousinRealCorr', Cr0, ... | ||
242 | 'parentRealCorr', Crx0, ... | ||
243 | 'varianceHPR', vHPR0); | ||
244 | |||
245 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/textureSynthesis.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/textureSynthesis.m deleted file mode 100755 index 38fce5a..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/textureSynthesis.m +++ /dev/null | |||
@@ -1,436 +0,0 @@ | |||
1 | function [im,snrP,imS] = textureSynthesis(params, im0, Niter, cmask, imask) | ||
2 | |||
3 | % [res,snrP,imS] = textureSynthesis(params, initialIm, Niter, cmask, imask) | ||
4 | % | ||
5 | % Synthesize texture applying Portilla-Simoncelli model/algorithm. | ||
6 | % | ||
7 | % params: structure containing texture parameters (as returned by textureAnalysis). | ||
8 | % | ||
9 | % im0: initial image, OR a vector (Ydim, Xdim, [SEED]) containing | ||
10 | % dimensions of desired image and an optional seed for the random | ||
11 | % number generator. If dimensions are passed, initial image is | ||
12 | % Gaussian white noise. | ||
13 | % | ||
14 | % Niter (optional): Number of iterations. Default = 50. | ||
15 | % | ||
16 | % cmask (optional): binary column vector (4x1) indicating which sets of | ||
17 | % constraints we want to apply in the synthesis. The four sets are: | ||
18 | % 1) Marginal statistics (mean, var, skew, kurt, range) | ||
19 | % 2) Correlation of subbands (space, orientation, scale) | ||
20 | % 3) Correlation of magnitude responses (sp, or, sc) | ||
21 | % 4) Relative local phase | ||
22 | % | ||
23 | % imask (optional): imsizex2 matrix. First column is a mask, second | ||
24 | % column contains the image values to be imposed. If only one column is | ||
25 | % provided, it assumes it corresponds to the image values, and it uses | ||
26 | % a raised cosine square for the mask. | ||
27 | % snrP (optional): Set of adjustment values (in dB) of the parameters. | ||
28 | % imS (optional): Sequence of synthetic images, from niter = 1 to 2^n, being | ||
29 | % n = floor(log2(Niter)). | ||
30 | |||
31 | % Javier Portilla and Eero Simoncelli. | ||
32 | % Work described in: | ||
33 | % "A Parametric Texture Model based on Joint Statistics of Complex Wavelet Coefficients". | ||
34 | % J Portilla and E P Simoncelli. Int'l Journal of Computer Vision, | ||
35 | % vol.40(1), pp. 49-71, Dec 2000. | ||
36 | % | ||
37 | % Please refer to this publication if you use the program for research or | ||
38 | % for technical applications. Thank you. | ||
39 | % | ||
40 | % Copyright, Center for Neural Science, New York University, January 2001. | ||
41 | % All rights reserved. | ||
42 | |||
43 | Warn = 0; % Set to 1 if you want to see warning messages | ||
44 | |||
45 | %% Check required args are passed: | ||
46 | if (nargin < 2) | ||
47 | error('Function called with too few input arguments'); | ||
48 | end | ||
49 | |||
50 | if ( ~exist('Niter') | isempty(Niter) ) | ||
51 | Niter = 50; | ||
52 | end | ||
53 | |||
54 | if (exist('cmask') & ~isempty(cmask) ) | ||
55 | cmask = (cmask > 0.5); % indices of ones in mask | ||
56 | else | ||
57 | cmask = ones(4,1); | ||
58 | end | ||
59 | |||
60 | %% Extract parameters | ||
61 | statg0 = params.pixelStats; | ||
62 | mean0 = statg0(1); var0 = statg0(2); | ||
63 | skew0 = statg0(3); kurt0 = statg0(4); | ||
64 | mn0 = statg0(5); mx0 = statg0(6); | ||
65 | statsLPim = params.pixelLPStats; | ||
66 | skew0p = statsLPim(:,1); | ||
67 | kurt0p = statsLPim(:,2); | ||
68 | vHPR0 = params.varianceHPR; | ||
69 | acr0 = params.autoCorrReal; | ||
70 | ace0 = params.autoCorrMag; | ||
71 | magMeans0 = params.magMeans; | ||
72 | C0 = params.cousinMagCorr; | ||
73 | Cx0 = params.parentMagCorr; | ||
74 | Crx0 = params.parentRealCorr; | ||
75 | |||
76 | %% Extract {Nsc, Nor, Na} from params | ||
77 | tmp = size(params.autoCorrMag); | ||
78 | Na = tmp(1); Nsc = tmp(3); | ||
79 | Nor = tmp(length(tmp))*(length(tmp)==4) + (length(tmp)<4); | ||
80 | la = (Na-1)/2; | ||
81 | |||
82 | %% If im0 is a vector of length 2, create Gaussian white noise image of this | ||
83 | %% size, with desired pixel mean and variance. If vector length is | ||
84 | %% 3, use the 3rd element to seed the random number generator. | ||
85 | if ( length(im0) <= 3 ) | ||
86 | if ( length(im0) == 3) | ||
87 | randn('state', im0(3)); % Reset Seed | ||
88 | im0 = im0(1:2); | ||
89 | end | ||
90 | im = mean0 + sqrt(var0)*randn(im0); | ||
91 | else | ||
92 | im = im0; | ||
93 | end | ||
94 | |||
95 | %% If the spatial neighborhood Na is too big for the lower scales, | ||
96 | %% "modacor22.m" will make it as big as the spatial support at | ||
97 | %% each scale: | ||
98 | [Ny,Nx] = size(im); | ||
99 | nth = log2(min(Ny,Nx)/Na); | ||
100 | if nth<Nsc+1 & Warn, | ||
101 | fprintf(1,'Warning: Na will be cut off for levels above #%d !\n',floor(nth)); | ||
102 | end | ||
103 | |||
104 | if exist('imask') & ~isempty(imask), | ||
105 | if size(imask,1) ~= prod(size(im)) | ||
106 | error(sprintf('imask size %d does not match image dimensions [%d,%d]',... | ||
107 | size(imask,1), size(im,1), size(im,2))); | ||
108 | end | ||
109 | if size(imask,2) == 1, | ||
110 | mask = (cos(-pi/2:2*pi/Ny:pi*(1-2/Ny)/2)).'*cos(-pi/2:2*pi/Nx:pi*(1-2/Nx)/2); | ||
111 | mask = mask.^2; | ||
112 | aux = zeros(size(im)); | ||
113 | aux(Ny/4+1:Ny/4+Ny/2,Nx/4+1:Nx/4+Nx/2)=mask; | ||
114 | mask = aux; | ||
115 | else | ||
116 | mask = reshape(imask(:,1),size(im)); | ||
117 | end | ||
118 | end | ||
119 | |||
120 | imf = max(1,gcf-1); snrf = imf+1; | ||
121 | figure(imf); clf | ||
122 | subplot(1,2,1); grayRange = showIm(im,'auto',1); title('Starting image'); | ||
123 | drawnow | ||
124 | |||
125 | prev_im=im; | ||
126 | |||
127 | imf = max(1,gcf-1); | ||
128 | figure(imf); | ||
129 | clf;showIm(im,'auto',1); title(sprintf('iteration 0')); | ||
130 | |||
131 | nq = 0; | ||
132 | Nq = floor(log2(Niter)); | ||
133 | imS = zeros(Ny,Nx,Nq); | ||
134 | |||
135 | %% MAIN LOOP | ||
136 | for niter = 1:Niter | ||
137 | |||
138 | %p = niter/Niter; | ||
139 | p = 1; | ||
140 | |||
141 | %% Build the steerable pyramid | ||
142 | [pyr,pind] = buildSCFpyr(im,Nsc,Nor-1); | ||
143 | |||
144 | if ( any(vector(mod(pind,4))) ) | ||
145 | error('Algorithm will fail: band dimensions are not all multiples of 4!'); | ||
146 | end | ||
147 | |||
148 | %% Subtract mean of lowBand: | ||
149 | nband = size(pind,1); | ||
150 | pyr(pyrBandIndices(pind,nband)) = ... | ||
151 | pyrBand(pyr,pind,nband) - mean2(pyrBand(pyr,pind,nband)); | ||
152 | |||
153 | apyr = abs(pyr); | ||
154 | |||
155 | %% Adjust autoCorr of lowBand | ||
156 | nband = size(pind,1); | ||
157 | ch = pyrBand(pyr,pind,nband); | ||
158 | Sch = min(size(ch)/2); | ||
159 | nz = sum(sum(~isnan(acr0(:,:,Nsc+1)))); | ||
160 | lz = (sqrt(nz)-1)/2; | ||
161 | le = min(Sch/2-1,lz); | ||
162 | im = real(ch); %Reconstructed image: initialize to lowband | ||
163 | [mpyr,mpind] = buildSFpyr(im,0,0); | ||
164 | im = pyrBand(mpyr,mpind,2); | ||
165 | vari = acr0(la+1:la+1,la+1:la+1,Nsc+1); | ||
166 | if cmask(2), | ||
167 | if vari/var0 > 1e-4, | ||
168 | [im, snr2(niter,Nsc+1)] = ... | ||
169 | modacor22(im, acr0(la-le+1:la+le+1,la-le+1:la+le+1,Nsc+1),p); | ||
170 | else | ||
171 | im = im*sqrt(vari/var2(im)); | ||
172 | end | ||
173 | if (var2(imag(ch))/var2(real(ch)) > 1e-6) | ||
174 | fprintf(1,'Discarding non-trivial imaginary part, lowPass autoCorr!'); | ||
175 | end | ||
176 | im = real(im); | ||
177 | end % cmask(2) | ||
178 | if cmask(1), | ||
179 | if vari/var0 > 1e-4, | ||
180 | [im,snr7(niter,2*(Nsc+1)-1)] = modskew(im,skew0p(Nsc+1),p); % Adjusts skewness | ||
181 | [im,snr7(niter,2*(Nsc+1))] = modkurt(im,kurt0p(Nsc+1),p); % Adjusts kurtosis | ||
182 | end | ||
183 | end % cmask(2) | ||
184 | |||
185 | %% Subtract mean of magnitude | ||
186 | if cmask(3), | ||
187 | magMeans = zeros(size(pind,1), 1); | ||
188 | for nband = 1:size(pind,1) | ||
189 | indices = pyrBandIndices(pind,nband); | ||
190 | magMeans(nband) = mean2(apyr(indices)); | ||
191 | apyr(indices) = apyr(indices) - magMeans(nband); | ||
192 | end | ||
193 | end % cmask(3) | ||
194 | |||
195 | %% Coarse-to-fine loop: | ||
196 | for nsc = Nsc:-1:1 | ||
197 | |||
198 | firstBnum = (nsc-1)*Nor+2; | ||
199 | cousinSz = prod(pind(firstBnum,:)); | ||
200 | ind = pyrBandIndices(pind,firstBnum); | ||
201 | cousinInd = ind(1) + [0:Nor*cousinSz-1]; | ||
202 | |||
203 | %% Interpolate parents | ||
204 | if (cmask(3) | cmask(4)), | ||
205 | if (nsc<Nsc) | ||
206 | parents = zeros(cousinSz,Nor); | ||
207 | rparents = zeros(cousinSz,Nor*2); | ||
208 | for nor = 1:Nor | ||
209 | nband = (nsc+1-1)*Nor+nor+1; | ||
210 | |||
211 | tmp = expand(pyrBand(pyr, pind, nband),2)/4; | ||
212 | rtmp = real(tmp); itmp = imag(tmp); | ||
213 | tmp = sqrt(rtmp.^2 + itmp.^2) .* exp(2 * sqrt(-1) * atan2(rtmp,itmp)); | ||
214 | rparents(:,nor) = vector(real(tmp)); | ||
215 | rparents(:,Nor+nor) = vector(imag(tmp)); | ||
216 | |||
217 | tmp = abs(tmp); | ||
218 | parents(:,nor) = vector(tmp - mean2(tmp)); | ||
219 | end | ||
220 | else | ||
221 | rparents = []; | ||
222 | parents = []; | ||
223 | end | ||
224 | end % if (cmask(3) | cmask(4)) | ||
225 | |||
226 | if cmask(3), | ||
227 | %% Adjust cross-correlation with MAGNITUDES at other orientations/scales: | ||
228 | cousins = reshape(apyr(cousinInd), [cousinSz Nor]); | ||
229 | nc = size(cousins,2); np = size(parents,2); | ||
230 | if (np == 0) | ||
231 | [cousins, snr3(niter,nsc)] = adjustCorr1s(cousins, C0(1:nc,1:nc,nsc), 2, p); | ||
232 | else | ||
233 | [cousins, snr3(niter,nsc), snr4(niter,nsc)] = ... | ||
234 | adjustCorr2s(cousins, C0(1:nc,1:nc,nsc), parents, Cx0(1:nc,1:np,nsc), 3, p); | ||
235 | end | ||
236 | if (var2(imag(cousins))/var2(real(cousins)) > 1e-6) | ||
237 | fprintf(1,'Non-trivial imaginary part, mag crossCorr, lev=%d!\n',nsc); | ||
238 | else | ||
239 | cousins = real(cousins); | ||
240 | ind = cousinInd; | ||
241 | apyr(ind) = vector(cousins); | ||
242 | end | ||
243 | |||
244 | %% Adjust autoCorr of mag responses | ||
245 | nband = (nsc-1)*Nor+2; | ||
246 | Sch = min(pind(nband,:)/2); | ||
247 | nz = sum(sum(~isnan(ace0(:,:,nsc,1)))); | ||
248 | lz = (sqrt(nz)-1)/2; | ||
249 | le = min(Sch/2-1,lz); | ||
250 | for nor = 1:Nor, | ||
251 | nband = (nsc-1)*Nor+nor+1; | ||
252 | ch = pyrBand(apyr,pind,nband); | ||
253 | [ch, snr1(niter,nband-1)] = modacor22(ch,... | ||
254 | ace0(la-le+1:la+le+1,la-le+1:la+le+1,nsc,nor), p); | ||
255 | ch = real(ch); | ||
256 | ind = pyrBandIndices(pind,nband); | ||
257 | apyr(ind) = ch; | ||
258 | %% Impose magnitude: | ||
259 | mag = apyr(ind) + magMeans0(nband); | ||
260 | mag = mag .* (mag>0); | ||
261 | pyr(ind) = pyr(ind) .* (mag./(abs(pyr(ind))+(abs(pyr(ind))<eps))); | ||
262 | end | ||
263 | end % cmask(3) | ||
264 | |||
265 | %% Adjust cross-correlation of REAL PARTS at other orientations/scales: | ||
266 | cousins = reshape(real(pyr(cousinInd)), [cousinSz Nor]); | ||
267 | Nrc = size(cousins,2); Nrp = size(rparents,2); | ||
268 | if cmask(4) & (Nrp ~= 0) | ||
269 | a3 = 0; a4 = 0; | ||
270 | for nrc = 1:Nrc, | ||
271 | cou = cousins(:,nrc); | ||
272 | [cou, s3, s4] = ... | ||
273 | adjustCorr2s(cou,mean(cou.^2),rparents,Crx0(nrc,1:Nrp,nsc), 3); | ||
274 | a3 = s3 + a3; | ||
275 | a4 = s4 + a4; | ||
276 | cousins(:,nrc) = cou; | ||
277 | end | ||
278 | snr4r(niter,nsc) = a4/Nrc; | ||
279 | end | ||
280 | if (var2(imag(cousins))/var2(real(cousins)) > 1e-6) | ||
281 | fprintf(1,'Non-trivial imaginary part, real crossCorr, lev=%d!\n',nsc); | ||
282 | else | ||
283 | %%% NOTE: THIS SETS REAL PART ONLY - signal is now NONANALYTIC! | ||
284 | pyr(cousinInd) = vector(cousins(1:Nor*cousinSz)); | ||
285 | end | ||
286 | |||
287 | %% Re-create analytic subbands | ||
288 | dims = pind(firstBnum,:); | ||
289 | ctr = ceil((dims+0.5)/2); | ||
290 | ang = mkAngle(dims, 0, ctr); | ||
291 | ang(ctr(1),ctr(2)) = -pi/2; | ||
292 | for nor = 1:Nor, | ||
293 | nband = (nsc-1)*Nor+nor+1; | ||
294 | ind = pyrBandIndices(pind,nband); | ||
295 | ch = pyrBand(pyr, pind, nband); | ||
296 | ang0 = pi*(nor-1)/Nor; | ||
297 | xang = mod(ang-ang0+pi, 2*pi) - pi; | ||
298 | amask = 2*(abs(xang) < pi/2) + (abs(xang) == pi/2); | ||
299 | amask(ctr(1),ctr(2)) = 1; | ||
300 | amask(:,1) = 1; | ||
301 | amask(1,:) = 1; | ||
302 | amask = fftshift(amask); | ||
303 | ch = ifft2(amask.*fft2(ch)); % "Analytic" version | ||
304 | pyr(ind) = ch; | ||
305 | end | ||
306 | |||
307 | %% Combine ori bands | ||
308 | bandNums = [1:Nor] + (nsc-1)*Nor+1; %ori bands only | ||
309 | ind1 = pyrBandIndices(pind, bandNums(1)); | ||
310 | indN = pyrBandIndices(pind, bandNums(Nor)); | ||
311 | bandInds = [ind1(1):indN(length(indN))]; | ||
312 | %% Make fake pyramid, containing dummy hi, ori, lo | ||
313 | fakePind = pind([bandNums(1), bandNums, bandNums(Nor)+1],:); | ||
314 | fakePyr = [zeros(prod(fakePind(1,:)),1);... | ||
315 | real(pyr(bandInds)); zeros(prod(fakePind(size(fakePind,1),:)),1)]; | ||
316 | ch = reconSFpyr(fakePyr, fakePind, [1]); % recon ori bands only | ||
317 | im = real(expand(im,2))/4; | ||
318 | im = im + ch; | ||
319 | vari = acr0(la+1:la+1,la+1:la+1,nsc); | ||
320 | if cmask(2), | ||
321 | if vari/var0 > 1e-4, | ||
322 | [im, snr2(niter,nsc)] = ... | ||
323 | modacor22(im, acr0(la-le+1:la+le+1,la-le+1:la+le+1,nsc), p); | ||
324 | else | ||
325 | im = im*sqrt(vari/var2(im)); | ||
326 | end | ||
327 | end % cmask(2) | ||
328 | im = real(im); | ||
329 | |||
330 | if cmask(1), | ||
331 | %% Fix marginal stats | ||
332 | if vari/var0 > 1e-4, | ||
333 | [im,snr7(niter,2*nsc-1)] = modskew(im,skew0p(nsc),p); % Adjusts skewness | ||
334 | [im,snr7(niter,2*nsc)] = modkurt(im,kurt0p(nsc),p); % Adjusts kurtosis | ||
335 | end | ||
336 | end % cmask(1) | ||
337 | |||
338 | end %END Coarse-to-fine loop | ||
339 | |||
340 | %% Adjust variance in HP, if higher than desired | ||
341 | if (cmask(2)|cmask(3)|cmask(4)), | ||
342 | ind = pyrBandIndices(pind,1); | ||
343 | ch = pyr(ind); | ||
344 | vHPR = mean2(ch.^2); | ||
345 | if vHPR > vHPR0, | ||
346 | ch = ch * sqrt(vHPR0/vHPR); | ||
347 | pyr(ind) = ch; | ||
348 | end | ||
349 | end % cmask | ||
350 | im = im + reconSFpyr(real(pyr), pind, [0]); %recon hi only | ||
351 | |||
352 | %% Pixel statistics | ||
353 | means = mean2(im); | ||
354 | vars = var2(im, means); | ||
355 | snr7(niter,2*(Nsc+1)+1) = snr(var0,var0-vars); | ||
356 | im = im-means; % Adjusts mean and variance | ||
357 | [mns mxs] = range2(im + mean0); | ||
358 | snr7(niter,2*(Nsc+1)+2) = snr(mx0-mn0,sqrt((mx0-mxs)^2+(mn0-mns)^2)); | ||
359 | if cmask(1), | ||
360 | im = im*sqrt(((1-p)*vars + p*var0)/vars); | ||
361 | end % cmaks(1) | ||
362 | im = im+mean0; | ||
363 | if cmask(1), | ||
364 | [im, snr7(niter,2*(Nsc+1)+3)] = modskew(im,skew0,p); % Adjusts skewness (keep mean and variance) | ||
365 | [im, snr7(niter,2*(Nsc+1)+4)] = modkurt(im,kurt0,p); % Adjusts kurtosis (keep mean and variance, | ||
366 | % but not skewness) | ||
367 | im = max(min(im,(1-p)*max(max(im))+p*mx0),... | ||
368 | (1-p)*min(min(im))+p*mn0); % Adjusts range (affects everything) | ||
369 | else | ||
370 | snr7(niter,2*(Nsc+1)+3) = snr(skew0,skew0-skew2(im)); | ||
371 | snr7(niter,2*(Nsc+1)+4) = snr(kurt0,kurt0-kurt2(im)); | ||
372 | end % cmask(1) | ||
373 | |||
374 | %% Force pixels specified by image mask | ||
375 | if (exist('imask') & ~isempty(imask) ) | ||
376 | im = mask.*reshape(imask(:,2 - (size(imask,2)==1)),size(im)) + ... | ||
377 | (1-mask).*im; | ||
378 | end | ||
379 | |||
380 | snr6(niter,1) = snr(im-mean0,im-prev_im); | ||
381 | |||
382 | if floor(log2(niter))==log2(niter), | ||
383 | nq = nq + 1; | ||
384 | imS(:,:,nq) = im; | ||
385 | end | ||
386 | |||
387 | tmp = prev_im; | ||
388 | prev_im=im; | ||
389 | |||
390 | figure(imf); | ||
391 | subplot(1,2,1); | ||
392 | showIm(im-tmp,'auto',1); title('Change'); | ||
393 | subplot(1,2,2); | ||
394 | showIm(im,'auto',1); title(sprintf('iteration %d/%d',niter,Niter)); | ||
395 | drawnow | ||
396 | |||
397 | % accelerator | ||
398 | alpha = 0.8; | ||
399 | im = im + alpha*(im - tmp); | ||
400 | |||
401 | commented = 1; % set it to 0 for displaying convergence of parameters in SNR (dB) | ||
402 | if ~commented, | ||
403 | |||
404 | % The graphs that appear reflect | ||
405 | % the relative distance of each parameter or group | ||
406 | % of parametersi, to the original's, in decibels. | ||
407 | % Note, however, that when the original parameters | ||
408 | % are close to zero, this measurement is meaningless. | ||
409 | % This is why in some cases it seems that some of | ||
410 | % the parameters do not converge at all. | ||
411 | |||
412 | figure(snrf); | ||
413 | if cmask(1) | ||
414 | subplot(171); plot(snr7); title('Mrgl stats'); | ||
415 | end | ||
416 | if cmask(2), | ||
417 | subplot(172); plot(snr2); title('Raw auto'); | ||
418 | end | ||
419 | if cmask(3), | ||
420 | subplot(173); plot(snr1); title('Mag auto'); | ||
421 | subplot(174); plot(snr3); title('Mag ori'); | ||
422 | subplot(175); plot(snr4); title('Mag scale'); | ||
423 | end | ||
424 | if (Nrp > 0) & cmask(4), | ||
425 | subplot(176); plot(snr4r); title('Phs scale'); | ||
426 | end | ||
427 | subplot(177); plot(snr6); title('Im change'); | ||
428 | drawnow | ||
429 | |||
430 | end % if ~commented | ||
431 | |||
432 | end %END MAIN LOOP | ||
433 | |||
434 | im = prev_im; | ||
435 | |||
436 | snrP = [snr7 snr2 snr1 snr3 snr4 snr4r snr6]; | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/upBlur.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/upBlur.m deleted file mode 100755 index 948c2e1..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/upBlur.m +++ /dev/null | |||
@@ -1,52 +0,0 @@ | |||
1 | % RES = upBlur(IM, LEVELS, FILT) | ||
2 | % | ||
3 | % Upsample and blur an image. The blurring is done with filter | ||
4 | % kernel specified by FILT (default = 'binom5'), which can be a string | ||
5 | % (to be passed to namedFilter), a vector (applied separably as a 1D | ||
6 | % convolution kernel in X and Y), or a matrix (applied as a 2D | ||
7 | % convolution kernel). The downsampling is always by 2 in each | ||
8 | % direction. | ||
9 | % | ||
10 | % The procedure is applied recursively LEVELS times (default=1). | ||
11 | |||
12 | % Eero Simoncelli, 4/97. | ||
13 | |||
14 | function res = upBlur(im, nlevs, filt) | ||
15 | |||
16 | %------------------------------------------------------------ | ||
17 | %% OPTIONAL ARGS: | ||
18 | |||
19 | if (exist('nlevs') ~= 1) | ||
20 | nlevs = 1; | ||
21 | end | ||
22 | |||
23 | if (exist('filt') ~= 1) | ||
24 | filt = 'binom5'; | ||
25 | end | ||
26 | |||
27 | %------------------------------------------------------------ | ||
28 | |||
29 | if isstr(filt) | ||
30 | filt = namedFilter(filt); | ||
31 | end | ||
32 | |||
33 | if nlevs > 1 | ||
34 | im = upBlur(im,nlevs-1,filt); | ||
35 | end | ||
36 | |||
37 | if (nlevs >= 1) | ||
38 | if (any(size(im)==1)) | ||
39 | if (size(im,1)==1) | ||
40 | filt = filt'; | ||
41 | end | ||
42 | res = upConv(im,filt,'reflect1',(size(im)~=1)+1); | ||
43 | elseif (any(size(filt)==1)) | ||
44 | filt = filt(:); | ||
45 | res = upConv(im,filt,'reflect1',[2 1]); | ||
46 | res = upConv(res,filt','reflect1',[1 2]); | ||
47 | else | ||
48 | res = upConv(im,filt,'reflect1',[2 2]); | ||
49 | end | ||
50 | else | ||
51 | res = im; | ||
52 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/upConv.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/upConv.m deleted file mode 100755 index 10bea46..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/upConv.m +++ /dev/null | |||
@@ -1,80 +0,0 @@ | |||
1 | % RES = upConv(IM, FILT, EDGES, STEP, START, STOP, RES) | ||
2 | % | ||
3 | % Upsample matrix IM, followed by convolution with matrix FILT. These | ||
4 | % arguments should be 1D or 2D matrices, and IM must be larger (in | ||
5 | % both dimensions) than FILT. The origin of filt | ||
6 | % is assumed to be floor(size(filt)/2)+1. | ||
7 | % | ||
8 | % EDGES is a string determining boundary handling: | ||
9 | % 'circular' - Circular convolution | ||
10 | % 'reflect1' - Reflect about the edge pixels | ||
11 | % 'reflect2' - Reflect, doubling the edge pixels | ||
12 | % 'repeat' - Repeat the edge pixels | ||
13 | % 'zero' - Assume values of zero outside image boundary | ||
14 | % 'extend' - Reflect and invert | ||
15 | % 'dont-compute' - Zero output when filter overhangs OUTPUT boundaries | ||
16 | % | ||
17 | % Upsampling factors are determined by STEP (optional, default=[1 1]), | ||
18 | % a 2-vector [y,x]. | ||
19 | % | ||
20 | % The window over which the convolution occurs is specfied by START | ||
21 | % (optional, default=[1,1], and STOP (optional, default = | ||
22 | % step .* (size(IM) + floor((start-1)./step))). | ||
23 | % | ||
24 | % RES is an optional result matrix. The convolution result will be | ||
25 | % destructively added into this matrix. If this argument is passed, the | ||
26 | % result matrix will not be returned. DO NOT USE THIS ARGUMENT IF | ||
27 | % YOU DO NOT UNDERSTAND WHAT THIS MEANS!! | ||
28 | % | ||
29 | % NOTE: this operation corresponds to multiplication of a signal | ||
30 | % vector by a matrix whose columns contain copies of the time-reversed | ||
31 | % (or space-reversed) FILT shifted by multiples of STEP. See corrDn.m | ||
32 | % for the operation corresponding to the transpose of this matrix. | ||
33 | |||
34 | % Eero Simoncelli, 6/96. revised 2/97. | ||
35 | |||
36 | function result = upConv(im,filt,edges,step,start,stop,res) | ||
37 | |||
38 | %% THIS CODE IS NOT ACTUALLY USED! (MEX FILE IS CALLED INSTEAD) | ||
39 | |||
40 | %fprintf(1,'WARNING: You should compile the MEX version of "upConv.c",\n found in the MEX subdirectory of matlabPyrTools, and put it in your matlab path. It is MUCH faster, and provides more boundary-handling options.\n'); | ||
41 | |||
42 | %------------------------------------------------------------ | ||
43 | %% OPTIONAL ARGS: | ||
44 | |||
45 | if (exist('edges') == 1) | ||
46 | if (strcmp(edges,'reflect1') ~= 1) | ||
47 | warning('Using REFLECT1 edge-handling (use MEX code for other options).'); | ||
48 | end | ||
49 | end | ||
50 | |||
51 | if (exist('step') ~= 1) | ||
52 | step = [1,1]; | ||
53 | end | ||
54 | |||
55 | if (exist('start') ~= 1) | ||
56 | start = [1,1]; | ||
57 | end | ||
58 | |||
59 | % A multiple of step | ||
60 | if (exist('stop') ~= 1) | ||
61 | stop = step .* (floor((start-ones(size(start)))./step)+size(im)) | ||
62 | end | ||
63 | |||
64 | if ( ceil((stop(1)+1-start(1)) / step(1)) ~= size(im,1) ) | ||
65 | error('Bad Y result dimension'); | ||
66 | end | ||
67 | if ( ceil((stop(2)+1-start(2)) / step(2)) ~= size(im,2) ) | ||
68 | error('Bad X result dimension'); | ||
69 | end | ||
70 | |||
71 | if (exist('res') ~= 1) | ||
72 | res = zeros(stop-start+1); | ||
73 | end | ||
74 | |||
75 | %------------------------------------------------------------ | ||
76 | |||
77 | tmp = zeros(size(res)); | ||
78 | tmp(start(1):step(1):stop(1),start(2):step(2):stop(2)) = im; | ||
79 | |||
80 | result = rconv2(tmp,filt) + res; | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/var2.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/var2.m deleted file mode 100755 index 6957eff..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/var2.m +++ /dev/null | |||
@@ -1,17 +0,0 @@ | |||
1 | % V = VAR2(MTX,MEAN) | ||
2 | % | ||
3 | % Sample variance of a matrix. | ||
4 | % Passing MEAN (optional) makes the calculation faster. | ||
5 | |||
6 | function res = var2(mtx, mn) | ||
7 | |||
8 | if (exist('mn') ~= 1) | ||
9 | mn = mean2(mtx); | ||
10 | end | ||
11 | |||
12 | if (isreal(mtx)) | ||
13 | res = sum(sum(abs(mtx-mn).^2)) / max((prod(size(mtx)) - 1),1); | ||
14 | else | ||
15 | res = sum(sum(real(mtx-mn).^2)) + i*sum(sum(imag(mtx-mn).^2)); | ||
16 | res = res / max((prod(size(mtx)) - 1),1); | ||
17 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/vectify.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/vectify.m deleted file mode 100755 index 3664223..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/vectify.m +++ /dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | % [VEC] = columnize(MTX) | ||
2 | % | ||
3 | % Pack elements of MTX into a column vector. Just provides a | ||
4 | % function-call notatoin for the operation MTX(:) | ||
5 | |||
6 | function vec = columnize(mtx) | ||
7 | |||
8 | vec = mtx(:); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/vector.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/vector.m deleted file mode 100755 index 6168151..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/vector.m +++ /dev/null | |||
@@ -1,7 +0,0 @@ | |||
1 | % [VEC] = vector(MTX) | ||
2 | % | ||
3 | % Pack elements of MTX into a column vector. Same as VEC = MTX(:) | ||
4 | |||
5 | function vec = vector(mtx) | ||
6 | |||
7 | vec = mtx(:); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/wpyrBand.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/wpyrBand.m deleted file mode 100755 index c027cca..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/wpyrBand.m +++ /dev/null | |||
@@ -1,39 +0,0 @@ | |||
1 | % RES = wpyrBand(PYR, INDICES, LEVEL, BAND) | ||
2 | % | ||
3 | % Access a subband from a separable QMF/wavelet pyramid. | ||
4 | % | ||
5 | % LEVEL (optional, default=1) indicates the scale (finest = 1, | ||
6 | % coarsest = wpyrHt(INDICES)). | ||
7 | % | ||
8 | % BAND (optional, default=1) indicates which subband (1=horizontal, | ||
9 | % 2=vertical, 3=diagonal). | ||
10 | |||
11 | % Eero Simoncelli, 6/96. | ||
12 | |||
13 | function im = wpyrBand(pyr,pind,level,band) | ||
14 | |||
15 | if (exist('level') ~= 1) | ||
16 | level = 1; | ||
17 | end | ||
18 | |||
19 | if (exist('band') ~= 1) | ||
20 | band = 1; | ||
21 | end | ||
22 | |||
23 | if ((pind(1,1) == 1) | (pind(1,2) ==1)) | ||
24 | nbands = 1; | ||
25 | else | ||
26 | nbands = 3; | ||
27 | end | ||
28 | |||
29 | if ((band > nbands) | (band < 1)) | ||
30 | error(sprintf('Bad band number (%d) should be in range [1,%d].', band, nbands)); | ||
31 | end | ||
32 | |||
33 | maxLev = wpyrHt(pind); | ||
34 | if ((level > maxLev) | (level < 1)) | ||
35 | error(sprintf('Bad level number (%d), should be in range [1,%d].', level, maxLev)); | ||
36 | end | ||
37 | |||
38 | band = band + nbands*(level-1); | ||
39 | im = pyrBand(pyr,pind,band); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/wpyrHt.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/wpyrHt.m deleted file mode 100755 index 476be83..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/wpyrHt.m +++ /dev/null | |||
@@ -1,15 +0,0 @@ | |||
1 | % [HEIGHT] = wpyrHt(INDICES) | ||
2 | % | ||
3 | % Compute height of separable QMF/wavelet pyramid with given index matrix. | ||
4 | |||
5 | % Eero Simoncelli, 6/96. | ||
6 | |||
7 | function [ht] = wpyrHt(pind) | ||
8 | |||
9 | if ((pind(1,1) == 1) | (pind(1,2) ==1)) | ||
10 | nbands = 1; | ||
11 | else | ||
12 | nbands = 3; | ||
13 | end | ||
14 | |||
15 | ht = (size(pind,1)-1)/nbands; | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/wpyrLev.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/wpyrLev.m deleted file mode 100755 index 18f30ae..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/wpyrLev.m +++ /dev/null | |||
@@ -1,30 +0,0 @@ | |||
1 | % [LEV,IND] = wpyrLev(PYR,INDICES,LEVEL) | ||
2 | % | ||
3 | % Access a level from a separable QMF/wavelet pyramid. | ||
4 | % Return as an SxB matrix, B = number of bands, S = total size of a band. | ||
5 | % Also returns an Bx2 matrix containing dimensions of the subbands. | ||
6 | |||
7 | % Eero Simoncelli, 6/96. | ||
8 | |||
9 | function [lev,ind] = wpyrLev(pyr,pind,level) | ||
10 | |||
11 | if ((pind(1,1) == 1) | (pind(1,2) ==1)) | ||
12 | nbands = 1; | ||
13 | else | ||
14 | nbands = 3; | ||
15 | end | ||
16 | |||
17 | if ((level > wpyrHt(pind)) | (level < 1)) | ||
18 | error(sprintf('Level number must be in the range [1, %d].', wpyrHt(pind))); | ||
19 | end | ||
20 | |||
21 | firstband = 1 + nbands*(level-1) | ||
22 | firstind = 1; | ||
23 | for l=1:firstband-1 | ||
24 | firstind = firstind + prod(pind(l,:)); | ||
25 | end | ||
26 | |||
27 | |||
28 | ind = pind(firstband:firstband+nbands-1,:); | ||
29 | lev = pyr(firstind:firstind+sum(prod(ind'))-1); | ||
30 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/zconv2.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/zconv2.m deleted file mode 100755 index f678d89..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/zconv2.m +++ /dev/null | |||
@@ -1,41 +0,0 @@ | |||
1 | % RES = ZCONV2(MTX1, MTX2, CTR) | ||
2 | % | ||
3 | % Convolution of two matrices, with boundaries handled as if the larger mtx | ||
4 | % lies in a sea of zeros. Result will be of size of LARGER vector. | ||
5 | % | ||
6 | % The origin of the smaller matrix is assumed to be its center. | ||
7 | % For even dimensions, the origin is determined by the CTR (optional) | ||
8 | % argument: | ||
9 | % CTR origin | ||
10 | % 0 DIM/2 (default) | ||
11 | % 1 (DIM/2)+1 (behaves like conv2(mtx1,mtx2,'same')) | ||
12 | |||
13 | % Eero Simoncelli, 2/97. | ||
14 | |||
15 | function c = zconv2(a,b,ctr) | ||
16 | |||
17 | if (exist('ctr') ~= 1) | ||
18 | ctr = 0; | ||
19 | end | ||
20 | |||
21 | if (( size(a,1) >= size(b,1) ) & ( size(a,2) >= size(b,2) )) | ||
22 | large = a; small = b; | ||
23 | elseif (( size(a,1) <= size(b,1) ) & ( size(a,2) <= size(b,2) )) | ||
24 | large = b; small = a; | ||
25 | else | ||
26 | error('one arg must be larger than the other in both dimensions!'); | ||
27 | end | ||
28 | |||
29 | ly = size(large,1); | ||
30 | lx = size(large,2); | ||
31 | sy = size(small,1); | ||
32 | sx = size(small,2); | ||
33 | |||
34 | %% These values are the index of the small mtx that falls on the | ||
35 | %% border pixel of the large matrix when computing the first | ||
36 | %% convolution response sample: | ||
37 | sy2 = floor((sy+ctr+1)/2); | ||
38 | sx2 = floor((sx+ctr+1)/2); | ||
39 | |||
40 | clarge = conv2(large,small); | ||
41 | c = clarge(sy2:ly+sy2-1, sx2:lx+sx2-1); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/ChangeLog b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/ChangeLog deleted file mode 100755 index f20c499..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/ChangeLog +++ /dev/null | |||
@@ -1,430 +0,0 @@ | |||
1 | Log of changes made to matlabPyrTools code | ||
2 | (important changes marked with **) | ||
3 | ----------------------------------------------------------------------- | ||
4 | 2004-10-14 Eero Simoncelli <eero@sesto.cns.nyu.edu> | ||
5 | |||
6 | * Made new tarfile (version 1.3) | ||
7 | |||
8 | * Incorporated complex-valued steerable pyramid code (buildSCFpyr, | ||
9 | buildSCFpyrLevs,reconSCFpyr) written by Javier Portilla in 9/97, | ||
10 | and used in our work on texture representation/synthesis | ||
11 | (Portilla&Simoncelli, Int'l Journal of Computer Vision, | ||
12 | 40(1):49-71, Dec 2000). | ||
13 | |||
14 | * Incorporated imGradient.m from personal code. | ||
15 | |||
16 | * reagan.pgm out. feynam.pgm in | ||
17 | |||
18 | 2004-03-20 Eero Simoncelli <eero@sesto.cns.nyu.edu> | ||
19 | |||
20 | * blur.m added (just calls blurDn and then upBlur). | ||
21 | |||
22 | 2003-08-06 Eero Simoncelli <eero@sesto.cns.nyu.edu> | ||
23 | |||
24 | * blurDn.m (filt): Forced correct scaling of filters in 1D | ||
25 | |||
26 | 2003-05-28 Eero Simoncelli <eero@ferrando.cns.nyu.edu> | ||
27 | |||
28 | * incorporated setPyrBand.m from local code | ||
29 | |||
30 | 2002-10-01 Eero Simoncelli <eero.simoncelli@nyu.edu> | ||
31 | |||
32 | * incorporated clip.m from local code | ||
33 | |||
34 | 2002-09-18 Eero Simoncelli <eero.simoncelli@nyu.edu> | ||
35 | |||
36 | * pointOp.m: Added the new 'extrap' option for matlab's interp1 to | ||
37 | make this m-file version more compatible with the mex version. | ||
38 | |||
39 | Wed Aug 28 2002 Eero Simoncelli <eero.simoncelli@nyu.edu> | ||
40 | |||
41 | * var2.m: now returns zero (instead of error) for matrix of size 1. | ||
42 | * function VECTORIZE renamed to VECTIFY, since it was colliding | ||
43 | with a function introduced in standard matlab. | ||
44 | |||
45 | Dec 27 2001 Eero Simoncelli <eero.simoncelli@nyu.edu> | ||
46 | |||
47 | * Modified calls to upConv in reconSpyr.m and reconSpyrLevs.m so | ||
48 | that the returned result is bound. Previously, had relied on the | ||
49 | MEX version of upConv to destructively modify the result array, | ||
50 | users had been getting errors because they were using the m-file | ||
51 | version of upConv. | ||
52 | |||
53 | Wed Sep 19 2001 Eero Simoncelli <eero.simoncelli@nyu.edu> | ||
54 | |||
55 | * buildSFpyrLevs/reconSFpyrLevs: replace use of "i" with sqrt(-1), to | ||
56 | avoid problems if user rebinds it! | ||
57 | |||
58 | Wed Mar 28 10:22:01 2001 Eero Simoncelli <eero.simoncelli@nyu.edu> | ||
59 | |||
60 | * Moved innerProd.m and all associated MEX files from the | ||
61 | matlabLocal source tree into matlabPyrTools. | ||
62 | * Added innerProd to Contents.m | ||
63 | * Updated/clarified WARNINGS in all *.m files that have MEX versions. | ||
64 | |||
65 | Tue Mar 27 11:21:53 2001 Eero Simoncelli <eero.simoncelli@nyu.edu> | ||
66 | |||
67 | * Incorporated Windows MEX files (*.dll) into MEX subdirectory. | ||
68 | Windows users should either copy these into the main directory, | ||
69 | or put the MEX subdirectory in their matlab path. | ||
70 | |||
71 | Fri Mar 23 14:46:16 2001 Eero Simoncelli <eero.simoncelli@nyu.edu> | ||
72 | |||
73 | * buildSFpyrLevs.m, reconSFpyrLevs.m: shift the raised-cosine | ||
74 | lookup table (Xrcos) instead of incrementing the log-radial image | ||
75 | (log_rad). THis is more efficient... | ||
76 | |||
77 | Fri Oct 1 19:37:03 1999 Eero Simoncelli <eero.simoncelli@nyu.edu> | ||
78 | |||
79 | * upConv.m: Did not return correct size result when STOP argument | ||
80 | was passed. Thanks to hertzman@mrl.nyu.edu for pointing this out. | ||
81 | |||
82 | Fri Sep 17 15:53:26 1999 Eero Simoncelli <eero.simoncelli@nyu.edu> | ||
83 | |||
84 | * buildSFpyrLevs.m: Changed lutsize to 1024, giving a slight | ||
85 | increase in accuracy. | ||
86 | |||
87 | Thu Feb 25 18:10:38 1999 Eero Simoncelli <eero.simoncelli@nyu.edu> | ||
88 | |||
89 | * histo1.m: Modified histo.m to be more compatible (but still not | ||
90 | exactly the same) as the MEX file version. | ||
91 | |||
92 | Fri Jun 12 21:15:39 1998 Eero Simoncelli <eero.simoncelli@nyu.edu> | ||
93 | |||
94 | * TUTORIALS pyramids.m upgraded. | ||
95 | |||
96 | Tue Feb 17 13:22:28 1998 Eero Simoncelli <eero.simoncelli@nyu.edu> | ||
97 | |||
98 | * showIm.m: Dims are now printed followed by the zoom factor. | ||
99 | |||
100 | Mon Oct 13 14:49:51 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
101 | |||
102 | * mkSquare.m: Modified to do raised-cosine soft threshold | ||
103 | transitions. | ||
104 | |||
105 | Tue Oct 7 10:13:51 1997 Eero Simoncelli <eero@chrysothemis.cims.nyu.edu> | ||
106 | |||
107 | * upConv.m: Argument order was wrong (this function is not used | ||
108 | anyway, unless you don't compile the MEX code). - Thanks to | ||
109 | farid@psyche.mit.edu for pointing this out. | ||
110 | |||
111 | Thu Sep 25 16:09:49 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
112 | |||
113 | * MEX/wrap.c: Changed #include <malloc.h> to <stdlib.h>, as | ||
114 | suggested by David Brainard. * Incorporated Mac-compiled mex | ||
115 | files, courtesy of David Brainard. | ||
116 | |||
117 | Sat Sep 6 16:10:25 1997 Eero Simoncelli <eero@chrysothemis.cims.nyu.edu> | ||
118 | |||
119 | * MEX/convolve.h: abstracted out type of images with typedef image_type. | ||
120 | Added ansi declarations. | ||
121 | |||
122 | Fri Aug 29 13:49:16 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
123 | |||
124 | ** showIm.m: Modified to behave better under resizing (and printing): | ||
125 | resets axis units to "normalized". | ||
126 | |||
127 | Thu Aug 28 22:56:52 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
128 | |||
129 | ** MEX/edges.c: reflect1, reflect2, repeat, extend upgraded to work | ||
130 | properly for non-symmetric filters. reflect2 and extend were also | ||
131 | broken for upConv. Added qreflect2 to handle even-length QMF's | ||
132 | which broke under the reflect2 modification. | ||
133 | * Added example code to TUTORIALS/matlabPyrTools to illustrate the | ||
134 | boundary-handling behavior... | ||
135 | |||
136 | Thu Aug 21 13:34:17 1997 Eero Simoncelli <eero@chrysothemis.cims.nyu.edu> | ||
137 | |||
138 | * var2, skew2, kurt2: modified to return complex values for complex images. | ||
139 | * imStats.m: now gives an error for complex args. | ||
140 | |||
141 | Thu Aug 14 15:24:29 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
142 | |||
143 | * Modified shift.m: negated the meaning of the offset parameter, | ||
144 | such that RES=shift(MTX,OFFSET) means RES(POS)=MTX(POS-OFFSET) | ||
145 | (this is more intuitive). | ||
146 | |||
147 | Thu Jul 10 17:06:52 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
148 | |||
149 | * Modified MEX/Makefile-* to be consistent with matlab5: | ||
150 | - call mex instead of cmex | ||
151 | - use -V4 flag (creating matlab v4 compatible binaries) | ||
152 | |||
153 | * showIm.m (xlbl_offset): Modified to use "points" units, so that | ||
154 | printed images look correct. Still slightly busted for arbitrary figure | ||
155 | window sizes and for printing. | ||
156 | |||
157 | * Modified upConv.c: does not return ANYTHING if you pass a result | ||
158 | argument (this had been causing occasional problems with matlab's | ||
159 | memory manager). | ||
160 | |||
161 | Mon Jun 30 12:09:30 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
162 | |||
163 | * reconSFpyr.m (res): now returns real part (oops). | ||
164 | |||
165 | * reconSpyrLevs.m (maxLev): got rid of superfluous nbands argument | ||
166 | (can be calculated from bfilts). | ||
167 | |||
168 | Mon May 26 12:29:54 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
169 | |||
170 | * showIm.m/pgmWrite.m: Modified 'auto3'-scaling to use a | ||
171 | histogram. This gives a significant speedup. | ||
172 | |||
173 | * fixed a few minor bugs in the TUTORIALS, having to do with | ||
174 | matching image sizes to the machine speed... | ||
175 | |||
176 | Sat May 10 17:27:25 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
177 | |||
178 | * pgmWrite.m: fixed auto-scaling bug. Added new scaling | ||
179 | calculations, parallel to those of imShow. | ||
180 | |||
181 | Fri May 9 09:02:56 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
182 | |||
183 | * buildSFpyr.m: Changed NBANDS argument to be ORDER, which is one | ||
184 | less than the number of orientation bands. This is consistent | ||
185 | with the derivative order, and the labels on the spNFilters files. | ||
186 | |||
187 | Tue May 6 19:08:18 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
188 | |||
189 | ** Added buildSFpyr, reconSFpyr: Steerable pyramids constructed | ||
190 | in the Fourier domain. Radial functions tile, with a | ||
191 | raised-cosine falloff. Angular functions are | ||
192 | cos(theta-k\pi/(K+1))^K, where K is the order (number of bands | ||
193 | minus 1). Compared to the convolution version: | ||
194 | + Reconstruction is exact (within floating point errors) | ||
195 | + Can produce any number of orientation bands. | ||
196 | - Typically slower. | ||
197 | - Boundary-handling must be circular. | ||
198 | Could be made much more efficient by taking advantage of symmetries in | ||
199 | the fft! | ||
200 | |||
201 | * Added example usage of Fourier steerable pyramid to TUTORIALS/pyramids.m | ||
202 | |||
203 | * steer.m: fixed for harmonic lists including zero. | ||
204 | |||
205 | Sun May 4 15:16:10 1997 Eero Simoncelli <eero@ferrando.cns.nyu.edu> | ||
206 | |||
207 | * MEX/Makefile-linux: created. | ||
208 | |||
209 | * spyrHt, spyrNumBands: Modified to return 0 for pyramids of height 0. | ||
210 | |||
211 | * reconWpyr.m: utilize desctructive addition in calls to upConv. | ||
212 | |||
213 | * reconSpyr.m: Added error check to ensure consistancy between | ||
214 | pyramid and filter file. Utilize destructive addition in upConv | ||
215 | call on highpass band. Modified to work properly with pyramids of | ||
216 | height 0. | ||
217 | |||
218 | Mon Apr 28 13:38:10 1997 Eero Simoncelli <eero@ferrando.cns.nyu.edu> | ||
219 | |||
220 | * lplot.m: modified to handle complex vectors, use standard MatLab | ||
221 | indices, and show minimal axes. Added xrange parameter to allow | ||
222 | adjustment of X axis labeling. | ||
223 | |||
224 | Sun Apr 27 20:20:41 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
225 | |||
226 | * var2, skew2, kurt2: enhanced to work on complex matrices. | ||
227 | |||
228 | Sat Apr 26 11:16:12 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
229 | |||
230 | * Changed parent directory (and distribution) name: | ||
231 | matlabImTools -> matlabPyrTools | ||
232 | |||
233 | * namedFilter.m: Added two more Daubechies filters, and modified | ||
234 | names to match the reference (e.g., daub2 is now a 4-tap filter). | ||
235 | |||
236 | * Added vectorize.m: trivial function to pack matrix into vector (i.e., | ||
237 | computes mtx(:)). | ||
238 | |||
239 | * Added upBlur.m: Upsample and blur (parallels blurDn). | ||
240 | |||
241 | Sun Apr 13 14:23:38 1997 Eero Simoncelli <eero@chrysothemis.cims.nyu.edu> | ||
242 | |||
243 | * TUTORIALS/pyramids.m: Added plots of Fourier spectra for Wavelet bases. | ||
244 | |||
245 | * make-tar-file: switched from compress to gzip for the | ||
246 | distribution tarfile. | ||
247 | |||
248 | * namedFilter.m: Added a few even-length QMF's from Johnston80. | ||
249 | |||
250 | Fri Apr 11 19:16:21 1997 Eero Simoncelli <eero@chrysothemis.cims.nyu.edu> | ||
251 | |||
252 | * buildWpyr.m, reconWpyr.m: Modified slightly, so that subsampling | ||
253 | lattice is better for even-length filters. | ||
254 | |||
255 | * TUTORIALS/pyramids.m: Substantially overhauled. | ||
256 | |||
257 | Thu Apr 10 15:20:23 1997 Eero Simoncelli <eero@chrysothemis.cims.nyu.edu> | ||
258 | |||
259 | * blurDn.m: added this function to downsample an image by a factor | ||
260 | 2^L. | ||
261 | |||
262 | * Fixed minor bug in upConv.m: errors in image size checking. | ||
263 | |||
264 | Mon Apr 7 13:25:37 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
265 | |||
266 | * Changed TUTORIALS/matlabImTools.m to use histo.mex instead of | ||
267 | matlab's hist. | ||
268 | |||
269 | Wed Apr 2 13:20:55 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
270 | |||
271 | ** Incorporated Denis Pelli's ThinkC and MetroWorks projects for | ||
272 | Macintosh versions of the MEX code, along with MEX binaries. These | ||
273 | are included as an HQX'ed self-extracting archive | ||
274 | (Macintosh-MEX.sit.hqx), in the MEX subdirectory. | ||
275 | |||
276 | Tue Apr 1 15:35:31 1997 Eero Simoncelli <eero@chrysothemis.cims.nyu.edu> | ||
277 | |||
278 | * edges.c: modified by Denis Pelli to support THINK C. * edges.c: | ||
279 | |||
280 | * histo.c, upConv.c, corrDn.c: minor changes in error message | ||
281 | printouts, to work around bugs in THINK C. | ||
282 | |||
283 | * Included Denis Pelli's MacReadMe file in the MEX subdirectory, | ||
284 | which gives instructions for MEX file compilation on a MacIntosh | ||
285 | (PPC or 68k). | ||
286 | |||
287 | * wrap.c, convolve.c, edges.c: added explicit int function | ||
288 | declarations, and return values. | ||
289 | |||
290 | * range2.m/range2.c: A MEX function for fast min/max computation. | ||
291 | Adjusted entropy2.m, histo.m, imStats.m, pgmWrite.m, showIm.m, | ||
292 | showLpyr.m, showSpyr.m, showWpyr.m to call it. | ||
293 | |||
294 | Thu Mar 27 17:23:05 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
295 | |||
296 | ** histo.m/histo.c: Added MEX function HISTO, a fast replacement | ||
297 | for matlab's HIST function. Modified histoMatch.m, entropy2.m to | ||
298 | call it. | ||
299 | |||
300 | * Changed main directory name to matlabImTools. | ||
301 | |||
302 | * Added TUTORIALS/README file. | ||
303 | |||
304 | Wed Mar 19 14:19:51 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
305 | |||
306 | * Changed directory name: MEX_SRC -> MEX | ||
307 | |||
308 | Wed Mar 12 17:00:03 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
309 | |||
310 | * mkGaussian.m: fixed another (X,Y) bug: both dimensions and | ||
311 | cov/mean are now specified in [y,x] order. | ||
312 | |||
313 | Tue Mar 11 19:08:17 1997 Eero Simoncelli <eero@chrysothemis.cims.nyu.edu> | ||
314 | |||
315 | * showSpyr.m: Fixed a bug that was dropping display of one | ||
316 | orientation band when there were more than 2 of them! | ||
317 | |||
318 | Mon Mar 10 19:08:24 1997 Eero Simoncelli <eero@chrysothemis.cims.nyu.edu> | ||
319 | |||
320 | * Added shift.m | ||
321 | |||
322 | * makeSteerMtx -> steerDir2HarmMtx | ||
323 | |||
324 | * Added TUTORIALS/matlab-EPS.m: examples using the code in this | ||
325 | distribution. | ||
326 | |||
327 | Sun Mar 9 17:49:18 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
328 | |||
329 | ** showIm.m: | ||
330 | - args: changed order so that NSHADES is last. | ||
331 | - TITLES: Can now pass a string for IM, which will be evaluated | ||
332 | in the global environment to get the matrix. The string is | ||
333 | used as a title. MATLAB v.5 ONLY!!! | ||
334 | - Added 'auto3' RANGE value, that scales based on percentiles. | ||
335 | THis is more robust to outliers than 'auto2' or 'auto1'. | ||
336 | |||
337 | * pixelAxes.m: Made a more serious attempt to reverse-engineer | ||
338 | Mathworks' image pixelization. It is improved, but still makes | ||
339 | occasional errors. | ||
340 | |||
341 | * Added skew2.m. | ||
342 | |||
343 | Fri Mar 7 10:11:07 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
344 | |||
345 | * pixelAxes.m: Modified to take an optional | ||
346 | ZOOM argument. Fixed dimension ordering bug | ||
347 | (positions are reported (x,y), but mtx dims are (y,x)!) | ||
348 | |||
349 | * showIm.m: Added an optional ZOOM argument. | ||
350 | |||
351 | Thu Mar 6 14:17:19 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
352 | |||
353 | * Added showLpyr, showWpyr, showSpyr. Modified | ||
354 | TUTORIALS/pyramids.m to use them. | ||
355 | |||
356 | * added pixelAxes.m: Adjusts size (in pixels) of currently | ||
357 | displayed image to be a multiple of the matrix dimensions, | ||
358 | thus eliminating display aliasing artifacts. | ||
359 | This is now called by all the "show" commands. | ||
360 | |||
361 | Mon Mar 3 17:33:25 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
362 | |||
363 | * Fixed bug in pgmWrite (dimensions were written in reverse order). | ||
364 | |||
365 | * Fixed bug in showIm (X and Y coords were swapped on label display). | ||
366 | |||
367 | * Fixed bug in reconLpyr (swapped X and Y coords on int_sz) | ||
368 | |||
369 | * Changed calls to "reshape" to pass dimensions individually -- | ||
370 | older version of matlab do not accept the reshape(mtx,[y x]) form. | ||
371 | |||
372 | * Fixed bug in mkDisc: sz a scalar. | ||
373 | |||
374 | * Added ifftshift.m | ||
375 | |||
376 | Fri Feb 28 11:07:20 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
377 | |||
378 | * Re-worked TUTORIALS/pyramids.m | ||
379 | |||
380 | * buildGpyr and buildLpyr now use 1+maxPyrHt for default height. | ||
381 | |||
382 | * Fixed buildGpyr to work on 1D signals. | ||
383 | |||
384 | ** Gaussian/Laplacian/Wavelet pyramid build and recon functions: | ||
385 | - work properly with new corrDn/upConv. | ||
386 | - use separable convolutions | ||
387 | - use destructive modification ability of upConv (less memory | ||
388 | allocation) | ||
389 | |||
390 | * modulateFlipShift -> modulateFlip. | ||
391 | |||
392 | * added lpyrHt, wpyrHt, spyrHt to return number of levels in a pyramid. | ||
393 | |||
394 | Thu Feb 27 15:39:53 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
395 | |||
396 | * Changed angular coordinate systems to CLOCKWISE in mkRamp, | ||
397 | mkTheta, mkSine, mkSquare. This is unnatural for screen viewing, | ||
398 | but consistent with an origin in the upper left corner of the | ||
399 | image, which is the way one addresses the underlying matrix. | ||
400 | |||
401 | * mkSine and mkSquare can now take a frequency vector or the | ||
402 | period and direction args | ||
403 | |||
404 | Tue Feb 25 11:58:33 1997 Eero Simoncelli <eero@servilia.cns.nyu.edu> | ||
405 | |||
406 | ** Rewrote corrDn/upConv C routines: | ||
407 | - more efficient | ||
408 | - changed START parameters to have [1 1] origin, consistent with | ||
409 | matlab | ||
410 | - added STOP parameters | ||
411 | - upConv allows destructive modification of a result arg | ||
412 | - changed order of other params (sorry) | ||
413 | - wrote test file conv_test.m | ||
414 | * wrote zconv2.m | ||
415 | |||
416 | Wed Aug 19 20:39:15 1996 Eero Simoncelli (eero@tarpon.cis.upenn.edu) | ||
417 | |||
418 | ** Added "pointOp" function (MUCH faster than interp1). | ||
419 | ** Added "histoMatch" function. | ||
420 | |||
421 | Fri Aug 2 00:56:31 1996 Eero Simoncelli (eero@tarpon.cis.upenn.edu) | ||
422 | |||
423 | * Changed all function/file-names to be of the form "fooBar". * | ||
424 | Fixed entropy2.m (busted due to typo). | ||
425 | |||
426 | Original convolution code was written in Spring 1986, and comes from | ||
427 | OBVIUS (Object-Based Vision and Image Understanding System), an | ||
428 | interactive image-processing system written in Common Lisp (with calls | ||
429 | to C code). | ||
430 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/Contents.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/Contents.m deleted file mode 100755 index d19f067..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/Contents.m +++ /dev/null | |||
@@ -1,107 +0,0 @@ | |||
1 | % Image and Multi-scale Pyramid Tools | ||
2 | % Version 1.3, October 2004. | ||
3 | % Created: Early Spring, 1996. Eero Simoncelli, eero.simoncelli@nyu.edu | ||
4 | % | ||
5 | % See README file for brief description. | ||
6 | % See ChangeLog file for latest modifications. | ||
7 | % See TUTORIALS subdirectory for demonstrations. | ||
8 | % Type "help <command-name>" for documentation on individual commands. | ||
9 | % ----------------------------------------------------------------- | ||
10 | % Synthetic Images (matrices): | ||
11 | % mkImpulse - Make an image containing an impulse. | ||
12 | % mkRamp - Make an image containing a ramp function. | ||
13 | % mkR - Make an image containing distance from the origin. | ||
14 | % mkAngle - Make an image containing angle about origin. | ||
15 | % mkDisc - Make an image containing a disk image. | ||
16 | % mkGaussian - Make an image containing a Gaussian function. | ||
17 | % mkZonePlate - Make an image containing a zone plate (cos(r^2)). | ||
18 | % mkAngularSine - Make an image containing an angular sine wave (pinwheel). | ||
19 | % mkSine - Make an image containing a sine grating. | ||
20 | % mkSquare - Make an image containing a square grating. | ||
21 | % mkFract - Make an image containing fractal (1/f) noise. | ||
22 | % | ||
23 | % Point Operations: | ||
24 | % clip - clip values to a range. | ||
25 | % pointOp - Lookup table (much faster than interp1) [MEX file] | ||
26 | % histo - Efficient histogram computation [MEX file] | ||
27 | % histoMatch - Modify matrix elements to match specified histogram stats. | ||
28 | % | ||
29 | % Convolution (first two are significantly faster): | ||
30 | % corrDn - Correlate & downsample with boundary-handling [MEX file] | ||
31 | % upConv - Upsample & convolve with boundary-handling [MEX file] | ||
32 | % blurDn - Blur and subsample a signal/image. | ||
33 | % upBlur - Upsample and blur a signal/image. | ||
34 | % blur - Multi-scale blurring, calls blurDn and then upBlur. | ||
35 | % cconv2 - Circular convolution. | ||
36 | % rconv2 - Convolution with reflected boundaries. | ||
37 | % zconv2 - Convolution assuming zeros beyond image boundaries. | ||
38 | % | ||
39 | % General pyramids: | ||
40 | % pyrLow - Access lowpass subband from (any type of) pyramid | ||
41 | % pyrBand - Access a subband from (any type of) pyramid | ||
42 | % setPyrBand - Insert an image into (any type of) pyramid as a subband | ||
43 | % pyrBandIndices - Returns indices for given band in a pyramid vector | ||
44 | % maxPyrHt - compute maximum number of scales in a pyramid | ||
45 | % | ||
46 | % Gaussian/Laplacian Pyramids: | ||
47 | % buildGpyr - Build a Gaussian pyramid of an input signal/image. | ||
48 | % buildLpyr - Build a Laplacian pyramid of an input signal/image. | ||
49 | % reconLpyr - Reconstruct (invert) the Laplacian pyramid transform. | ||
50 | % | ||
51 | % Separable orthonormal QMF/wavelet Pyramids: | ||
52 | % buildWpyr - Build a separable wavelet representation of an input signal/image. | ||
53 | % reconWpyr - Reconstruct (invert) the wavelet transform. | ||
54 | % wpyrBand - Extract a single band of the wavelet representation. | ||
55 | % wpyrLev - Extract (packed) subbands at a particular level | ||
56 | % wpyrHt - Number of levels (height) of a wavelet pyramid. | ||
57 | % | ||
58 | % Steerable Pyramids: | ||
59 | % buildSpyr - Build a steerable pyramid representation of an input image. | ||
60 | % reconSpyr - Reconstruct (invert) the steerable pyramid transform. | ||
61 | % buildSFpyr - Build a steerable pyramid representation in the Fourier domain. | ||
62 | % reconSFpyr - Reconstruct (invert) the (Fourier domain) steerable pyramid transform. | ||
63 | % spyrBand - Extract a single band from a steerable pyramid. | ||
64 | % spyrHigh - Highpass residual band. | ||
65 | % spyrLev - A whole level (i.e., all images at a given scale) of a steerable pyramid. | ||
66 | % spyrHt - Number of levels (height) of a steerable pyramid. | ||
67 | % spyrNumBands - Number of orientation bands in a steerable pyramid. | ||
68 | % | ||
69 | % Steerable filters / derivatives: | ||
70 | % imGradient - Compute gradient of image using directionally accurete filters. | ||
71 | % steer - Steer filters (or responses). | ||
72 | % steer2HarmMtx - Construct a matrix mapping direcional basis to angular harmonics. | ||
73 | % | ||
74 | % Filters: | ||
75 | % binomialFilter - returns a filter of binomial coefficients. | ||
76 | % namedFilter - some typical Laplacian/Wavelet pyramid filters | ||
77 | % spNFilters - Set of Nth order steerable pyramid filters. | ||
78 | % derivNFiltersS - Matched set of S-tap 1D derivatives, orders 0 to N. | ||
79 | % | ||
80 | % Display: | ||
81 | % showIm - Display a matrix (real or complex) as grayscale image(s). | ||
82 | % Displays dimensions, subsampling, and range of pixel values. | ||
83 | % showLpyr - Display a Laplacian pyramid. | ||
84 | % showWpyr - Display a separable wavelet pyramid. | ||
85 | % showSpyr - Display a steerable pyramid. | ||
86 | % lplot - "lollipop" plot. | ||
87 | % nextFig - Make next figure window current. | ||
88 | % pixelAxes - Make image display use an integer number of pixels | ||
89 | % per sample to avoid resampling artifacts. | ||
90 | % | ||
91 | % Statistics (for 2D Matrices): | ||
92 | % range2 - Min and max of image (matrix) [MEX file] | ||
93 | % mean2 - Sample mean of an image (matrix). | ||
94 | % var2 - Sample variance of an image (matrix). | ||
95 | % skew2 - Sample skew (3rd moment / variance^1.5) of an image (matrix). | ||
96 | % kurt2 - Sample kurtosis (4th moment / variance^2) of an image (matrix). | ||
97 | % entropy2 - Sample entropy of an image (matrix). | ||
98 | % imStats - Report sample statistics of an image, or pair of images. | ||
99 | % | ||
100 | % Miscellaneous: | ||
101 | % pgmRead - Load a "pgm" image into a MatLab matrix [try einstein.pgm,feynman.pgm] | ||
102 | % pgmWrite - Write a MatLab matrix to a "pgm" image file. | ||
103 | % shift - circular shift a 2D matrix by an arbitrary amount. | ||
104 | % vectify - pack matrix into column vector (i.e., function to compute mtx(:)). | ||
105 | % ifftshift - inverse of MatLab's FFTSHIFT (differs for odd-length dimensions) | ||
106 | % rcosFn - return a lookup table of a raised-cosine threshold fn. | ||
107 | % innerProd - Compute M'*M efficiently (i.e., do not copy) [MEX file] | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/-MacReadMe b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/-MacReadMe deleted file mode 100755 index 898dc0c..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/-MacReadMe +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | MacReadMe How to compile a MEX file for Macintosh (Based on a similar note written by David Brainard and Denis Pelli to accompany the Psychophysics Toolbox.) A MEX file (short for "MATLAB extension") contains code that implements a new MATLAB function, allowing users to use the full power of the C language and the Macintosh hardware and operating system in implementing a new MATLAB function. This document explains how to produce a MEX file that is "fat" (i.e. will run as native code on both 68K and PowerPC Macs) and is compatible with both MATLAB 4 and 5. 1) To produce a MATLAB MEX file with PowerPC code you must have the Metrowerks CodeWarrior C compiler (version 10 or better, abbreviated as CW below). To produce 68K code we still use the Symantec THINK C compiler (version from Symantec C++ 8 CD-ROM release 5), but we will soon be switching to Metrowerks CodeWarrior. (See note A below.) 2) Place a copy of the MATLAB 4:Extern folder, supplied by Mathworks, on your compiler's search path. We suggest that you name the copy "MEX V4". (See notes B and C, below.) 3) Build any of the MEX files simply by opening its project file and asking your compiler to "Build Code Resource" (in THINK C) or to "Make" it (in CW). For each MEX file, e.g. histo.mex, there are two associated projects, e.g. histo.µ for CW, and histo.¹.4 for THINK C. To build a "fat" MEX, that runs native on both 68K and PowerPC, you should first compile in THINK C, and then in CW. (See note A, below.) Denis Pelli April 2, 1997 Notes A) The Mathworks support only the THINK C compiler to make 68K MEX code for MATLAB version 4 and only the CW compiler to make PPC MEX files for MATLAB 4 and both 68K and PPC for MATLAB 5. This archive includes THINK and CW projects. To build a fat MEX file for MATLAB 4, first "make" the THINK C version (e.g. histo.¹.4), producing a file with a .rsrc extension (e.g. histo.µ.rsrc). This is the 68K MEX file. When you then "make" histo.µ, the CW project incorporates the .rsrc file and generates a "fat" MEX file that will run native (i.e. fast) on both 68K and PowerPC. To make a 68K-only MEX file, simply rename, e.g., histo.µ.rsrc to histo.mex after you make the THINK project, and set the file type and creator to match the other MEX files. THINK C is slow and hard to work with. Symantec hasn't significantly upgraded in it many years. There is an error in the math.h header (version from Symantec C++ 8 CD-ROM release 5). We fix that error by some tricky preprocessor defines and undefines in the THINK C Prefix in each of the THINK projects. B) The easiest way to put a folder on your compilerÕs search path is simply to put the folder in the same folder as the compiler itself. If you want to use both CW and THINK C, then put the folder under CW, make an alias of it, and put the alias in THINK C's "Aliases" folder. C) Happily, MATLAB 5 is capable of running both V4 and V5 MEX files. Thus we are currently distributing sources that compile into V4 MEX files. The resulting MEX files run both under V4 and V5. In the future we will drop support for V4 and THINK C. (See note A above.) \ No newline at end of file | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/.AppleDouble/.Parent b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/.AppleDouble/.Parent deleted file mode 100755 index f242a99..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/.AppleDouble/.Parent +++ /dev/null | |||
Binary files differ | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/.FBCIndex b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/.FBCIndex deleted file mode 100755 index 848736b..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/.FBCIndex +++ /dev/null | |||
Binary files differ | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/.FBCLockFolder/.FBCSemaphoreFile b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/.FBCLockFolder/.FBCSemaphoreFile deleted file mode 100755 index ab2c684..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/.FBCLockFolder/.FBCSemaphoreFile +++ /dev/null | |||
Binary files differ | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/Makefile-linux b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/Makefile-linux deleted file mode 100755 index 726dd31..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/Makefile-linux +++ /dev/null | |||
@@ -1,39 +0,0 @@ | |||
1 | MLAB = /usr/local/matlab5.1 | ||
2 | |||
3 | MXSFX = mexlx | ||
4 | MEX = ${MLAB}/bin/mex | ||
5 | |||
6 | MFLAGS = -V4 | ||
7 | INC = -I ${MLAB}/extern/include | ||
8 | LIB = -L ${MLAB}/extern/lib | ||
9 | |||
10 | CC = gcc -Wall -pedantic | ||
11 | C_OPTIMIZE_SWITCH = -O2 ## For GCC | ||
12 | CFLAGS = ${C_OPTIMIZE_SWITCH} ${INC} ${LIB} | ||
13 | |||
14 | all: corrDn.${MXSFX} upConv.${MXSFX} pointOp.${MXSFX} \ | ||
15 | histo.${MXSFX} range2.${MXSFX} | ||
16 | |||
17 | clean: | ||
18 | /bin/rm *.o | ||
19 | |||
20 | corrDn.${MXSFX}: corrDn.o wrap.o convolve.o edges.o | ||
21 | ${MEX} ${MFLAGS} corrDn.o wrap.o convolve.o edges.o | ||
22 | |||
23 | upConv.${MXSFX}: upConv.o wrap.o convolve.o edges.o | ||
24 | ${MEX} ${MFLAGS} upConv.o wrap.o convolve.o edges.o | ||
25 | |||
26 | pointOp.${MXSFX}: pointOp.o | ||
27 | ${MEX} ${MFLAGS} pointOp.o | ||
28 | |||
29 | histo.${MXSFX}: histo.o | ||
30 | ${MEX} ${MFLAGS} histo.o | ||
31 | |||
32 | range2.${MXSFX}: range2.o | ||
33 | ${MEX} ${MFLAGS} range2.o | ||
34 | |||
35 | convolve.o wrap.o edges.o: convolve.h | ||
36 | |||
37 | %.o : %.c | ||
38 | ${CC} -c ${CFLAGS} $< | ||
39 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/Makefile-ml6-linux b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/Makefile-ml6-linux deleted file mode 100755 index f596ad7..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/Makefile-ml6-linux +++ /dev/null | |||
@@ -1,39 +0,0 @@ | |||
1 | MLAB = /usr/local/matlab6.0 | ||
2 | |||
3 | MXSFX = mexglx | ||
4 | MEX = ${MLAB}/bin/mex | ||
5 | |||
6 | MFLAGS = -V4 | ||
7 | INC = -I ${MLAB}/extern/include | ||
8 | LIB = -L ${MLAB}/extern/lib | ||
9 | |||
10 | CC = gcc -Wall -pedantic | ||
11 | C_OPTIMIZE_SWITCH = -O2 ## For GCC | ||
12 | CFLAGS = ${C_OPTIMIZE_SWITCH} ${INC} ${LIB} | ||
13 | |||
14 | all: corrDn.${MXSFX} upConv.${MXSFX} pointOp.${MXSFX} \ | ||
15 | histo.${MXSFX} range2.${MXSFX} | ||
16 | |||
17 | clean: | ||
18 | /bin/rm *.o | ||
19 | |||
20 | corrDn.${MXSFX}: corrDn.o wrap.o convolve.o edges.o | ||
21 | ${MEX} ${MFLAGS} corrDn.o wrap.o convolve.o edges.o | ||
22 | |||
23 | upConv.${MXSFX}: upConv.o wrap.o convolve.o edges.o | ||
24 | ${MEX} ${MFLAGS} upConv.o wrap.o convolve.o edges.o | ||
25 | |||
26 | pointOp.${MXSFX}: pointOp.o | ||
27 | ${MEX} ${MFLAGS} pointOp.o | ||
28 | |||
29 | histo.${MXSFX}: histo.o | ||
30 | ${MEX} ${MFLAGS} histo.o | ||
31 | |||
32 | range2.${MXSFX}: range2.o | ||
33 | ${MEX} ${MFLAGS} range2.o | ||
34 | |||
35 | convolve.o wrap.o edges.o: convolve.h | ||
36 | |||
37 | %.o : %.c | ||
38 | ${CC} -c ${CFLAGS} $< | ||
39 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/Makefile-osx b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/Makefile-osx deleted file mode 100755 index 352d15b..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/Makefile-osx +++ /dev/null | |||
@@ -1,39 +0,0 @@ | |||
1 | MLAB = /share/wotan/matlab13 | ||
2 | |||
3 | MXSFX = mexosx | ||
4 | MEX = ${MLAB}/bin/mex | ||
5 | |||
6 | MFLAGS = | ||
7 | INC = -I ${MLAB}/extern/include | ||
8 | LIB = -L ${MLAB}/extern/lib | ||
9 | |||
10 | CC = cc -Wall -pedantic -no-cpp-precomp | ||
11 | C_OPTIMIZE_SWITCH = -O2 ## For GCC | ||
12 | CFLAGS = ${C_OPTIMIZE_SWITCH} ${INC} ${LIB} | ||
13 | |||
14 | all: corrDn.${MXSFX} upConv.${MXSFX} pointOp.${MXSFX} \ | ||
15 | histo.${MXSFX} range2.${MXSFX} | ||
16 | |||
17 | clean: | ||
18 | /bin/rm *.o | ||
19 | |||
20 | corrDn.${MXSFX}: corrDn.o wrap.o convolve.o edges.o | ||
21 | ${MEX} ${MFLAGS} corrDn.o wrap.o convolve.o edges.o | ||
22 | |||
23 | upConv.${MXSFX}: upConv.o wrap.o convolve.o edges.o | ||
24 | ${MEX} ${MFLAGS} upConv.o wrap.o convolve.o edges.o | ||
25 | |||
26 | pointOp.${MXSFX}: pointOp.o | ||
27 | ${MEX} ${MFLAGS} pointOp.o | ||
28 | |||
29 | histo.${MXSFX}: histo.o | ||
30 | ${MEX} ${MFLAGS} histo.o | ||
31 | |||
32 | range2.${MXSFX}: range2.o | ||
33 | ${MEX} ${MFLAGS} range2.o | ||
34 | |||
35 | convolve.o wrap.o edges.o: convolve.h | ||
36 | |||
37 | %.o : %.c | ||
38 | ${CC} -c ${CFLAGS} $< | ||
39 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/Makefile-solaris b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/Makefile-solaris deleted file mode 100755 index 2be2bdb..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/Makefile-solaris +++ /dev/null | |||
@@ -1,38 +0,0 @@ | |||
1 | MLAB = /export/home/Solaris2/matlab5.1 | ||
2 | |||
3 | MXSFX = mexsol | ||
4 | MEX = ${MLAB}/bin/mex | ||
5 | |||
6 | MFLAGS = -V4 | ||
7 | INC = -I ${MLAB}/extern/include | ||
8 | LIB = -L ${MLAB}/extern/lib | ||
9 | |||
10 | CC = gcc -Wall -pedantic | ||
11 | C_OPTIMIZE_SWITCH = -O2 ## For GCC | ||
12 | CFLAGS = ${C_OPTIMIZE_SWITCH} ${INC} ${LIB} | ||
13 | |||
14 | all: corrDn.${MXSFX} upConv.${MXSFX} pointOp.${MXSFX} \ | ||
15 | histo.${MXSFX} range2.${MXSFX} | ||
16 | |||
17 | clean: | ||
18 | /bin/rm *.o | ||
19 | |||
20 | corrDn.${MXSFX}: corrDn.o wrap.o convolve.o edges.o | ||
21 | ${MEX} ${MFLAGS} corrDn.o wrap.o convolve.o edges.o | ||
22 | |||
23 | upConv.${MXSFX}: upConv.o wrap.o convolve.o edges.o | ||
24 | ${MEX} ${MFLAGS} upConv.o wrap.o convolve.o edges.o | ||
25 | |||
26 | pointOp.${MXSFX}: pointOp.o | ||
27 | ${MEX} ${MFLAGS} pointOp.o | ||
28 | |||
29 | histo.${MXSFX}: histo.o | ||
30 | ${MEX} ${MFLAGS} histo.o | ||
31 | |||
32 | range2.${MXSFX}: range2.o | ||
33 | ${MEX} ${MFLAGS} range2.o | ||
34 | |||
35 | convolve.o wrap.o edges.o: convolve.h | ||
36 | |||
37 | %.o : %.c | ||
38 | ${CC} -c ${CFLAGS} $< | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/Makefile-sun4 b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/Makefile-sun4 deleted file mode 100755 index 432b181..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/Makefile-sun4 +++ /dev/null | |||
@@ -1,39 +0,0 @@ | |||
1 | MLAB = /home/alberich/matlab4 | ||
2 | |||
3 | MXSFX = mex4 | ||
4 | MEX = ${MLAB}/bin/cmex | ||
5 | |||
6 | MFLAGS = | ||
7 | INC = -I ${MLAB}/extern/include | ||
8 | LIB = -L ${MLAB}/extern/lib/sun4 | ||
9 | |||
10 | CC = gcc | ||
11 | C_OPTIMIZE_SWITCH = -O2 ## For GCC | ||
12 | CFLAGS = ${C_OPTIMIZE_SWITCH} ${INC} ${LIB} | ||
13 | |||
14 | all: corrDn.${MXSFX} upConv.${MXSFX} pointOp.${MXSFX} \ | ||
15 | histo.${MXSFX} range2.${MXSFX} | ||
16 | |||
17 | clean: | ||
18 | /bin/rm *.o | ||
19 | |||
20 | corrDn.${MXSFX}: corrDn.o wrap.o convolve.o edges.o | ||
21 | ${MEX} ${MFLAGS} corrDn.o wrap.o convolve.o edges.o | ||
22 | |||
23 | upConv.${MXSFX}: upConv.o wrap.o convolve.o edges.o | ||
24 | ${MEX} ${MFLAGS} upConv.o wrap.o convolve.o edges.o | ||
25 | |||
26 | pointOp.${MXSFX}: pointOp.o | ||
27 | ${MEX} ${MFLAGS} pointOp.o | ||
28 | |||
29 | histo.${MXSFX}: histo.o | ||
30 | ${MEX} ${MFLAGS} histo.o | ||
31 | |||
32 | range2.${MXSFX}: range2.o | ||
33 | ${MEX} ${MFLAGS} range2.o | ||
34 | |||
35 | convolve.o wrap.o edges.o: convolve.h | ||
36 | |||
37 | %.o : %.c | ||
38 | ${CC} -c ${CFLAGS} $< | ||
39 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/convolve.c b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/convolve.c deleted file mode 100755 index 60a11a4..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/convolve.c +++ /dev/null | |||
@@ -1,325 +0,0 @@ | |||
1 | /* | ||
2 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
3 | ;;; File: convolve.c | ||
4 | ;;; Author: Eero Simoncelli | ||
5 | ;;; Description: General convolution code for 2D images | ||
6 | ;;; Creation Date: Spring, 1987. | ||
7 | ;;; MODIFICATIONS: | ||
8 | ;;; 10/89: approximately optimized the choice of register vars on SPARCS. | ||
9 | ;;; 6/96: Switched array types to double float. | ||
10 | ;;; 2/97: made more robust and readable. Added STOP arguments. | ||
11 | ;;; 8/97: Bug: when calling internal_reduce with edges in {reflect1,repeat, | ||
12 | ;;; extend} and an even filter dimension. Solution: embed the filter | ||
13 | ;;; in the upper-left corner of a filter with odd Y and X dimensions. | ||
14 | ;;; ---------------------------------------------------------------- | ||
15 | ;;; Object-Based Vision and Image Understanding System (OBVIUS), | ||
16 | ;;; Copyright 1988, Vision Science Group, Media Laboratory, | ||
17 | ;;; Massachusetts Institute of Technology. | ||
18 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
19 | */ | ||
20 | |||
21 | #include <stdio.h> | ||
22 | #include <math.h> | ||
23 | #include "convolve.h" | ||
24 | |||
25 | /* | ||
26 | -------------------------------------------------------------------- | ||
27 | Correlate FILT with IMAGE, subsampling according to START, STEP, and | ||
28 | STOP parameters, with values placed into RESULT array. RESULT | ||
29 | dimensions should be ceil((stop-start)/step). TEMP should be a | ||
30 | pointer to a temporary double array the size of the filter. | ||
31 | EDGES is a string specifying how to handle boundaries -- see edges.c. | ||
32 | The convolution is done in 9 sections, where the border sections use | ||
33 | specially computed edge-handling filters (see edges.c). The origin | ||
34 | of the filter is assumed to be (floor(x_fdim/2), floor(y_fdim/2)). | ||
35 | ------------------------------------------------------------------------ */ | ||
36 | |||
37 | /* abstract out the inner product computation */ | ||
38 | #define INPROD(XCNR,YCNR) \ | ||
39 | { \ | ||
40 | sum=0.0; \ | ||
41 | for (im_pos=YCNR*x_dim+XCNR, filt_pos=0, x_filt_stop=x_fdim; \ | ||
42 | x_filt_stop<=filt_size; \ | ||
43 | im_pos+=(x_dim-x_fdim), x_filt_stop+=x_fdim) \ | ||
44 | for (; \ | ||
45 | filt_pos<x_filt_stop; \ | ||
46 | filt_pos++, im_pos++) \ | ||
47 | sum+= image[im_pos]*temp[filt_pos]; \ | ||
48 | result[res_pos] = sum; \ | ||
49 | } | ||
50 | |||
51 | int internal_reduce(image, x_dim, y_dim, filt, temp, x_fdim, y_fdim, | ||
52 | x_start, x_step, x_stop, y_start, y_step, y_stop, | ||
53 | result, edges) | ||
54 | register image_type *image, *temp; | ||
55 | register int x_fdim, x_dim; | ||
56 | register image_type *result; | ||
57 | register int x_step, y_step; | ||
58 | int x_start, y_start; | ||
59 | int x_stop, y_stop; | ||
60 | image_type *filt; | ||
61 | int y_dim, y_fdim; | ||
62 | char *edges; | ||
63 | { | ||
64 | register double sum; | ||
65 | register int filt_pos, im_pos, x_filt_stop; | ||
66 | register int x_pos, filt_size = x_fdim*y_fdim; | ||
67 | register int y_pos, res_pos; | ||
68 | register int y_ctr_stop = y_dim - ((y_fdim==1)?0:y_fdim); | ||
69 | register int x_ctr_stop = x_dim - ((x_fdim==1)?0:x_fdim); | ||
70 | register int x_res_dim = (x_stop-x_start+x_step-1)/x_step; | ||
71 | int x_ctr_start = ((x_fdim==1)?0:1); | ||
72 | int y_ctr_start = ((y_fdim==1)?0:1); | ||
73 | int x_fmid = x_fdim/2; | ||
74 | int y_fmid = y_fdim/2; | ||
75 | int base_res_pos; | ||
76 | fptr reflect = edge_function(edges); /* look up edge-handling function */ | ||
77 | |||
78 | if (!reflect) return(-1); | ||
79 | |||
80 | /* shift start/stop coords to filter upper left hand corner */ | ||
81 | x_start -= x_fmid; y_start -= y_fmid; | ||
82 | x_stop -= x_fmid; y_stop -= y_fmid; | ||
83 | |||
84 | if (x_stop < x_ctr_stop) x_ctr_stop = x_stop; | ||
85 | if (y_stop < y_ctr_stop) y_ctr_stop = y_stop; | ||
86 | |||
87 | for (res_pos=0, y_pos=y_start; /* TOP ROWS */ | ||
88 | y_pos<y_ctr_start; | ||
89 | y_pos+=y_step) | ||
90 | { | ||
91 | for (x_pos=x_start; /* TOP-LEFT CORNER */ | ||
92 | x_pos<x_ctr_start; | ||
93 | x_pos+=x_step, res_pos++) | ||
94 | { | ||
95 | (*reflect)(filt,x_fdim,y_fdim,x_pos-1,y_pos-1,temp,REDUCE); | ||
96 | INPROD(0,0) | ||
97 | } | ||
98 | |||
99 | (*reflect)(filt,x_fdim,y_fdim,0,y_pos-1,temp,REDUCE); | ||
100 | for (; /* TOP EDGE */ | ||
101 | x_pos<x_ctr_stop; | ||
102 | x_pos+=x_step, res_pos++) | ||
103 | INPROD(x_pos,0) | ||
104 | |||
105 | for (; /* TOP-RIGHT CORNER */ | ||
106 | x_pos<x_stop; | ||
107 | x_pos+=x_step, res_pos++) | ||
108 | { | ||
109 | (*reflect)(filt,x_fdim,y_fdim,x_pos-x_ctr_stop+1,y_pos-1,temp,REDUCE); | ||
110 | INPROD(x_ctr_stop,0) | ||
111 | } | ||
112 | } /* end TOP ROWS */ | ||
113 | |||
114 | y_ctr_start = y_pos; /* hold location of top */ | ||
115 | for (base_res_pos=res_pos, x_pos=x_start; /* LEFT EDGE */ | ||
116 | x_pos<x_ctr_start; | ||
117 | x_pos+=x_step, base_res_pos++) | ||
118 | { | ||
119 | (*reflect)(filt,x_fdim,y_fdim,x_pos-1,0,temp,REDUCE); | ||
120 | for (y_pos=y_ctr_start, res_pos=base_res_pos; | ||
121 | y_pos<y_ctr_stop; | ||
122 | y_pos+=y_step, res_pos+=x_res_dim) | ||
123 | INPROD(0,y_pos) | ||
124 | } | ||
125 | |||
126 | (*reflect)(filt,x_fdim,y_fdim,0,0,temp,REDUCE); | ||
127 | for (; /* CENTER */ | ||
128 | x_pos<x_ctr_stop; | ||
129 | x_pos+=x_step, base_res_pos++) | ||
130 | for (y_pos=y_ctr_start, res_pos=base_res_pos; | ||
131 | y_pos<y_ctr_stop; | ||
132 | y_pos+=y_step, res_pos+=x_res_dim) | ||
133 | INPROD(x_pos,y_pos) | ||
134 | |||
135 | for (; /* RIGHT EDGE */ | ||
136 | x_pos<x_stop; | ||
137 | x_pos+=x_step, base_res_pos++) | ||
138 | { | ||
139 | (*reflect)(filt,x_fdim,y_fdim,x_pos-x_ctr_stop+1,0,temp,REDUCE); | ||
140 | for (y_pos=y_ctr_start, res_pos=base_res_pos; | ||
141 | y_pos<y_ctr_stop; | ||
142 | y_pos+=y_step, res_pos+=x_res_dim) | ||
143 | INPROD(x_ctr_stop,y_pos) | ||
144 | } | ||
145 | |||
146 | for (res_pos-=(x_res_dim-1); | ||
147 | y_pos<y_stop; /* BOTTOM ROWS */ | ||
148 | y_pos+=y_step) | ||
149 | { | ||
150 | for (x_pos=x_start; /* BOTTOM-LEFT CORNER */ | ||
151 | x_pos<x_ctr_start; | ||
152 | x_pos+=x_step, res_pos++) | ||
153 | { | ||
154 | (*reflect)(filt,x_fdim,y_fdim,x_pos-1,y_pos-y_ctr_stop+1,temp,REDUCE); | ||
155 | INPROD(0,y_ctr_stop) | ||
156 | } | ||
157 | |||
158 | (*reflect)(filt,x_fdim,y_fdim,0,y_pos-y_ctr_stop+1,temp,REDUCE); | ||
159 | for (; /* BOTTOM EDGE */ | ||
160 | x_pos<x_ctr_stop; | ||
161 | x_pos+=x_step, res_pos++) | ||
162 | INPROD(x_pos,y_ctr_stop) | ||
163 | |||
164 | for (; /* BOTTOM-RIGHT CORNER */ | ||
165 | x_pos<x_stop; | ||
166 | x_pos+=x_step, res_pos++) | ||
167 | { | ||
168 | (*reflect)(filt,x_fdim,y_fdim,x_pos-x_ctr_stop+1,y_pos-y_ctr_stop+1,temp,REDUCE); | ||
169 | INPROD(x_ctr_stop,y_ctr_stop) | ||
170 | } | ||
171 | } /* end BOTTOM */ | ||
172 | return(0); | ||
173 | } /* end of internal_reduce */ | ||
174 | |||
175 | |||
176 | /* | ||
177 | -------------------------------------------------------------------- | ||
178 | Upsample IMAGE according to START,STEP, and STOP parameters and then | ||
179 | convolve with FILT, adding values into RESULT array. IMAGE | ||
180 | dimensions should be ceil((stop-start)/step). See | ||
181 | description of internal_reduce (above). | ||
182 | |||
183 | WARNING: this subroutine destructively modifies the RESULT array! | ||
184 | ------------------------------------------------------------------------ */ | ||
185 | |||
186 | /* abstract out the inner product computation */ | ||
187 | #define INPROD2(XCNR,YCNR) \ | ||
188 | { \ | ||
189 | val = image[im_pos]; \ | ||
190 | for (res_pos=YCNR*x_dim+XCNR, filt_pos=0, x_filt_stop=x_fdim; \ | ||
191 | x_filt_stop<=filt_size; \ | ||
192 | res_pos+=(x_dim-x_fdim), x_filt_stop+=x_fdim) \ | ||
193 | for (; \ | ||
194 | filt_pos<x_filt_stop; \ | ||
195 | filt_pos++, res_pos++) \ | ||
196 | result[res_pos] += val*temp[filt_pos]; \ | ||
197 | } | ||
198 | |||
199 | int internal_expand(image,filt,temp,x_fdim,y_fdim, | ||
200 | x_start,x_step,x_stop,y_start,y_step,y_stop, | ||
201 | result,x_dim,y_dim,edges) | ||
202 | register image_type *result, *temp; | ||
203 | register int x_fdim, x_dim; | ||
204 | register int x_step, y_step; | ||
205 | register image_type *image; | ||
206 | int x_start, y_start; | ||
207 | image_type *filt; | ||
208 | int y_fdim, y_dim; | ||
209 | char *edges; | ||
210 | { | ||
211 | register double val; | ||
212 | register int filt_pos, res_pos, x_filt_stop; | ||
213 | register int x_pos, filt_size = x_fdim*y_fdim; | ||
214 | register int y_pos, im_pos; | ||
215 | register int x_ctr_stop = x_dim - ((x_fdim==1)?0:x_fdim); | ||
216 | int y_ctr_stop = (y_dim - ((y_fdim==1)?0:y_fdim)); | ||
217 | int x_ctr_start = ((x_fdim==1)?0:1); | ||
218 | int y_ctr_start = ((y_fdim==1)?0:1); | ||
219 | int x_fmid = x_fdim/2; | ||
220 | int y_fmid = y_fdim/2; | ||
221 | int base_im_pos, x_im_dim = (x_stop-x_start+x_step-1)/x_step; | ||
222 | fptr reflect = edge_function(edges); /* look up edge-handling function */ | ||
223 | |||
224 | if (!reflect) return(-1); | ||
225 | |||
226 | /* shift start/stop coords to filter upper left hand corner */ | ||
227 | x_start -= x_fmid; y_start -= y_fmid; | ||
228 | x_stop -= x_fmid; y_stop -= y_fmid; | ||
229 | |||
230 | if (x_stop < x_ctr_stop) x_ctr_stop = x_stop; | ||
231 | if (y_stop < y_ctr_stop) y_ctr_stop = y_stop; | ||
232 | |||
233 | for (im_pos=0, y_pos=y_start; /* TOP ROWS */ | ||
234 | y_pos<y_ctr_start; | ||
235 | y_pos+=y_step) | ||
236 | { | ||
237 | for (x_pos=x_start; /* TOP-LEFT CORNER */ | ||
238 | x_pos<x_ctr_start; | ||
239 | x_pos+=x_step, im_pos++) | ||
240 | { | ||
241 | (*reflect)(filt,x_fdim,y_fdim,x_pos-1,y_pos-1,temp,EXPAND); | ||
242 | INPROD2(0,0) | ||
243 | } | ||
244 | |||
245 | (*reflect)(filt,x_fdim,y_fdim,0,y_pos-1,temp,EXPAND); | ||
246 | for (; /* TOP EDGE */ | ||
247 | x_pos<x_ctr_stop; | ||
248 | x_pos+=x_step, im_pos++) | ||
249 | INPROD2(x_pos,0) | ||
250 | |||
251 | for (; /* TOP-RIGHT CORNER */ | ||
252 | x_pos<x_stop; | ||
253 | x_pos+=x_step, im_pos++) | ||
254 | { | ||
255 | (*reflect)(filt,x_fdim,y_fdim,x_pos-x_ctr_stop+1,y_pos-1,temp,EXPAND); | ||
256 | INPROD2(x_ctr_stop,0) | ||
257 | } | ||
258 | } /* end TOP ROWS */ | ||
259 | |||
260 | y_ctr_start = y_pos; /* hold location of top */ | ||
261 | for (base_im_pos=im_pos, x_pos=x_start; /* LEFT EDGE */ | ||
262 | x_pos<x_ctr_start; | ||
263 | x_pos+=x_step, base_im_pos++) | ||
264 | { | ||
265 | (*reflect)(filt,x_fdim,y_fdim,x_pos-1,0,temp,EXPAND); | ||
266 | for (y_pos=y_ctr_start, im_pos=base_im_pos; | ||
267 | y_pos<y_ctr_stop; | ||
268 | y_pos+=y_step, im_pos+=x_im_dim) | ||
269 | INPROD2(0,y_pos) | ||
270 | } | ||
271 | |||
272 | (*reflect)(filt,x_fdim,y_fdim,0,0,temp,EXPAND); | ||
273 | for (; /* CENTER */ | ||
274 | x_pos<x_ctr_stop; | ||
275 | x_pos+=x_step, base_im_pos++) | ||
276 | for (y_pos=y_ctr_start, im_pos=base_im_pos; | ||
277 | y_pos<y_ctr_stop; | ||
278 | y_pos+=y_step, im_pos+=x_im_dim) | ||
279 | INPROD2(x_pos,y_pos) | ||
280 | |||
281 | for (; /* RIGHT EDGE */ | ||
282 | x_pos<x_stop; | ||
283 | x_pos+=x_step, base_im_pos++) | ||
284 | { | ||
285 | (*reflect)(filt,x_fdim,y_fdim,x_pos-x_ctr_stop+1,0,temp,EXPAND); | ||
286 | for (y_pos=y_ctr_start, im_pos=base_im_pos; | ||
287 | y_pos<y_ctr_stop; | ||
288 | y_pos+=y_step, im_pos+=x_im_dim) | ||
289 | INPROD2(x_ctr_stop,y_pos) | ||
290 | } | ||
291 | |||
292 | for (im_pos-=(x_im_dim-1); | ||
293 | y_pos<y_stop; /* BOTTOM ROWS */ | ||
294 | y_pos+=y_step) | ||
295 | { | ||
296 | for (x_pos=x_start; /* BOTTOM-LEFT CORNER */ | ||
297 | x_pos<x_ctr_start; | ||
298 | x_pos+=x_step, im_pos++) | ||
299 | { | ||
300 | (*reflect)(filt,x_fdim,y_fdim,x_pos-1,y_pos-y_ctr_stop+1,temp,EXPAND); | ||
301 | INPROD2(0,y_ctr_stop) | ||
302 | } | ||
303 | |||
304 | (*reflect)(filt,x_fdim,y_fdim,0,y_pos-y_ctr_stop+1,temp,EXPAND); | ||
305 | for (; /* BOTTOM EDGE */ | ||
306 | x_pos<x_ctr_stop; | ||
307 | x_pos+=x_step, im_pos++) | ||
308 | INPROD2(x_pos,y_ctr_stop) | ||
309 | |||
310 | for (; /* BOTTOM-RIGHT CORNER */ | ||
311 | x_pos<x_stop; | ||
312 | x_pos+=x_step, im_pos++) | ||
313 | { | ||
314 | (*reflect)(filt,x_fdim,y_fdim,x_pos-x_ctr_stop+1,y_pos-y_ctr_stop+1,temp,EXPAND); | ||
315 | INPROD2(x_ctr_stop,y_ctr_stop) | ||
316 | } | ||
317 | } /* end BOTTOM */ | ||
318 | return(0); | ||
319 | } /* end of internal_expand */ | ||
320 | |||
321 | |||
322 | /* Local Variables: */ | ||
323 | /* buffer-read-only: t */ | ||
324 | /* End: */ | ||
325 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/convolve.h b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/convolve.h deleted file mode 100755 index 48d55f7..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/convolve.h +++ /dev/null | |||
@@ -1,55 +0,0 @@ | |||
1 | /* | ||
2 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
3 | ;;; File: convolve.h | ||
4 | ;;; Author: Simoncelli | ||
5 | ;;; Description: Header file for convolve.c | ||
6 | ;;; Creation Date: | ||
7 | ;;; ---------------------------------------------------------------- | ||
8 | ;;; Object-Based Vision and Image Understanding System (OBVIUS), | ||
9 | ;;; Copyright 1988, Vision Science Group, Media Laboratory, | ||
10 | ;;; Massachusetts Institute of Technology. | ||
11 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
12 | */ | ||
13 | |||
14 | #include <stdio.h> | ||
15 | #include <stdlib.h> | ||
16 | |||
17 | #define ABS(x) (((x)>=0) ? (x) : (-(x))) | ||
18 | #define ROOT2 1.4142135623730951 | ||
19 | #define REDUCE 0 | ||
20 | #define EXPAND 1 | ||
21 | #define IS == | ||
22 | #define ISNT != | ||
23 | #define AND && | ||
24 | #define OR || | ||
25 | |||
26 | typedef int (*fptr)(); | ||
27 | |||
28 | typedef struct | ||
29 | { | ||
30 | char *name; | ||
31 | fptr func; | ||
32 | } EDGE_HANDLER; | ||
33 | |||
34 | typedef double image_type; | ||
35 | |||
36 | fptr edge_function(char *edges); | ||
37 | int internal_reduce(image_type *image, int x_idim, int y_idim, | ||
38 | image_type *filt, image_type *temp, int x_fdim, int y_fdim, | ||
39 | int x_start, int x_step, int x_stop, | ||
40 | int y_start, int y_step, int y_stop, | ||
41 | image_type *result, char *edges); | ||
42 | int internal_expand(image_type *image, | ||
43 | image_type *filt, image_type *temp, int x_fdim, int y_fdim, | ||
44 | int x_start, int x_step, int x_stop, | ||
45 | int y_start, int y_step, int y_stop, | ||
46 | image_type *result, int x_rdim, int y_rdim, char *edges); | ||
47 | int internal_wrap_reduce(image_type *image, int x_idim, int y_idim, | ||
48 | image_type *filt, int x_fdim, int y_fdim, | ||
49 | int x_start, int x_step, int x_stop, | ||
50 | int y_start, int y_step, int y_stop, | ||
51 | image_type *result); | ||
52 | int internal_wrap_expand(image_type *image, image_type *filt, int x_fdim, int y_fdim, | ||
53 | int x_start, int x_step, int x_stop, | ||
54 | int y_start, int y_step, int y_stop, | ||
55 | image_type *result, int x_rdim, int y_rdim); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/corrDn.c b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/corrDn.c deleted file mode 100755 index c74df1f..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/corrDn.c +++ /dev/null | |||
@@ -1,145 +0,0 @@ | |||
1 | /* | ||
2 | RES = corrDn(IM, FILT, EDGES, STEP, START, STOP); | ||
3 | >>> See corrDn.m for documentation <<< | ||
4 | This is a matlab interface to the internal_reduce function. | ||
5 | EPS, 7/96. | ||
6 | */ | ||
7 | |||
8 | #define V4_COMPAT | ||
9 | #include <matrix.h> /* Matlab matrices */ | ||
10 | #include <mex.h> | ||
11 | |||
12 | #include "convolve.h" | ||
13 | |||
14 | #define notDblMtx(it) (!mxIsNumeric(it) || !mxIsDouble(it) || mxIsSparse(it) || mxIsComplex(it)) | ||
15 | |||
16 | void mexFunction(int nlhs, /* Num return vals on lhs */ | ||
17 | mxArray *plhs[], /* Matrices on lhs */ | ||
18 | int nrhs, /* Num args on rhs */ | ||
19 | const mxArray *prhs[] /* Matrices on rhs */ | ||
20 | ) | ||
21 | { | ||
22 | double *image,*filt, *temp, *result; | ||
23 | int x_fdim, y_fdim, x_idim, y_idim; | ||
24 | int x_rdim, y_rdim; | ||
25 | int x_start = 1; | ||
26 | int x_step = 1; | ||
27 | int y_start = 1; | ||
28 | int y_step = 1; | ||
29 | int x_stop, y_stop; | ||
30 | mxArray *arg; | ||
31 | double *mxMat; | ||
32 | char edges[15] = "reflect1"; | ||
33 | |||
34 | if (nrhs<2) mexErrMsgTxt("requres at least 2 args."); | ||
35 | |||
36 | /* ARG 1: IMAGE */ | ||
37 | arg = prhs[0]; | ||
38 | if notDblMtx(arg) mexErrMsgTxt("IMAGE arg must be a non-sparse double float matrix."); | ||
39 | image = mxGetPr(arg); | ||
40 | x_idim = (int) mxGetM(arg); /* X is inner index! */ | ||
41 | y_idim = (int) mxGetN(arg); | ||
42 | |||
43 | /* ARG 2: FILTER */ | ||
44 | arg = prhs[1]; | ||
45 | if notDblMtx(arg) mexErrMsgTxt("FILTER arg must be non-sparse double float matrix."); | ||
46 | filt = mxGetPr(arg); | ||
47 | x_fdim = (int) mxGetM(arg); | ||
48 | y_fdim = (int) mxGetN(arg); | ||
49 | |||
50 | if ((x_fdim > x_idim) || (y_fdim > y_idim)) | ||
51 | { | ||
52 | mexPrintf("Filter: [%d %d], Image: [%d %d]\n",x_fdim,y_fdim,x_idim,y_idim); | ||
53 | mexErrMsgTxt("FILTER dimensions larger than IMAGE dimensions."); | ||
54 | } | ||
55 | |||
56 | /* ARG 3 (optional): EDGES */ | ||
57 | if (nrhs>2) | ||
58 | { | ||
59 | if (!mxIsChar(prhs[2])) | ||
60 | mexErrMsgTxt("EDGES arg must be a string."); | ||
61 | mxGetString(prhs[2],edges,15); | ||
62 | } | ||
63 | |||
64 | /* ARG 4 (optional): STEP */ | ||
65 | if (nrhs>3) | ||
66 | { | ||
67 | arg = prhs[3]; | ||
68 | if notDblMtx(arg) mexErrMsgTxt("STEP arg must be a double float matrix."); | ||
69 | if (mxGetM(arg) * mxGetN(arg) != 2) | ||
70 | mexErrMsgTxt("STEP arg must contain two elements."); | ||
71 | mxMat = mxGetPr(arg); | ||
72 | x_step = (int) mxMat[0]; | ||
73 | y_step = (int) mxMat[1]; | ||
74 | if ((x_step<1) || (y_step<1)) | ||
75 | mexErrMsgTxt("STEP values must be greater than zero."); | ||
76 | } | ||
77 | |||
78 | /* ARG 5 (optional): START */ | ||
79 | if (nrhs>4) | ||
80 | { | ||
81 | arg = prhs[4]; | ||
82 | if notDblMtx(arg) mexErrMsgTxt("START arg must be a double float matrix."); | ||
83 | if (mxGetM(arg) * mxGetN(arg) != 2) | ||
84 | mexErrMsgTxt("START arg must contain two elements."); | ||
85 | mxMat = mxGetPr(arg); | ||
86 | x_start = (int) mxMat[0]; | ||
87 | y_start = (int) mxMat[1]; | ||
88 | if ((x_start<1) || (x_start>x_idim) || | ||
89 | (y_start<1) || (y_start>y_idim)) | ||
90 | mexErrMsgTxt("START values must lie between 1 and the image dimensions."); | ||
91 | } | ||
92 | x_start--; /* convert from Matlab to standard C indexes */ | ||
93 | y_start--; | ||
94 | |||
95 | /* ARG 6 (optional): STOP */ | ||
96 | if (nrhs>5) | ||
97 | { | ||
98 | if notDblMtx(prhs[5]) mexErrMsgTxt("STOP arg must be double float matrix."); | ||
99 | if (mxGetM(prhs[5]) * mxGetN(prhs[5]) != 2) | ||
100 | mexErrMsgTxt("STOP arg must contain two elements."); | ||
101 | mxMat = mxGetPr(prhs[5]); | ||
102 | x_stop = (int) mxMat[0]; | ||
103 | y_stop = (int) mxMat[1]; | ||
104 | if ((x_stop<x_start) || (x_stop>x_idim) || | ||
105 | (y_stop<y_start) || (y_stop>y_idim)) | ||
106 | mexErrMsgTxt("STOP values must lie between START and the image dimensions."); | ||
107 | } | ||
108 | else | ||
109 | { | ||
110 | x_stop = x_idim; | ||
111 | y_stop = y_idim; | ||
112 | } | ||
113 | |||
114 | x_rdim = (x_stop-x_start+x_step-1) / x_step; | ||
115 | y_rdim = (y_stop-y_start+y_step-1) / y_step; | ||
116 | |||
117 | /* mxFreeMatrix(plhs[0]); */ | ||
118 | plhs[0] = (mxArray *) mxCreateDoubleMatrix(x_rdim,y_rdim,mxREAL); | ||
119 | if (plhs[0] == NULL) mexErrMsgTxt("Cannot allocate result matrix"); | ||
120 | result = mxGetPr(plhs[0]); | ||
121 | |||
122 | temp = mxCalloc(x_fdim*y_fdim, sizeof(double)); | ||
123 | if (temp == NULL) | ||
124 | mexErrMsgTxt("Cannot allocate necessary temporary space"); | ||
125 | |||
126 | /* | ||
127 | printf("i(%d, %d), f(%d, %d), r(%d, %d), X(%d, %d, %d), Y(%d, %d, %d), %s\n", | ||
128 | x_idim,y_idim,x_fdim,y_fdim,x_rdim,y_rdim, | ||
129 | x_start,x_step,x_stop,y_start,y_step,y_stop,edges); | ||
130 | */ | ||
131 | |||
132 | if (strcmp(edges,"circular") == 0) | ||
133 | internal_wrap_reduce(image, x_idim, y_idim, filt, x_fdim, y_fdim, | ||
134 | x_start, x_step, x_stop, y_start, y_step, y_stop, | ||
135 | result); | ||
136 | else internal_reduce(image, x_idim, y_idim, filt, temp, x_fdim, y_fdim, | ||
137 | x_start, x_step, x_stop, y_start, y_step, y_stop, | ||
138 | result, edges); | ||
139 | |||
140 | mxFree((char *) temp); | ||
141 | return; | ||
142 | } | ||
143 | |||
144 | |||
145 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/edges-orig.c b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/edges-orig.c deleted file mode 100755 index 1f6a98b..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/edges-orig.c +++ /dev/null | |||
@@ -1,494 +0,0 @@ | |||
1 | /* | ||
2 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
3 | ;;; File: edges.c | ||
4 | ;;; Author: Eero Simoncelli | ||
5 | ;;; Description: Boundary handling routines for use with convolve.c | ||
6 | ;;; Creation Date: Spring 1987. | ||
7 | ;;; MODIFIED, 6/96, to operate on double float arrays. | ||
8 | ;;; MODIFIED by dgp, 4/1/97, to support THINK C. | ||
9 | ;;; ---------------------------------------------------------------- | ||
10 | ;;; Object-Based Vision and Image Understanding System (OBVIUS), | ||
11 | ;;; Copyright 1988, Vision Science Group, Media Laboratory, | ||
12 | ;;; Massachusetts Institute of Technology. | ||
13 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
14 | */ | ||
15 | |||
16 | /* | ||
17 | This file contains functions which determine how edges are to be | ||
18 | handled when performing convolutions of images with linear filters. | ||
19 | Any edge handling function which is local and linear may be defined, | ||
20 | except (unfortunately) constants cannot be added. So to treat the | ||
21 | edges as if the image is surrounded by a gray field, you must paste it | ||
22 | into a gray image, convolve, and crop it out... | ||
23 | The main convolution function is called internal_filter and is defined | ||
24 | in the file convolve.c. The idea is that the convolution function | ||
25 | calls the edge handling function which computes a new filter based on | ||
26 | the old filter and the distance to the edge of the image. For | ||
27 | example, reflection is done by reflecting the filter through the | ||
28 | appropriate axis and summing. Currently defined functions are listed | ||
29 | below. | ||
30 | */ | ||
31 | |||
32 | /* | ||
33 | #define DEBUG | ||
34 | */ | ||
35 | |||
36 | #include <stdio.h> | ||
37 | #include <math.h> | ||
38 | #include <string.h> | ||
39 | #include "convolve.h" | ||
40 | |||
41 | #define sgn(a) ( ((a)>0)?1:(((a)<0)?-1:0) ) | ||
42 | #define clip(a,mn,mx) ( ((a)<(mn))?(mn):(((a)>=(mx))?(mx-1):(a)) ) | ||
43 | |||
44 | int reflect1(), reflect2(), repeat(), zero(), Extend(), nocompute(); | ||
45 | int ereflect(), predict(); | ||
46 | |||
47 | /* Lookup table matching a descriptive string to the edge-handling function */ | ||
48 | #if !THINK_C | ||
49 | static EDGE_HANDLER edge_foos[] = | ||
50 | { | ||
51 | { "dont-compute", nocompute }, /* zero output for filter touching edge */ | ||
52 | { "zero", zero }, /* zero outside of image */ | ||
53 | { "repeat", repeat }, /* repeat edge pixel */ | ||
54 | { "reflect1", reflect1 }, /* reflect about edge pixels */ | ||
55 | { "reflect2", reflect2 }, /* reflect image, including edge pixels */ | ||
56 | { "extend", Extend }, /* extend (reflect & invert) */ | ||
57 | { "predict", predict }, /* predict based on portion covered by filt */ | ||
58 | { "ereflect", ereflect }, /* orthogonal QMF reflection */ | ||
59 | }; | ||
60 | #else | ||
61 | /* | ||
62 | This is really stupid, but THINK C won't allow initialization of static variables in | ||
63 | a code resource with string addresses. So we do it this way. | ||
64 | The 68K code for a MATLAB 4 MEX file can only be created by THINK C. | ||
65 | However, for MATLAB 5, we'll be able to use Metrowerks CodeWarrior for both 68K and PPC, so this | ||
66 | cludge can be dropped when we drop support for MATLAB 4. | ||
67 | Denis Pelli, 4/1/97. | ||
68 | */ | ||
69 | static EDGE_HANDLER edge_foos[8]; | ||
70 | |||
71 | void InitializeTable(EDGE_HANDLER edge_foos[]) | ||
72 | { | ||
73 | static int i=0; | ||
74 | |||
75 | if(i>0) return; | ||
76 | edge_foos[i].name="dont-compute"; | ||
77 | edge_foos[i++].func=nocompute; | ||
78 | edge_foos[i].name="zero"; | ||
79 | edge_foos[i++].func=zero; | ||
80 | edge_foos[i].name="repeat"; | ||
81 | edge_foos[i++].func=repeat; | ||
82 | edge_foos[i].name="reflect1"; | ||
83 | edge_foos[i++].func=reflect1; | ||
84 | edge_foos[i].name="reflect2"; | ||
85 | edge_foos[i++].func=reflect2; | ||
86 | edge_foos[i].name="extend"; | ||
87 | edge_foos[i++].func=Extend; | ||
88 | edge_foos[i].name="predict"; | ||
89 | edge_foos[i++].func=predict; | ||
90 | edge_foos[i].name="ereflect"; | ||
91 | edge_foos[i++].func=ereflect; | ||
92 | } | ||
93 | #endif | ||
94 | |||
95 | /* | ||
96 | Function looks up an edge handler id string in the structure above, and | ||
97 | returns the associated function | ||
98 | */ | ||
99 | fptr edge_function(char *edges) | ||
100 | { | ||
101 | int i; | ||
102 | |||
103 | #if THINK_C | ||
104 | InitializeTable(edge_foos); | ||
105 | #endif | ||
106 | for (i = 0; i<sizeof(edge_foos)/sizeof(EDGE_HANDLER); i++) | ||
107 | if (strcmp(edges,edge_foos[i].name) == 0) | ||
108 | return(edge_foos[i].func); | ||
109 | printf("Error: '%s' is not the name of a valid edge-handler!\n",edges); | ||
110 | for (i=0; i<sizeof(edge_foos)/sizeof(EDGE_HANDLER); i++) | ||
111 | { | ||
112 | if (i==0) printf(" Options are: "); | ||
113 | else printf(", "); | ||
114 | printf("%s",edge_foos[i].name); | ||
115 | } | ||
116 | printf("\n"); | ||
117 | return(0); | ||
118 | } | ||
119 | |||
120 | /* | ||
121 | ---------------- EDGE HANDLER ARGUMENTS ------------------------ | ||
122 | filt - array of filter taps. | ||
123 | x_dim, y_dim - x and y dimensions of filt. | ||
124 | x_pos - position of filter relative to the horizontal image edges. Negative | ||
125 | values indicate left edge, positive indicate right edge. Zero | ||
126 | indicates that the filter is not touching either edge. An absolute | ||
127 | value of 1 indicates that the edge tap of the filter is over the | ||
128 | edge pixel of the image. | ||
129 | y_pos - analogous to x_pos. | ||
130 | result - array where the resulting filter will go. The edge | ||
131 | of this filter will be aligned with the image for application... | ||
132 | f_or_e - equal to one of the two constants EXPAND or FILTER. | ||
133 | -------------------------------------------------------------------- | ||
134 | */ | ||
135 | |||
136 | |||
137 | /* -------------------------------------------------------------------- | ||
138 | nocompute() - Return zero for values where filter hangs over the edge. | ||
139 | */ | ||
140 | |||
141 | int nocompute(filt,x_dim,y_dim,x_pos,y_pos,result,f_or_e) | ||
142 | register double *filt, *result; | ||
143 | register int x_dim; | ||
144 | int y_dim, x_pos, y_pos, f_or_e; | ||
145 | { | ||
146 | register int i; | ||
147 | register int size = x_dim*y_dim; | ||
148 | |||
149 | if ( (x_pos>1) OR (x_pos<-1) OR (y_pos>1) OR (y_pos<-1) ) | ||
150 | for (i=0; i<size; i++) result[i] = 0.0; | ||
151 | else | ||
152 | for (i=0; i<size; i++) result[i] = filt[i]; | ||
153 | return(0); | ||
154 | } | ||
155 | |||
156 | /* -------------------------------------------------------------------- | ||
157 | zero() - Zero outside of image. Discontinuous, but adds zero energy. */ | ||
158 | |||
159 | int zero(filt,x_dim,y_dim,x_pos,y_pos,result,f_or_e) | ||
160 | register double *filt, *result; | ||
161 | register int x_dim; | ||
162 | int y_dim, x_pos, y_pos, f_or_e; | ||
163 | { | ||
164 | register int y_filt,x_filt, y_res,x_res; | ||
165 | int filt_sz = x_dim*y_dim; | ||
166 | int x_start = ((x_pos>0)?(x_pos-1):((x_pos<0)?(x_pos+1):0)); | ||
167 | int y_start = x_dim * ((y_pos>0)?(y_pos-1):((y_pos<0)?(y_pos+1):0)); | ||
168 | int i; | ||
169 | |||
170 | for (i=0; i<filt_sz; i++) result[i] = 0.0; | ||
171 | |||
172 | for (y_filt=0, y_res=y_start; | ||
173 | y_filt<filt_sz; | ||
174 | y_filt+=x_dim, y_res+=x_dim) | ||
175 | if ((y_res >= 0) AND (y_res < filt_sz)) | ||
176 | for (x_filt=y_filt, x_res=x_start; | ||
177 | x_filt<y_filt+x_dim; | ||
178 | x_filt++, x_res++) | ||
179 | if ((x_res >= 0) AND (x_res < x_dim)) | ||
180 | result[y_res+x_res] = filt[x_filt]; | ||
181 | return(0); | ||
182 | } | ||
183 | |||
184 | /* -------------------------------------------------------------------- | ||
185 | repeat() - repeat edge pixel. Continuous, but content is usually | ||
186 | different from image. | ||
187 | */ | ||
188 | |||
189 | int repeat(filt,x_dim,y_dim,x_pos,y_pos,result,f_or_e) | ||
190 | register double *filt, *result; | ||
191 | register int x_dim; | ||
192 | int y_dim, x_pos, y_pos, f_or_e; | ||
193 | { | ||
194 | register int y_filt,x_filt, y_res,x_res; | ||
195 | int filt_sz = x_dim*y_dim; | ||
196 | int x_start = ((x_pos>0)?(x_pos-1):((x_pos<0)?(x_pos+1):0)); | ||
197 | int y_start = x_dim * ((y_pos>0)?(y_pos-1):((y_pos<0)?(y_pos+1):0)); | ||
198 | int i; | ||
199 | |||
200 | for (i=0; i<filt_sz; i++) result[i] = 0.0; | ||
201 | |||
202 | for (y_filt=0, y_res=y_start; | ||
203 | y_filt<filt_sz; | ||
204 | y_filt+=x_dim, y_res+=x_dim) | ||
205 | for (x_filt=y_filt, x_res=x_start; | ||
206 | x_filt<y_filt+x_dim; | ||
207 | x_filt++, x_res++) | ||
208 | result[((y_res>=0)?((y_res<filt_sz)?y_res:(filt_sz-x_dim)):0) | ||
209 | + ((x_res>=0)?((x_res<x_dim)?x_res:(x_dim-1)):0)] | ||
210 | += filt[x_filt]; | ||
211 | return(0); | ||
212 | } | ||
213 | |||
214 | /* -------------------------------------------------------------------- | ||
215 | reflect2() - "Normal" image reflection. The edge pixel is repeated, | ||
216 | then the next pixel, etc. Continuous, attempting to maintain | ||
217 | "similar" content, but discontinuous first derivative. | ||
218 | */ | ||
219 | |||
220 | int reflect2(filt,x_dim,y_dim,x_pos,y_pos,result,f_or_e) | ||
221 | register double *filt, *result; | ||
222 | register int x_dim; | ||
223 | int y_dim, x_pos, y_pos, f_or_e; | ||
224 | { | ||
225 | register int y_filt,x_filt, y_edge,x_edge; | ||
226 | register int x_base = (x_pos>0)?(x_dim-1):0; | ||
227 | register int y_base = (y_pos>0)?(x_dim*(y_dim-1)):0; | ||
228 | int filt_sz = x_dim*y_dim; | ||
229 | int x_edge_dist = (x_pos>0)?(x_pos-x_dim-1):(x_pos+1); | ||
230 | int y_edge_dist = x_dim * ((y_pos>0)?(y_pos-y_dim-1):(y_pos+1)); | ||
231 | int i; | ||
232 | |||
233 | #ifdef DEBUG | ||
234 | printf("(%d,%d) ",y_pos,x_pos); | ||
235 | if (x_pos==0) printf("\n"); | ||
236 | #endif | ||
237 | |||
238 | for (i=0; i<filt_sz; i++) result[i] = 0.0; | ||
239 | |||
240 | for (y_filt=0, y_edge=y_edge_dist; | ||
241 | y_filt<filt_sz; | ||
242 | y_filt+=x_dim, y_edge+=x_dim) | ||
243 | { | ||
244 | if (y_edge IS 0) y_edge+=x_dim; | ||
245 | for (x_filt=y_filt, x_edge=x_edge_dist; | ||
246 | x_filt<y_filt+x_dim; | ||
247 | x_filt++, x_edge++) | ||
248 | { | ||
249 | if (x_edge IS 0) x_edge++; | ||
250 | result[ABS(y_base-ABS(y_edge)+x_dim) + ABS(x_base-ABS(x_edge)+1)] | ||
251 | += filt[x_filt]; | ||
252 | } | ||
253 | } | ||
254 | return(0); | ||
255 | } | ||
256 | |||
257 | /* -------------------------------------------------------------------- | ||
258 | reflect1() - Reflection through the edge pixels. This is the right thing | ||
259 | to do if you are subsampling by 2, since it maintains parity (even | ||
260 | pixels positions remain even, odd ones remain odd). (note: procedure differs | ||
261 | depending on f_or_e parameter). */ | ||
262 | |||
263 | int reflect1(filt,x_dim,y_dim,x_pos,y_pos,result,f_or_e) | ||
264 | register double *filt, *result; | ||
265 | register int x_dim; | ||
266 | int y_dim, x_pos, y_pos, f_or_e; | ||
267 | { | ||
268 | int filt_sz = x_dim*y_dim; | ||
269 | register int x_start = 0, y_start = 0, x_stop = x_dim, y_stop = filt_sz; | ||
270 | register int y_filt,x_filt, y_edge,x_edge; | ||
271 | register int x_base = (x_pos>0)?(x_dim-1):0; | ||
272 | register int y_base = (y_pos>0)?(x_dim*(y_dim-1)):0; | ||
273 | int x_edge_dist = (x_pos>0)?(x_pos-x_dim):((x_pos<0)?(x_pos+1):0); | ||
274 | int y_edge_dist = x_dim * ((y_pos>0)?(y_pos-y_dim):((y_pos<0)?(y_pos+1):0)); | ||
275 | int i; | ||
276 | int mx_pos = (x_dim/2)+1; | ||
277 | int my_pos = (y_dim/2)+1; | ||
278 | |||
279 | #ifdef DEBUG | ||
280 | printf("(%d,%d) ",y_pos,x_pos); | ||
281 | if (x_pos==0) printf("\n"); | ||
282 | #endif | ||
283 | |||
284 | for (i=0; i<filt_sz; i++) result[i] = 0.0; | ||
285 | |||
286 | /* if EXPAND and filter is centered on image edge, do not reflect */ | ||
287 | if (f_or_e IS EXPAND) | ||
288 | { | ||
289 | if (x_pos IS mx_pos) x_stop = (x_dim+1)/2; | ||
290 | else if (x_pos IS -mx_pos) { x_start = x_dim/2; x_edge_dist = 0; } | ||
291 | |||
292 | if (y_pos IS my_pos) y_stop = x_dim*((y_dim+1)/2); | ||
293 | else if (y_pos IS -my_pos) { y_start = x_dim*(y_dim/2); y_edge_dist = 0;} | ||
294 | } | ||
295 | |||
296 | /* reflect at boundary of image */ | ||
297 | for (y_filt=y_start, y_edge=y_edge_dist; | ||
298 | y_filt<y_stop; | ||
299 | y_filt+=x_dim, y_edge+=x_dim) | ||
300 | for (x_filt=y_filt+x_start, x_edge=x_edge_dist; | ||
301 | x_filt<y_filt+x_stop; | ||
302 | x_filt++, x_edge++) | ||
303 | result[ABS(y_base-ABS(y_edge)) + ABS(x_base-ABS(x_edge))] | ||
304 | += filt[x_filt]; | ||
305 | |||
306 | /* if EXPAND and filter is not centered on image edge, mult edge by 2 */ | ||
307 | if (f_or_e IS EXPAND) | ||
308 | { | ||
309 | if ( (ABS(x_pos) ISNT mx_pos) AND (x_pos ISNT 0) ) | ||
310 | for (y_filt=x_base; y_filt<filt_sz; y_filt+=x_dim) | ||
311 | result[y_filt] += result[y_filt]; | ||
312 | if ( (ABS(y_pos) ISNT my_pos) AND (y_pos ISNT 0) ) | ||
313 | for (x_filt=y_base; x_filt<y_base+x_dim; x_filt++) | ||
314 | result[x_filt] += result[x_filt]; | ||
315 | } | ||
316 | return(0); | ||
317 | } | ||
318 | |||
319 | /* -------------------------------------------------------------------- | ||
320 | Extend() - Extend image by reflecting and inverting about edge pixel | ||
321 | value. Maintains continuity in intensity AND first derivative (but | ||
322 | not higher derivs). | ||
323 | */ | ||
324 | |||
325 | int Extend(filt,x_dim,y_dim,x_pos,y_pos,result,f_or_e) | ||
326 | register double *filt, *result; | ||
327 | register int x_dim; | ||
328 | int y_dim, x_pos, y_pos, f_or_e; | ||
329 | { | ||
330 | int filt_sz = x_dim*y_dim; | ||
331 | register int x_start = 0, y_start = 0, x_stop = x_dim, y_stop = filt_sz; | ||
332 | register int y_filt,x_filt, y_edge,x_edge; | ||
333 | register int x_base = (x_pos>0)?(x_dim-1):0; | ||
334 | register int y_base = (y_pos>0)?(x_dim*(y_dim-1)):0; | ||
335 | int x_edge_dist = (x_pos>0)?(x_pos-x_dim):((x_pos<-1)?(x_pos+1):0); | ||
336 | int y_edge_dist = x_dim * ((y_pos>0)?(y_pos-y_dim):((y_pos<-1)?(y_pos+1):0)); | ||
337 | int i; | ||
338 | int mx_pos = (x_dim/2)+1; | ||
339 | int my_pos = (y_dim/2)+1; | ||
340 | |||
341 | for (i=0; i<filt_sz; i++) result[i] = 0.0; | ||
342 | |||
343 | /* if EXPAND and filter is centered on image edge, do not reflect */ | ||
344 | if (f_or_e IS EXPAND) | ||
345 | { | ||
346 | if (x_pos IS mx_pos) x_stop = (x_dim+1)/2; | ||
347 | else if (x_pos IS -mx_pos) { x_start = x_dim/2; x_edge_dist = 0; } | ||
348 | |||
349 | if (y_pos IS my_pos) y_stop = x_dim*((y_dim+1)/2); | ||
350 | else if (y_pos IS -my_pos) { y_start = x_dim*(y_dim/2); y_edge_dist = 0;} | ||
351 | } | ||
352 | |||
353 | /* reflect at boundary of image */ | ||
354 | for (y_filt=y_start, y_edge=y_edge_dist; | ||
355 | y_filt<y_stop; | ||
356 | y_filt+=x_dim, y_edge+=x_dim) | ||
357 | for (x_filt=y_filt+x_start, x_edge=x_edge_dist; | ||
358 | x_filt<y_filt+x_stop; | ||
359 | x_filt++, x_edge++) | ||
360 | if (((!y_base AND (sgn(y_edge) IS -1)) /* y overhanging */ | ||
361 | OR | ||
362 | (y_base AND (sgn(y_edge) IS 1))) | ||
363 | ISNT /* XOR */ | ||
364 | ((!x_base AND (sgn(x_edge) IS -1)) /* x overhanging */ | ||
365 | OR | ||
366 | (x_base AND (sgn(x_edge) IS 1)))) | ||
367 | { | ||
368 | result[ABS(y_base-ABS(y_edge)) + ABS(x_base-ABS(x_edge))] | ||
369 | -= filt[x_filt]; | ||
370 | result[clip(y_base+y_edge,0,y_dim) + clip(x_base+x_edge,0,x_dim)] | ||
371 | += filt[x_filt] + filt[x_filt]; | ||
372 | } | ||
373 | else result[ABS(y_base-ABS(y_edge)) + ABS(x_base-ABS(x_edge))] | ||
374 | += filt[x_filt]; | ||
375 | return(0); | ||
376 | } | ||
377 | |||
378 | /* -------------------------------------------------------------------- | ||
379 | predict() - Simple prediction. Like zero, but multiplies the result | ||
380 | by the reciprocal of the percentage of filter being used. (i.e. if | ||
381 | 50% of the filter is hanging over the edge of the image, multiply the | ||
382 | taps being used by 2). */ | ||
383 | |||
384 | int predict(filt,x_dim,y_dim,x_pos,y_pos,result,f_or_e) | ||
385 | register double *filt, *result; | ||
386 | register int x_dim; | ||
387 | int y_dim, x_pos, y_pos, f_or_e; | ||
388 | { | ||
389 | register int y_filt,x_filt, y_res,x_res; | ||
390 | register double taps_used = 0.0; /* int *** */ | ||
391 | register double fraction = 0.0; | ||
392 | int filt_sz = x_dim*y_dim; | ||
393 | int x_start = ((x_pos>0)?(x_pos-1):((x_pos<0)?(x_pos+1):0)); | ||
394 | int y_start = x_dim * ((y_pos>0)?(y_pos-1):((y_pos<0)?(y_pos+1):0)); | ||
395 | int i; | ||
396 | |||
397 | for (i=0; i<filt_sz; i++) result[i] = 0.0; | ||
398 | |||
399 | for (y_filt=0, y_res=y_start; | ||
400 | y_filt<filt_sz; | ||
401 | y_filt+=x_dim, y_res+=x_dim) | ||
402 | if ((y_res >= 0) AND (y_res < filt_sz)) | ||
403 | for (x_filt=y_filt, x_res=x_start; | ||
404 | x_filt<y_filt+x_dim; | ||
405 | x_filt++, x_res++) | ||
406 | if ((x_res >= 0) AND (x_res < x_dim)) | ||
407 | { | ||
408 | result[y_res+x_res] = filt[x_filt]; | ||
409 | taps_used += ABS(filt[x_filt]); | ||
410 | } | ||
411 | printf("TU: %f\n",taps_used); | ||
412 | if (f_or_e IS FILTER) | ||
413 | { | ||
414 | /* fraction = ( (double) filt_sz ) / ( (double) taps_used ); */ | ||
415 | for (i=0; i<filt_sz; i++) fraction += ABS(filt[i]); | ||
416 | fraction = ( fraction / taps_used ); | ||
417 | for (i=0; i<filt_sz; i++) result[i] *= fraction; | ||
418 | } | ||
419 | return(0); | ||
420 | } | ||
421 | |||
422 | |||
423 | /* -------------------------------------------------------------------- | ||
424 | Reflect, multiplying tap of filter which is at the edge of the image | ||
425 | by root 2. This maintains orthogonality of odd-length linear-phase | ||
426 | QMF filters, but it is not useful for most applications, since it | ||
427 | alters the DC level. */ | ||
428 | |||
429 | int ereflect(filt,x_dim,y_dim,x_pos,y_pos,result,f_or_e) | ||
430 | register double *filt, *result; | ||
431 | register int x_dim; | ||
432 | int y_dim, x_pos, y_pos, f_or_e; | ||
433 | { | ||
434 | register int y_filt,x_filt, y_edge,x_edge; | ||
435 | register int x_base = (x_pos>0)?(x_dim-1):0; | ||
436 | register int y_base = x_dim * ( (y_pos>0)?(y_dim-1):0 ); | ||
437 | int filt_sz = x_dim*y_dim; | ||
438 | int x_edge_dist = (x_pos>1)?(x_pos-x_dim):((x_pos<-1)?(x_pos+1):0); | ||
439 | int y_edge_dist = x_dim * ( (y_pos>1)?(y_pos-y_dim):((y_pos<-1)?(y_pos+1):0) ); | ||
440 | int i; | ||
441 | double norm,onorm; | ||
442 | |||
443 | for (i=0; i<filt_sz; i++) result[i] = 0.0; | ||
444 | |||
445 | /* reflect at boundary */ | ||
446 | for (y_filt=0, y_edge=y_edge_dist; | ||
447 | y_filt<filt_sz; | ||
448 | y_filt+=x_dim, y_edge+=x_dim) | ||
449 | for (x_filt=y_filt, x_edge=x_edge_dist; | ||
450 | x_filt<y_filt+x_dim; | ||
451 | x_filt++, x_edge++) | ||
452 | result[ABS(y_base-ABS(y_edge)) + ABS(x_base-ABS(x_edge))] | ||
453 | += filt[x_filt]; | ||
454 | |||
455 | /* now multiply edge by root 2 */ | ||
456 | if (x_pos ISNT 0) | ||
457 | for (y_filt=x_base; y_filt<filt_sz; y_filt+=x_dim) | ||
458 | result[y_filt] *= ROOT2; | ||
459 | if (y_pos ISNT 0) | ||
460 | for (x_filt=y_base; x_filt<y_base+x_dim; x_filt++) | ||
461 | result[x_filt] *= ROOT2; | ||
462 | |||
463 | /* now normalize to norm of original filter */ | ||
464 | for (norm=0.0,i=0; i<filt_sz; i++) | ||
465 | norm += (result[i]*result[i]); | ||
466 | norm=sqrt(norm); | ||
467 | |||
468 | for (onorm=0.0,i=0; i<filt_sz; i++) | ||
469 | onorm += (filt[i]*filt[i]); | ||
470 | onorm = sqrt(onorm); | ||
471 | |||
472 | norm = norm/onorm; | ||
473 | for (i=0; i<filt_sz; i++) | ||
474 | result[i] /= norm; | ||
475 | return(0); | ||
476 | } | ||
477 | |||
478 | |||
479 | /* ------- printout stuff for testing ------------------------------ | ||
480 | printf("Xpos: %d, Ypos: %d", x_pos, y_pos); | ||
481 | for (y_filt=0; y_filt<y_dim; y_filt++) | ||
482 | { | ||
483 | printf("\n"); | ||
484 | for (x_filt=0; x_filt<x_dim; x_filt++) | ||
485 | printf("%6.1f", result[y_filt*x_dim+x_filt]); | ||
486 | } | ||
487 | printf("\n"); | ||
488 | */ | ||
489 | |||
490 | |||
491 | |||
492 | /* Local Variables: */ | ||
493 | /* buffer-read-only: t */ | ||
494 | /* End: */ | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/edges.c b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/edges.c deleted file mode 100755 index 98b377d..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/edges.c +++ /dev/null | |||
@@ -1,647 +0,0 @@ | |||
1 | /* | ||
2 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
3 | ;;; File: edges.c | ||
4 | ;;; Author: Eero Simoncelli | ||
5 | ;;; Description: Boundary handling routines for use with convolve.c | ||
6 | ;;; Creation Date: Spring 1987. | ||
7 | ;;; MODIFIED, 6/96, to operate on double float arrays. | ||
8 | ;;; MODIFIED by dgp, 4/1/97, to support THINK C. | ||
9 | ;;; MODIFIED, 8/97: reflect1, reflect2, repeat, extend upgraded to | ||
10 | ;;; work properly for non-symmetric filters. Added qreflect2 to handle | ||
11 | ;;; even-length QMF's which broke under the reflect2 modification. | ||
12 | ;;; ---------------------------------------------------------------- | ||
13 | ;;; Object-Based Vision and Image Understanding System (OBVIUS), | ||
14 | ;;; Copyright 1988, Vision Science Group, Media Laboratory, | ||
15 | ;;; Massachusetts Institute of Technology. | ||
16 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
17 | */ | ||
18 | |||
19 | /* This file contains functions which determine how edges are to be | ||
20 | handled when performing convolutions of images with linear filters. | ||
21 | Any edge handling function which is local and linear may be defined, | ||
22 | except (unfortunately) constants cannot be added. So to treat the | ||
23 | edges as if the image is surrounded by a gray field, you must paste it | ||
24 | into a gray image, convolve, and crop it out... The main convolution | ||
25 | functions are called internal_reduce and internal_expand and are | ||
26 | defined in the file convolve.c. The idea is that the convolution | ||
27 | function calls the edge handling function which computes a new filter | ||
28 | based on the old filter and the distance to the edge of the image. | ||
29 | For example, reflection is done by reflecting the filter through the | ||
30 | appropriate axis and summing. Currently defined functions are listed | ||
31 | below. | ||
32 | */ | ||
33 | |||
34 | |||
35 | #include <stdio.h> | ||
36 | #include <math.h> | ||
37 | #include <string.h> | ||
38 | #include "convolve.h" | ||
39 | |||
40 | #define sgn(a) ( ((a)>0)?1:(((a)<0)?-1:0) ) | ||
41 | #define clip(a,mn,mx) ( ((a)<(mn))?(mn):(((a)>=(mx))?(mx-1):(a)) ) | ||
42 | |||
43 | int reflect1(), reflect2(), qreflect2(), repeat(), zero(), Extend(), nocompute(); | ||
44 | int ereflect(), predict(); | ||
45 | |||
46 | /* Lookup table matching a descriptive string to the edge-handling function */ | ||
47 | #if !THINK_C | ||
48 | static EDGE_HANDLER edge_foos[] = | ||
49 | { | ||
50 | { "dont-compute", nocompute }, /* zero output for filter touching edge */ | ||
51 | { "zero", zero }, /* zero outside of image */ | ||
52 | { "repeat", repeat }, /* repeat edge pixel */ | ||
53 | { "reflect1", reflect1 }, /* reflect about edge pixels */ | ||
54 | { "reflect2", reflect2 }, /* reflect image, including edge pixels */ | ||
55 | { "qreflect2", qreflect2 }, /* reflect image, including edge pixels | ||
56 | for even-length QMF decompositions */ | ||
57 | { "extend", Extend }, /* extend (reflect & invert) */ | ||
58 | { "ereflect", ereflect }, /* orthogonal QMF reflection */ | ||
59 | }; | ||
60 | #else | ||
61 | /* | ||
62 | This is really stupid, but THINK C won't allow initialization of static variables in | ||
63 | a code resource with string addresses. So we do it this way. | ||
64 | The 68K code for a MATLAB 4 MEX file can only be created by THINK C. | ||
65 | However, for MATLAB 5, we'll be able to use Metrowerks CodeWarrior for both 68K and PPC, so this | ||
66 | cludge can be dropped when we drop support for MATLAB 4. | ||
67 | Denis Pelli, 4/1/97. | ||
68 | */ | ||
69 | static EDGE_HANDLER edge_foos[8]; | ||
70 | |||
71 | void InitializeTable(EDGE_HANDLER edge_foos[]) | ||
72 | { | ||
73 | static int i=0; | ||
74 | |||
75 | if(i>0) return; | ||
76 | edge_foos[i].name="dont-compute"; | ||
77 | edge_foos[i++].func=nocompute; | ||
78 | edge_foos[i].name="zero"; | ||
79 | edge_foos[i++].func=zero; | ||
80 | edge_foos[i].name="repeat"; | ||
81 | edge_foos[i++].func=repeat; | ||
82 | edge_foos[i].name="reflect1"; | ||
83 | edge_foos[i++].func=reflect1; | ||
84 | edge_foos[i].name="reflect2"; | ||
85 | edge_foos[i++].func=reflect2; | ||
86 | edge_foos[i].name="qreflect2"; | ||
87 | edge_foos[i++].func=qreflect2; | ||
88 | edge_foos[i].name="extend"; | ||
89 | edge_foos[i++].func=Extend; | ||
90 | edge_foos[i].name="ereflect"; | ||
91 | edge_foos[i++].func=ereflect; | ||
92 | } | ||
93 | #endif | ||
94 | |||
95 | /* | ||
96 | Function looks up an edge handler id string in the structure above, and | ||
97 | returns the associated function | ||
98 | */ | ||
99 | fptr edge_function(char *edges) | ||
100 | { | ||
101 | int i; | ||
102 | |||
103 | #if THINK_C | ||
104 | InitializeTable(edge_foos); | ||
105 | #endif | ||
106 | for (i = 0; i<sizeof(edge_foos)/sizeof(EDGE_HANDLER); i++) | ||
107 | if (strcmp(edges,edge_foos[i].name) IS 0) | ||
108 | return(edge_foos[i].func); | ||
109 | printf("Error: '%s' is not the name of a valid edge-handler!\n",edges); | ||
110 | for (i=0; i<sizeof(edge_foos)/sizeof(EDGE_HANDLER); i++) | ||
111 | { | ||
112 | if (i IS 0) printf(" Options are: "); | ||
113 | else printf(", "); | ||
114 | printf("%s",edge_foos[i].name); | ||
115 | } | ||
116 | printf("\n"); | ||
117 | return(0); | ||
118 | } | ||
119 | |||
120 | /* | ||
121 | ---------------- EDGE HANDLER ARGUMENTS ------------------------ | ||
122 | filt - array of filter taps. | ||
123 | x_dim, y_dim - x and y dimensions of filt. | ||
124 | x_pos - position of filter relative to the horizontal image edges. Negative | ||
125 | values indicate left edge, positive indicate right edge. Zero | ||
126 | indicates that the filter is not touching either edge. An absolute | ||
127 | value of 1 indicates that the edge tap of the filter is over the | ||
128 | edge pixel of the image. | ||
129 | y_pos - analogous to x_pos. | ||
130 | result - array where the resulting filter will go. The edge | ||
131 | of this filter will be aligned with the image for application... | ||
132 | r_or_e - equal to one of the two constants EXPAND or REDUCE. | ||
133 | -------------------------------------------------------------------- | ||
134 | */ | ||
135 | |||
136 | |||
137 | /* -------------------------------------------------------------------- | ||
138 | nocompute() - Return zero for values where filter hangs over the edge. | ||
139 | */ | ||
140 | |||
141 | int nocompute(filt,x_dim,y_dim,x_pos,y_pos,result,r_or_e) | ||
142 | register double *filt, *result; | ||
143 | register int x_dim; | ||
144 | int y_dim, x_pos, y_pos, r_or_e; | ||
145 | { | ||
146 | register int i; | ||
147 | register int size = x_dim*y_dim; | ||
148 | |||
149 | if ( (x_pos>1) OR (x_pos<-1) OR (y_pos>1) OR (y_pos<-1) ) | ||
150 | for (i=0; i<size; i++) result[i] = 0.0; | ||
151 | else | ||
152 | for (i=0; i<size; i++) result[i] = filt[i]; | ||
153 | |||
154 | return(0); | ||
155 | } | ||
156 | |||
157 | /* -------------------------------------------------------------------- | ||
158 | zero() - Zero outside of image. Discontinuous, but adds zero energy. */ | ||
159 | |||
160 | int zero(filt,x_dim,y_dim,x_pos,y_pos,result,r_or_e) | ||
161 | register double *filt, *result; | ||
162 | register int x_dim; | ||
163 | int y_dim, x_pos, y_pos, r_or_e; | ||
164 | { | ||
165 | register int y_filt,x_filt, y_res,x_res; | ||
166 | int filt_sz = x_dim*y_dim; | ||
167 | int x_start = ((x_pos>0)?(x_pos-1):((x_pos<0)?(x_pos+1):0)); | ||
168 | int y_start = x_dim * ((y_pos>0)?(y_pos-1):((y_pos<0)?(y_pos+1):0)); | ||
169 | int i; | ||
170 | |||
171 | for (i=0; i<filt_sz; i++) result[i] = 0.0; | ||
172 | |||
173 | for (y_filt=0, y_res=y_start; | ||
174 | y_filt<filt_sz; | ||
175 | y_filt+=x_dim, y_res+=x_dim) | ||
176 | if ((y_res >= 0) AND (y_res < filt_sz)) | ||
177 | for (x_filt=y_filt, x_res=x_start; | ||
178 | x_filt<y_filt+x_dim; | ||
179 | x_filt++, x_res++) | ||
180 | if ((x_res >= 0) AND (x_res < x_dim)) | ||
181 | result[y_res+x_res] = filt[x_filt]; | ||
182 | return(0); | ||
183 | } | ||
184 | |||
185 | |||
186 | /* -------------------------------------------------------------------- | ||
187 | reflect1() - Reflection through the edge pixels. Continuous, but | ||
188 | discontinuous first derivative. This is the right thing to do if you | ||
189 | are subsampling by 2, since it maintains parity (even pixels positions | ||
190 | remain even, odd ones remain odd). | ||
191 | */ | ||
192 | |||
193 | int reflect1(filt,x_dim,y_dim,x_pos,y_pos,result,r_or_e) | ||
194 | register double *filt, *result; | ||
195 | register int x_dim; | ||
196 | int y_dim, x_pos, y_pos, r_or_e; | ||
197 | { | ||
198 | int filt_sz = x_dim*y_dim; | ||
199 | register int y_filt,x_filt, y_res, x_res; | ||
200 | register int x_base = (x_pos>0)?(x_dim-1):0; | ||
201 | register int y_base = x_dim * ((y_pos>0)?(y_dim-1):0); | ||
202 | int x_overhang = (x_pos>0)?(x_pos-1):((x_pos<0)?(x_pos+1):0); | ||
203 | int y_overhang = x_dim * ((y_pos>0)?(y_pos-1):((y_pos<0)?(y_pos+1):0)); | ||
204 | int i; | ||
205 | int mx_pos = (x_pos<0)?(x_dim/2):((x_dim-1)/2); | ||
206 | int my_pos = x_dim * ((y_pos<0)?(y_dim/2):((y_dim-1)/2)); | ||
207 | |||
208 | for (i=0; i<filt_sz; i++) result[i] = 0.0; | ||
209 | |||
210 | if (r_or_e IS REDUCE) | ||
211 | for (y_filt=0, y_res=y_overhang-y_base; | ||
212 | y_filt<filt_sz; | ||
213 | y_filt+=x_dim, y_res+=x_dim) | ||
214 | for (x_filt=y_filt, x_res=x_overhang-x_base; | ||
215 | x_filt<y_filt+x_dim; | ||
216 | x_filt++, x_res++) | ||
217 | result[ABS(y_base-ABS(y_res)) + ABS(x_base-ABS(x_res))] | ||
218 | += filt[x_filt]; | ||
219 | else { | ||
220 | y_overhang = ABS(y_overhang); | ||
221 | x_overhang = ABS(x_overhang); | ||
222 | for (y_res=y_base, y_filt = y_base-y_overhang; | ||
223 | y_filt > y_base-filt_sz; | ||
224 | y_filt-=x_dim, y_res-=x_dim) | ||
225 | { | ||
226 | for (x_res=x_base, x_filt=x_base-x_overhang; | ||
227 | x_filt > x_base-x_dim; | ||
228 | x_res--, x_filt--) | ||
229 | result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_filt)+ABS(x_filt)]; | ||
230 | if ((x_overhang ISNT mx_pos) AND (x_pos ISNT 0)) | ||
231 | for (x_res=x_base, x_filt=x_base-2*mx_pos+x_overhang; | ||
232 | x_filt > x_base-x_dim; | ||
233 | x_res--, x_filt--) | ||
234 | result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_filt)+ABS(x_filt)]; | ||
235 | } | ||
236 | if ((y_overhang ISNT my_pos) AND (y_pos ISNT 0)) | ||
237 | for (y_res=y_base, y_filt = y_base-2*my_pos+y_overhang; | ||
238 | y_filt > y_base-filt_sz; | ||
239 | y_filt-=x_dim, y_res-=x_dim) | ||
240 | { | ||
241 | for (x_res=x_base, x_filt=x_base-x_overhang; | ||
242 | x_filt > x_base-x_dim; | ||
243 | x_res--, x_filt--) | ||
244 | result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_filt)+ABS(x_filt)]; | ||
245 | if ((x_overhang ISNT mx_pos) AND (x_pos ISNT 0)) | ||
246 | for (x_res=x_base, x_filt=x_base-2*mx_pos+x_overhang; | ||
247 | x_filt > x_base-x_dim; | ||
248 | x_res--, x_filt--) | ||
249 | result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_filt)+ABS(x_filt)]; | ||
250 | } | ||
251 | } | ||
252 | |||
253 | return(0); | ||
254 | } | ||
255 | |||
256 | /* -------------------------------------------------------------------- | ||
257 | reflect2() - Reflect image at boundary. The edge pixel is repeated, | ||
258 | then the next pixel, etc. Continuous, but discontinuous first | ||
259 | derivative. | ||
260 | */ | ||
261 | |||
262 | int reflect2(filt,x_dim,y_dim,x_pos,y_pos,result,r_or_e) | ||
263 | register double *filt, *result; | ||
264 | register int x_dim; | ||
265 | int y_dim, x_pos, y_pos, r_or_e; | ||
266 | { | ||
267 | int filt_sz = x_dim*y_dim; | ||
268 | register int y_filt,x_filt, y_res, x_res; | ||
269 | register int x_base = (x_pos>0)?(x_dim-1):0; | ||
270 | register int y_base = x_dim * ((y_pos>0)?(y_dim-1):0); | ||
271 | int x_overhang = (x_pos>0)?(x_pos-1):((x_pos<0)?(x_pos+1):0); | ||
272 | int y_overhang = x_dim * ((y_pos>0)?(y_pos-1):((y_pos<0)?(y_pos+1):0)); | ||
273 | int i; | ||
274 | int mx_pos = (x_pos<0)?(x_dim/2):((x_dim-1)/2); | ||
275 | int my_pos = x_dim * ((y_pos<0)?(y_dim/2):((y_dim-1)/2)); | ||
276 | |||
277 | for (i=0; i<filt_sz; i++) result[i] = 0.0; | ||
278 | |||
279 | if (r_or_e IS REDUCE) | ||
280 | for (y_filt=0, y_res = (y_overhang-y_base) - ((y_pos>0)?x_dim:0); | ||
281 | y_filt<filt_sz; | ||
282 | y_filt+=x_dim, y_res+=x_dim) | ||
283 | { | ||
284 | if (y_res IS 0) y_res+=x_dim; | ||
285 | for (x_filt=y_filt, x_res = (x_overhang-x_base) - ((x_pos>0)?1:0); | ||
286 | x_filt<y_filt+x_dim; | ||
287 | x_filt++, x_res++) | ||
288 | { | ||
289 | if (x_res IS 0) x_res++; | ||
290 | result[ABS(y_base-ABS(y_res)+x_dim) + ABS(x_base-ABS(x_res)+1)] | ||
291 | += filt[x_filt]; | ||
292 | } | ||
293 | } | ||
294 | else { | ||
295 | y_overhang = ABS(y_overhang); | ||
296 | x_overhang = ABS(x_overhang); | ||
297 | for (y_res=y_base, y_filt = y_base-y_overhang; | ||
298 | y_filt > y_base-filt_sz; | ||
299 | y_filt-=x_dim, y_res-=x_dim) | ||
300 | { | ||
301 | for (x_res=x_base, x_filt=x_base-x_overhang; | ||
302 | x_filt > x_base-x_dim; | ||
303 | x_res--, x_filt--) | ||
304 | result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_filt)+ABS(x_filt)]; | ||
305 | if (x_pos ISNT 0) | ||
306 | for (x_res=x_base, x_filt=x_base-2*mx_pos+x_overhang-1; | ||
307 | x_filt > x_base-x_dim; | ||
308 | x_res--, x_filt--) | ||
309 | result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_filt)+ABS(x_filt)]; | ||
310 | } | ||
311 | if (y_pos ISNT 0) | ||
312 | for (y_res=y_base, y_filt = y_base-2*my_pos+y_overhang-x_dim; | ||
313 | y_filt > y_base-filt_sz; | ||
314 | y_filt-=x_dim, y_res-=x_dim) | ||
315 | { | ||
316 | for (x_res=x_base, x_filt=x_base-x_overhang; | ||
317 | x_filt > x_base-x_dim; | ||
318 | x_res--, x_filt--) | ||
319 | result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_filt)+ABS(x_filt)]; | ||
320 | if (x_pos ISNT 0) | ||
321 | for (x_res=x_base, x_filt=x_base-2*mx_pos+x_overhang-1; | ||
322 | x_filt > x_base-x_dim; | ||
323 | x_res--, x_filt--) | ||
324 | result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_filt)+ABS(x_filt)]; | ||
325 | } | ||
326 | } | ||
327 | |||
328 | return(0); | ||
329 | } | ||
330 | |||
331 | |||
332 | /* -------------------------------------------------------------------- | ||
333 | qreflect2() - Modified version of reflect2 that works properly for | ||
334 | even-length QMF filters. | ||
335 | */ | ||
336 | |||
337 | int qreflect2(filt,x_dim,y_dim,x_pos,y_pos,result,r_or_e) | ||
338 | double *filt, *result; | ||
339 | int x_dim, y_dim, x_pos, y_pos, r_or_e; | ||
340 | { | ||
341 | reflect2(filt,x_dim,y_dim,x_pos,y_pos,result,0); | ||
342 | return(0); | ||
343 | } | ||
344 | |||
345 | /* -------------------------------------------------------------------- | ||
346 | repeat() - repeat edge pixel. Continuous, with discontinuous first | ||
347 | derivative. | ||
348 | */ | ||
349 | |||
350 | int repeat(filt,x_dim,y_dim,x_pos,y_pos,result,r_or_e) | ||
351 | register double *filt, *result; | ||
352 | register int x_dim; | ||
353 | int y_dim, x_pos, y_pos, r_or_e; | ||
354 | { | ||
355 | register int y_filt,x_filt, y_res,x_res, y_tmp, x_tmp; | ||
356 | register int x_base = (x_pos>0)?(x_dim-1):0; | ||
357 | register int y_base = x_dim * ((y_pos>0)?(y_dim-1):0); | ||
358 | int x_overhang = ((x_pos>0)?(x_pos-1):((x_pos<0)?(x_pos+1):0)); | ||
359 | int y_overhang = x_dim * ((y_pos>0)?(y_pos-1):((y_pos<0)?(y_pos+1):0)); | ||
360 | int filt_sz = x_dim*y_dim; | ||
361 | int mx_pos = (x_dim/2); | ||
362 | int my_pos = x_dim * (y_dim/2); | ||
363 | int i; | ||
364 | |||
365 | for (i=0; i<filt_sz; i++) result[i] = 0.0; | ||
366 | |||
367 | if (r_or_e IS REDUCE) | ||
368 | for (y_filt=0, y_res=y_overhang; | ||
369 | y_filt<filt_sz; | ||
370 | y_filt+=x_dim, y_res+=x_dim) | ||
371 | for (x_filt=y_filt, x_res=x_overhang; | ||
372 | x_filt<y_filt+x_dim; | ||
373 | x_filt++, x_res++) | ||
374 | /* Clip the index: */ | ||
375 | result[((y_res>=0)?((y_res<filt_sz)?y_res:(filt_sz-x_dim)):0) | ||
376 | + ((x_res>=0)?((x_res<x_dim)?x_res:(x_dim-1)):0)] | ||
377 | += filt[x_filt]; | ||
378 | else { | ||
379 | if ((y_base-y_overhang) ISNT my_pos) | ||
380 | for (y_res=y_base, y_filt=y_base-ABS(y_overhang); | ||
381 | y_filt > y_base-filt_sz; | ||
382 | y_filt-=x_dim, y_res-=x_dim) | ||
383 | if ((x_base-x_overhang) ISNT mx_pos) | ||
384 | for (x_res=x_base, x_filt=x_base-ABS(x_overhang); | ||
385 | x_filt > x_base-x_dim; | ||
386 | x_res--, x_filt--) | ||
387 | result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_filt)+ABS(x_filt)]; | ||
388 | else /* ((x_base-x_overhang) IS mx_pos) */ | ||
389 | for (x_res=x_base, x_filt=x_base-ABS(x_overhang); | ||
390 | x_filt > x_base-x_dim; | ||
391 | x_filt--, x_res--) | ||
392 | for(x_tmp=x_filt; x_tmp > x_base-x_dim; x_tmp--) | ||
393 | result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_filt)+ABS(x_tmp)]; | ||
394 | else /* ((y_base-y_overhang) IS my_pos) */ | ||
395 | for (y_res=y_base, y_filt=y_base-ABS(y_overhang); | ||
396 | y_filt > y_base-filt_sz; | ||
397 | y_filt-=x_dim, y_res-=x_dim) | ||
398 | for (y_tmp=y_filt; y_tmp > y_base-filt_sz; y_tmp-=x_dim) | ||
399 | if ((x_base-x_overhang) ISNT mx_pos) | ||
400 | for (x_res=x_base, x_filt=x_base-ABS(x_overhang); | ||
401 | x_filt > x_base-x_dim; | ||
402 | x_filt--, x_res--) | ||
403 | result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_tmp)+ABS(x_filt)]; | ||
404 | else /* ((x_base-x_overhang) IS mx_pos) */ | ||
405 | for (x_res=x_base, x_filt=x_base-ABS(x_overhang); | ||
406 | x_filt > x_base-x_dim; | ||
407 | x_filt--, x_res--) | ||
408 | for (x_tmp=x_filt; x_tmp > x_base-x_dim; x_tmp--) | ||
409 | result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_tmp)+ABS(x_tmp)]; | ||
410 | } /* End, if r_or_e IS EXPAND */ | ||
411 | |||
412 | return(0); | ||
413 | } | ||
414 | |||
415 | /* -------------------------------------------------------------------- | ||
416 | extend() - Extend image by reflecting and inverting about edge pixel | ||
417 | value. Maintains continuity in intensity AND first derivative (but | ||
418 | not higher derivs). | ||
419 | */ | ||
420 | |||
421 | int Extend(filt,x_dim,y_dim,x_pos,y_pos,result,r_or_e) | ||
422 | register double *filt, *result; | ||
423 | register int x_dim; | ||
424 | int y_dim, x_pos, y_pos, r_or_e; | ||
425 | { | ||
426 | int filt_sz = x_dim*y_dim; | ||
427 | register int y_filt,x_filt, y_res,x_res, y_tmp, x_tmp; | ||
428 | register int x_base = (x_pos>0)?(x_dim-1):0; | ||
429 | register int y_base = x_dim * ((y_pos>0)?(y_dim-1):0); | ||
430 | int x_overhang = (x_pos>0)?(x_pos-1):((x_pos<0)?(x_pos+1):0); | ||
431 | int y_overhang = x_dim * ((y_pos>0)?(y_pos-1):((y_pos<0)?(y_pos+1):0)); | ||
432 | int mx_pos = (x_pos<0)?(x_dim/2):((x_dim-1)/2); | ||
433 | int my_pos = x_dim * ((y_pos<0)?(y_dim/2):((y_dim-1)/2)); | ||
434 | int i; | ||
435 | |||
436 | for (i=0; i<filt_sz; i++) result[i] = 0.0; | ||
437 | |||
438 | /* Modeled on reflect1() */ | ||
439 | if (r_or_e IS REDUCE) | ||
440 | for (y_filt=0, y_res=y_overhang; | ||
441 | y_filt<filt_sz; | ||
442 | y_filt+=x_dim, y_res+=x_dim) | ||
443 | if ((y_res>=0) AND (y_res<filt_sz)) | ||
444 | for (x_filt=y_filt, x_res=x_overhang; | ||
445 | x_filt<y_filt+x_dim; | ||
446 | x_filt++, x_res++) | ||
447 | if ((x_res>=0) AND (x_res<x_dim)) | ||
448 | result[y_res+x_res] += filt[x_filt]; | ||
449 | else | ||
450 | { | ||
451 | result[y_res+ABS(x_base-ABS(x_res-x_base))] -= filt[x_filt]; | ||
452 | result[y_res+x_base] += 2*filt[x_filt]; | ||
453 | } | ||
454 | else | ||
455 | for (x_filt=y_filt, x_res=x_overhang; | ||
456 | x_filt<y_filt+x_dim; | ||
457 | x_filt++, x_res++) | ||
458 | if ((x_res>=0) AND (x_res<x_dim)) | ||
459 | { | ||
460 | result[ABS(y_base-ABS(y_res-y_base))+x_res] -= filt[x_filt]; | ||
461 | result[y_base+x_res] += 2*filt[x_filt]; | ||
462 | } | ||
463 | else | ||
464 | { | ||
465 | result[ABS(y_base-ABS(y_res-y_base))+ABS(x_base-ABS(x_res-x_base))] | ||
466 | -= filt[x_filt]; | ||
467 | result[y_base+x_base] += 2*filt[x_filt]; | ||
468 | } | ||
469 | else { /* r_or_e ISNT REDUCE */ | ||
470 | y_overhang = ABS(y_overhang); | ||
471 | x_overhang = ABS(x_overhang); | ||
472 | for (y_res=y_base, y_filt = y_base-y_overhang; | ||
473 | y_filt > y_base-filt_sz; | ||
474 | y_filt-=x_dim, y_res-=x_dim) | ||
475 | { | ||
476 | for (x_res=x_base, x_filt=x_base-x_overhang; | ||
477 | x_filt > x_base-x_dim; | ||
478 | x_res--, x_filt--) | ||
479 | result[ABS(y_res)+ABS(x_res)] += filt[ABS(y_filt)+ABS(x_filt)]; | ||
480 | if (x_pos ISNT 0) | ||
481 | if (x_overhang ISNT mx_pos) | ||
482 | for (x_res=x_base, x_filt=x_base-2*mx_pos+x_overhang; | ||
483 | x_filt > x_base-x_dim; | ||
484 | x_res--, x_filt--) | ||
485 | result[ABS(y_res)+ABS(x_res)] -= filt[ABS(y_filt)+ABS(x_filt)]; | ||
486 | else /* x_overhang IS mx_pos */ | ||
487 | for (x_res=x_base, x_filt=x_base-2*mx_pos+x_overhang-1; | ||
488 | x_filt > x_base-x_dim; | ||
489 | x_res--, x_filt--) | ||
490 | for (x_tmp=x_filt; x_tmp > x_base-x_dim; x_tmp--) | ||
491 | result[ABS(y_res)+ABS(x_res)] += 2*filt[ABS(y_filt)+ABS(x_tmp)]; | ||
492 | } | ||
493 | if (y_pos ISNT 0) | ||
494 | if (y_overhang ISNT my_pos) | ||
495 | for (y_res=y_base, y_filt = y_base-2*my_pos+y_overhang; | ||
496 | y_filt > y_base-filt_sz; | ||
497 | y_filt-=x_dim, y_res-=x_dim) | ||
498 | { | ||
499 | for (x_res=x_base, x_filt=x_base-x_overhang; | ||
500 | x_filt > x_base-x_dim; | ||
501 | x_res--, x_filt--) | ||
502 | result[ABS(y_res)+ABS(x_res)] -= filt[ABS(y_filt)+ABS(x_filt)]; | ||
503 | if ((x_pos ISNT 0) AND (x_overhang ISNT mx_pos)) | ||
504 | for (x_res=x_base, x_filt=x_base-2*mx_pos+x_overhang; | ||
505 | x_filt > x_base-x_dim; | ||
506 | x_res--, x_filt--) | ||
507 | result[ABS(y_res)+ABS(x_res)] -= filt[ABS(y_filt)+ABS(x_filt)]; | ||
508 | } | ||
509 | else /* y_overhang IS my_pos */ | ||
510 | for (y_res=y_base, y_filt = y_base-2*my_pos+y_overhang-x_dim; | ||
511 | y_filt > y_base-filt_sz; | ||
512 | y_res-=x_dim, y_filt-=x_dim) | ||
513 | for (y_tmp=y_filt; y_tmp > y_base-filt_sz; y_tmp-=x_dim) | ||
514 | { | ||
515 | for (x_res=x_base, x_filt=x_base-x_overhang; | ||
516 | x_filt > x_base-x_dim; | ||
517 | x_res--, x_filt--) | ||
518 | result[ABS(y_res)+ABS(x_res)] += 2*filt[ABS(y_tmp)+ABS(x_filt)]; | ||
519 | if ((x_pos ISNT 0) AND (x_overhang IS mx_pos)) | ||
520 | for (x_res=x_base, x_filt=x_base-2*mx_pos+x_overhang-1; | ||
521 | x_filt > x_base-x_dim; | ||
522 | x_res--, x_filt--) | ||
523 | for (x_tmp=x_filt; x_tmp > x_base-x_dim; x_tmp--) | ||
524 | result[ABS(y_res)+ABS(x_res)] += 2*filt[ABS(y_tmp)+ABS(x_tmp)]; | ||
525 | } | ||
526 | } /* r_or_e ISNT REDUCE */ | ||
527 | |||
528 | return(0); | ||
529 | } | ||
530 | |||
531 | /* -------------------------------------------------------------------- | ||
532 | predict() - Simple prediction. Like zero, but multiplies the result | ||
533 | by the reciprocal of the percentage of filter being used. (i.e. if | ||
534 | 50% of the filter is hanging over the edge of the image, multiply the | ||
535 | taps being used by 2). */ | ||
536 | |||
537 | int predict(filt,x_dim,y_dim,x_pos,y_pos,result,r_or_e) | ||
538 | register double *filt, *result; | ||
539 | register int x_dim; | ||
540 | int y_dim, x_pos, y_pos, r_or_e; | ||
541 | { | ||
542 | register int y_filt,x_filt, y_res,x_res; | ||
543 | register double taps_used = 0.0; /* int *** */ | ||
544 | register double fraction = 0.0; | ||
545 | int filt_sz = x_dim*y_dim; | ||
546 | int x_start = ((x_pos>0)?(x_pos-1):((x_pos<0)?(x_pos+1):0)); | ||
547 | int y_start = x_dim * ((y_pos>0)?(y_pos-1):((y_pos<0)?(y_pos+1):0)); | ||
548 | int i; | ||
549 | |||
550 | for (i=0; i<filt_sz; i++) result[i] = 0.0; | ||
551 | |||
552 | for (y_filt=0, y_res=y_start; | ||
553 | y_filt<filt_sz; | ||
554 | y_filt+=x_dim, y_res+=x_dim) | ||
555 | if ((y_res >= 0) AND (y_res < filt_sz)) | ||
556 | for (x_filt=y_filt, x_res=x_start; | ||
557 | x_filt<y_filt+x_dim; | ||
558 | x_filt++, x_res++) | ||
559 | if ((x_res >= 0) AND (x_res < x_dim)) | ||
560 | { | ||
561 | result[y_res+x_res] = filt[x_filt]; | ||
562 | taps_used += ABS(filt[x_filt]); | ||
563 | } | ||
564 | |||
565 | if (r_or_e IS REDUCE) | ||
566 | { | ||
567 | /* fraction = ( (double) filt_sz ) / ( (double) taps_used ); */ | ||
568 | for (i=0; i<filt_sz; i++) fraction += ABS(filt[i]); | ||
569 | fraction = ( fraction / taps_used ); | ||
570 | for (i=0; i<filt_sz; i++) result[i] *= fraction; | ||
571 | } | ||
572 | return(0); | ||
573 | } | ||
574 | |||
575 | |||
576 | /* -------------------------------------------------------------------- | ||
577 | Reflect, multiplying tap of filter which is at the edge of the image | ||
578 | by root 2. This maintains orthogonality of odd-length linear-phase | ||
579 | QMF filters, but it is not useful for most applications, since it | ||
580 | alters the DC level. */ | ||
581 | |||
582 | int ereflect(filt,x_dim,y_dim,x_pos,y_pos,result,r_or_e) | ||
583 | register double *filt, *result; | ||
584 | register int x_dim; | ||
585 | int y_dim, x_pos, y_pos, r_or_e; | ||
586 | { | ||
587 | register int y_filt,x_filt, y_res,x_res; | ||
588 | register int x_base = (x_pos>0)?(x_dim-1):0; | ||
589 | register int y_base = x_dim * ((y_pos>0)?(y_dim-1):0); | ||
590 | int filt_sz = x_dim*y_dim; | ||
591 | int x_overhang = (x_pos>1)?(x_pos-x_dim):((x_pos<-1)?(x_pos+1):0); | ||
592 | int y_overhang = x_dim * ( (y_pos>1)?(y_pos-y_dim):((y_pos<-1)?(y_pos+1):0) ); | ||
593 | int i; | ||
594 | double norm,onorm; | ||
595 | |||
596 | for (i=0; i<filt_sz; i++) result[i] = 0.0; | ||
597 | |||
598 | /* reflect at boundary */ | ||
599 | for (y_filt=0, y_res=y_overhang; | ||
600 | y_filt<filt_sz; | ||
601 | y_filt+=x_dim, y_res+=x_dim) | ||
602 | for (x_filt=y_filt, x_res=x_overhang; | ||
603 | x_filt<y_filt+x_dim; | ||
604 | x_filt++, x_res++) | ||
605 | result[ABS(y_base-ABS(y_res)) + ABS(x_base-ABS(x_res))] | ||
606 | += filt[x_filt]; | ||
607 | |||
608 | /* now multiply edge by root 2 */ | ||
609 | if (x_pos ISNT 0) | ||
610 | for (y_filt=x_base; y_filt<filt_sz; y_filt+=x_dim) | ||
611 | result[y_filt] *= ROOT2; | ||
612 | if (y_pos ISNT 0) | ||
613 | for (x_filt=y_base; x_filt<y_base+x_dim; x_filt++) | ||
614 | result[x_filt] *= ROOT2; | ||
615 | |||
616 | /* now normalize to norm of original filter */ | ||
617 | for (norm=0.0,i=0; i<filt_sz; i++) | ||
618 | norm += (result[i]*result[i]); | ||
619 | norm=sqrt(norm); | ||
620 | |||
621 | for (onorm=0.0,i=0; i<filt_sz; i++) | ||
622 | onorm += (filt[i]*filt[i]); | ||
623 | onorm = sqrt(onorm); | ||
624 | |||
625 | norm = norm/onorm; | ||
626 | for (i=0; i<filt_sz; i++) | ||
627 | result[i] /= norm; | ||
628 | return(0); | ||
629 | } | ||
630 | |||
631 | |||
632 | /* ------- printout stuff for testing ------------------------------ | ||
633 | printf("Xpos: %d, Ypos: %d", x_pos, y_pos); | ||
634 | for (y_filt=0; y_filt<y_dim; y_filt++) | ||
635 | { | ||
636 | printf("\n"); | ||
637 | for (x_filt=0; x_filt<x_dim; x_filt++) | ||
638 | printf("%6.1f", result[y_filt*x_dim+x_filt]); | ||
639 | } | ||
640 | printf("\n"); | ||
641 | */ | ||
642 | |||
643 | |||
644 | |||
645 | /* Local Variables: */ | ||
646 | /* buffer-read-only: t */ | ||
647 | /* End: */ | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/histo.c b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/histo.c deleted file mode 100755 index 43a99c7..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/histo.c +++ /dev/null | |||
@@ -1,140 +0,0 @@ | |||
1 | /* | ||
2 | [N, X] = histo(MTX, NBINS_OR_BINSIZE, BIN_CENTER) | ||
3 | >>> See histo.m for documentation <<< | ||
4 | EPS, ported from OBVIUS, 3/97. | ||
5 | */ | ||
6 | |||
7 | #define V4_COMPAT | ||
8 | #include <matrix.h> /* Matlab matrices */ | ||
9 | #include <mex.h> | ||
10 | |||
11 | #include <stddef.h> /* NULL */ | ||
12 | #include <math.h> /* ceil */ | ||
13 | |||
14 | #define notDblMtx(it) (!mxIsNumeric(it) || !mxIsDouble(it) || mxIsSparse(it) || mxIsComplex(it)) | ||
15 | |||
16 | #define PAD 0.49999 /* A hair below 1/2, to avoid roundoff errors */ | ||
17 | #define MAXBINS 20000 | ||
18 | |||
19 | void mexFunction(int nlhs, /* Num return vals on lhs */ | ||
20 | mxArray *plhs[], /* Matrices on lhs */ | ||
21 | int nrhs, /* Num args on rhs */ | ||
22 | const mxArray *prhs[] /* Matrices on rhs */ | ||
23 | ) | ||
24 | { | ||
25 | register double temp; | ||
26 | register int binnum, i, size; | ||
27 | register double *im, binsize; | ||
28 | register double origin, *hist, mn, mx, mean; | ||
29 | register int nbins; | ||
30 | double *bincenters; | ||
31 | mxArray *arg; | ||
32 | double *mxMat; | ||
33 | |||
34 | if (nrhs < 1 ) mexErrMsgTxt("requires at least 1 argument."); | ||
35 | |||
36 | /* ARG 1: MATRIX */ | ||
37 | arg = prhs[0]; | ||
38 | if notDblMtx(arg) mexErrMsgTxt("MTX arg must be a real non-sparse matrix."); | ||
39 | im = mxGetPr(arg); | ||
40 | size = (int) mxGetM(arg) * mxGetN(arg); | ||
41 | |||
42 | /* FIND min, max, mean values of MTX */ | ||
43 | mn = *im; mx = *im; binsize = 0; | ||
44 | for (i=1; i<size; i++) | ||
45 | { | ||
46 | temp = im[i]; | ||
47 | if (temp < mn) | ||
48 | mn = temp; | ||
49 | else if (temp > mx) | ||
50 | mx = temp; | ||
51 | binsize += temp; | ||
52 | } | ||
53 | mean = binsize / size; | ||
54 | |||
55 | /* ARG 3: BIN_CENTER */ | ||
56 | if (nrhs > 2) | ||
57 | { | ||
58 | arg = prhs[2]; | ||
59 | if notDblMtx(arg) mexErrMsgTxt("BIN_CENTER arg must be a real scalar."); | ||
60 | if (mxGetM(arg) * mxGetN(arg) != 1) | ||
61 | mexErrMsgTxt("BIN_CENTER must be a real scalar."); | ||
62 | mxMat= mxGetPr(arg); | ||
63 | origin = *mxMat; | ||
64 | } | ||
65 | else | ||
66 | origin = mean; | ||
67 | |||
68 | /* ARG 2: If positive, NBINS. If negative, -BINSIZE. */ | ||
69 | if (nrhs > 1) | ||
70 | { | ||
71 | arg = prhs[1]; | ||
72 | if notDblMtx(arg) mexErrMsgTxt("NBINS_OR_BINSIZE arg must be a real scalar."); | ||
73 | if (mxGetM(arg) * mxGetN(arg) != 1) | ||
74 | mexErrMsgTxt("NBINS_OR_BINSIZE must be a real scalar."); | ||
75 | mxMat= mxGetPr(arg); | ||
76 | binsize = *mxMat; | ||
77 | } | ||
78 | else | ||
79 | { | ||
80 | binsize = 101; /* DEFAULT: 101 bins */ | ||
81 | } | ||
82 | |||
83 | /* -------------------------------------------------- | ||
84 | Adjust origin, binsize, nbins such that | ||
85 | mx <= origin + (nbins-1)*binsize + PAD*binsize | ||
86 | mn >= origin - PAD*binsize | ||
87 | -------------------------------------------------- */ | ||
88 | if (binsize < 0) /* user specified BINSIZE */ | ||
89 | { | ||
90 | binsize = -binsize; | ||
91 | origin -= binsize * ceil((origin-mn-PAD*binsize)/binsize); | ||
92 | nbins = (int) ceil((mx-origin-PAD*binsize)/binsize) + 1; | ||
93 | } | ||
94 | else /* user specified NBINS */ | ||
95 | { | ||
96 | nbins = (int) (binsize + 0.5); /* round to int */ | ||
97 | if (nbins == 0) | ||
98 | mexErrMsgTxt("NBINS must be greater than zero."); | ||
99 | binsize = (mx-mn)/(nbins-1+2*PAD); /* start with lower bound */ | ||
100 | i = ceil((origin-mn-binsize/2)/binsize); | ||
101 | if ( mn < (origin-i*binsize-PAD*binsize) ) | ||
102 | binsize = (origin-mn)/(i+PAD); | ||
103 | else if ( mx > (origin+(nbins-1-i)*binsize+PAD*binsize) ) | ||
104 | binsize = (mx-origin)/((nbins-1-i)+PAD); | ||
105 | origin -= binsize * ceil((origin-mn-PAD*binsize)/binsize); | ||
106 | } | ||
107 | |||
108 | if (nbins > MAXBINS) | ||
109 | { | ||
110 | mexPrintf("nbins: %d, MAXBINS: %d\n",nbins,MAXBINS); | ||
111 | mexErrMsgTxt("Number of histo bins has exceeded maximum"); | ||
112 | } | ||
113 | |||
114 | /* Allocate hist and xvals */ | ||
115 | plhs[0] = (mxArray *) mxCreateDoubleMatrix(1,nbins,mxREAL); | ||
116 | if (plhs[0] == NULL) mexErrMsgTxt("Error allocating result matrix"); | ||
117 | hist = mxGetPr(plhs[0]); | ||
118 | |||
119 | if (nlhs > 1) | ||
120 | { | ||
121 | plhs[1] = (mxArray *) mxCreateDoubleMatrix(1,nbins,mxREAL); | ||
122 | if (plhs[1] == NULL) mexErrMsgTxt("Error allocating result matrix"); | ||
123 | bincenters = mxGetPr(plhs[1]); | ||
124 | for (i=0, temp=origin; i<nbins; i++, temp+=binsize) | ||
125 | bincenters[i] = temp; | ||
126 | } | ||
127 | |||
128 | for (i=0; i<size; i++) | ||
129 | { | ||
130 | binnum = (int) ((im[i] - origin)/binsize + 0.5); | ||
131 | if ((binnum < nbins) && (binnum >= 0)) | ||
132 | (hist[binnum]) += 1.0; | ||
133 | else | ||
134 | printf("HISTO warning: value %f outside of range [%f,%f]\n", | ||
135 | im[i], origin-0.5*binsize, origin+(nbins-0.5)*binsize); | ||
136 | } | ||
137 | |||
138 | return; | ||
139 | } | ||
140 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/innerProd.c b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/innerProd.c deleted file mode 100755 index 8fa1224..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/innerProd.c +++ /dev/null | |||
@@ -1,52 +0,0 @@ | |||
1 | /* | ||
2 | RES = innerProd(MAT); | ||
3 | Computes mat'*mat | ||
4 | Odelia Schwartz, 8/97. | ||
5 | */ | ||
6 | |||
7 | #define V4_COMPAT | ||
8 | #include <matrix.h> | ||
9 | |||
10 | #include <stdio.h> | ||
11 | #include <ctype.h> | ||
12 | #include <math.h> | ||
13 | #include <strings.h> | ||
14 | #include <stdlib.h> | ||
15 | |||
16 | void mexFunction(int nlhs, /* Num return vals on lhs */ | ||
17 | mxArray *plhs[], /* Matrices on lhs */ | ||
18 | int nrhs, /* Num args on rhs */ | ||
19 | const mxArray *prhs[] /* Matrices on rhs */ | ||
20 | ) | ||
21 | { | ||
22 | register double *res, *mat, tmp; | ||
23 | register int len, wid, i, k, j, jlen, ilen, imat, jmat; | ||
24 | mxArray *arg; | ||
25 | |||
26 | /* get matrix input argument */ | ||
27 | /* should be matrix in which num rows >= num columns */ | ||
28 | arg=prhs[0]; | ||
29 | mat= mxGetPr(arg); | ||
30 | len = (int) mxGetM(arg); | ||
31 | wid = (int) mxGetN(arg); | ||
32 | if ( wid > len ) | ||
33 | printf("innerProd: Warning: width %d is greater than length %d.\n",wid,len); | ||
34 | plhs[0] = (mxArray *) mxCreateDoubleMatrix(wid,wid,mxREAL); | ||
35 | if (plhs[0] == NULL) | ||
36 | mexErrMsgTxt(sprintf("Error allocating %dx%d result matrix",wid,wid)); | ||
37 | res = mxGetPr(plhs[0]); | ||
38 | |||
39 | for(i=0, ilen=0; i<wid; i++, ilen+=len) | ||
40 | { | ||
41 | for(j=i, jlen=ilen; j<wid; j++, jlen+=len) | ||
42 | { | ||
43 | tmp = 0.0; | ||
44 | for(k=0, imat=ilen, jmat=jlen; k<len; k++, imat++, jmat++) | ||
45 | tmp += mat[imat]*mat[jmat]; | ||
46 | res[i*wid+j] = tmp; | ||
47 | res[j*wid+i] = tmp; | ||
48 | } | ||
49 | } | ||
50 | return; | ||
51 | |||
52 | } | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/innerProd.dll b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/innerProd.dll deleted file mode 100755 index 40ac896..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/innerProd.dll +++ /dev/null | |||
Binary files differ | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/innerProd.mexglx b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/innerProd.mexglx deleted file mode 100755 index 749a5b5..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/innerProd.mexglx +++ /dev/null | |||
Binary files differ | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/innerProd.mexlx b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/innerProd.mexlx deleted file mode 100755 index 151b08f..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/innerProd.mexlx +++ /dev/null | |||
Binary files differ | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/innerProd.mexmac b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/innerProd.mexmac deleted file mode 100755 index 6e11fcd..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/innerProd.mexmac +++ /dev/null | |||
Binary files differ | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/innerProd.mexsol b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/innerProd.mexsol deleted file mode 100755 index d761ed8..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/innerProd.mexsol +++ /dev/null | |||
Binary files differ | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/pointOp.c b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/pointOp.c deleted file mode 100755 index 6ffcb45..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/pointOp.c +++ /dev/null | |||
@@ -1,126 +0,0 @@ | |||
1 | /* | ||
2 | RES = pointOp(IM, LUT, ORIGIN, INCREMENT, WARNINGS) | ||
3 | >>> See pointOp.m for documentation <<< | ||
4 | EPS, ported from OBVIUS, 7/96. | ||
5 | */ | ||
6 | |||
7 | #define V4_COMPAT | ||
8 | #include <matrix.h> /* Matlab matrices */ | ||
9 | #include <mex.h> | ||
10 | |||
11 | #include <stddef.h> /* NULL */ | ||
12 | |||
13 | #define notDblMtx(it) (!mxIsNumeric(it) || !mxIsDouble(it) || mxIsSparse(it) || mxIsComplex(it)) | ||
14 | |||
15 | void internal_pointop(); | ||
16 | |||
17 | void mexFunction(int nlhs, /* Num return vals on lhs */ | ||
18 | mxArray *plhs[], /* Matrices on lhs */ | ||
19 | int nrhs, /* Num args on rhs */ | ||
20 | const mxArray *prhs[] /* Matrices on rhs */ | ||
21 | ) | ||
22 | { | ||
23 | double *image, *lut, *res; | ||
24 | double origin, increment; | ||
25 | int x_dim, y_dim, lx_dim, ly_dim; | ||
26 | int warnings = 1; | ||
27 | mxArray *arg; | ||
28 | double *mxMat; | ||
29 | |||
30 | if (nrhs < 4 ) mexErrMsgTxt("requres at least 4 args."); | ||
31 | |||
32 | /* ARG 1: IMAGE */ | ||
33 | arg = prhs[0]; | ||
34 | if notDblMtx(arg) mexErrMsgTxt("IMAGE arg must be a real non-sparse matrix."); | ||
35 | image = mxGetPr(arg); | ||
36 | x_dim = (int) mxGetM(arg); /* X is inner index! */ | ||
37 | y_dim = (int) mxGetN(arg); | ||
38 | |||
39 | /* ARG 2: Lookup table */ | ||
40 | arg = prhs[1]; | ||
41 | if notDblMtx(arg) mexErrMsgTxt("LUT arg must be a real non-sparse matrix."); | ||
42 | lut = mxGetPr(arg); | ||
43 | lx_dim = (int) mxGetM(arg); /* X is inner index! */ | ||
44 | ly_dim = (int) mxGetN(arg); | ||
45 | if ( (lx_dim != 1) && (ly_dim != 1) ) | ||
46 | mexErrMsgTxt("Lookup table must be a row or column vector."); | ||
47 | |||
48 | /* ARG 3: ORIGIN */ | ||
49 | arg = prhs[2]; | ||
50 | if notDblMtx(arg) mexErrMsgTxt("ORIGIN arg must be a real scalar."); | ||
51 | if (mxGetM(arg) * mxGetN(arg) != 1) | ||
52 | mexErrMsgTxt("ORIGIN arg must be a real scalar."); | ||
53 | mxMat = mxGetPr(arg); | ||
54 | origin = *mxMat; | ||
55 | |||
56 | /* ARG 4: INCREMENT */ | ||
57 | arg = prhs[3]; | ||
58 | if notDblMtx(arg) mexErrMsgTxt("INCREMENT arg must be a real scalar."); | ||
59 | if (mxGetM(arg) * mxGetN(arg) != 1) | ||
60 | mexErrMsgTxt("INCREMENT arg must be a real scalar."); | ||
61 | mxMat = mxGetPr(arg); | ||
62 | increment = *mxMat; | ||
63 | |||
64 | /* ARG 5: WARNINGS */ | ||
65 | if (nrhs>4) | ||
66 | { | ||
67 | arg = prhs[4]; | ||
68 | if notDblMtx(arg) mexErrMsgTxt("WARINGS arg must be a real scalar."); | ||
69 | if (mxGetM(arg) * mxGetN(arg) != 1) | ||
70 | mexErrMsgTxt("WARNINGS arg must be a real scalar."); | ||
71 | mxMat = mxGetPr(arg); | ||
72 | warnings = (int) *mxMat; | ||
73 | } | ||
74 | |||
75 | plhs[0] = (mxArray *) mxCreateDoubleMatrix(x_dim,y_dim,mxREAL); | ||
76 | if (plhs[0] == NULL) mexErrMsgTxt("Cannot allocate result matrix"); | ||
77 | res = mxGetPr(plhs[0]); | ||
78 | |||
79 | internal_pointop(image, res, x_dim*y_dim, lut, lx_dim*ly_dim, | ||
80 | origin, increment, warnings); | ||
81 | return; | ||
82 | } | ||
83 | |||
84 | |||
85 | /* Use linear interpolation on a lookup table. | ||
86 | Taken from OBVIUS. EPS, Spring, 1987. | ||
87 | */ | ||
88 | void internal_pointop (im, res, size, lut, lutsize, origin, increment, warnings) | ||
89 | register double *im, *res, *lut; | ||
90 | register double origin, increment; | ||
91 | register int size, lutsize, warnings; | ||
92 | { | ||
93 | register int i, index; | ||
94 | register double pos; | ||
95 | register int l_unwarned = warnings; | ||
96 | register int r_unwarned = warnings; | ||
97 | |||
98 | lutsize = lutsize - 2; /* Maximum index value */ | ||
99 | if (increment > 0) | ||
100 | for (i=0; i<size; i++) | ||
101 | { | ||
102 | pos = (im[i] - origin) / increment; | ||
103 | index = (int) pos; /* Floor */ | ||
104 | if (index < 0) | ||
105 | { | ||
106 | index = 0; | ||
107 | if (l_unwarned) | ||
108 | { | ||
109 | mexPrintf("Warning: Extrapolating to left of lookup table...\n"); | ||
110 | l_unwarned = 0; | ||
111 | } | ||
112 | } | ||
113 | else if (index > lutsize) | ||
114 | { | ||
115 | index = lutsize; | ||
116 | if (r_unwarned) | ||
117 | { | ||
118 | mexPrintf("Warning: Extrapolating to right of lookup table...\n"); | ||
119 | r_unwarned = 0; | ||
120 | } | ||
121 | } | ||
122 | res[i] = lut[index] + (lut[index+1] - lut[index]) * (pos - index); | ||
123 | } | ||
124 | else | ||
125 | for (i=0; i<size; i++) res[i] = *lut; | ||
126 | } | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/range2.c b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/range2.c deleted file mode 100755 index b84f4e1..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/range2.c +++ /dev/null | |||
@@ -1,56 +0,0 @@ | |||
1 | /* | ||
2 | [MIN, MAX] = range2(MTX) | ||
3 | >>> See range2.m for documentation <<< | ||
4 | EPS, 3/97. | ||
5 | */ | ||
6 | |||
7 | #define V4_COMPAT | ||
8 | #include <matrix.h> /* Matlab matrices */ | ||
9 | #include <mex.h> | ||
10 | |||
11 | #include <stddef.h> /* NULL */ | ||
12 | |||
13 | #define notDblMtx(it) (!mxIsNumeric(it) || !mxIsDouble(it) || mxIsSparse(it) || mxIsComplex(it)) | ||
14 | |||
15 | void mexFunction(int nlhs, /* Num return vals on lhs */ | ||
16 | mxArray *plhs[], /* Matrices on lhs */ | ||
17 | int nrhs, /* Num args on rhs */ | ||
18 | const mxArray *prhs[] /* Matrices on rhs */ | ||
19 | ) | ||
20 | { | ||
21 | register double temp, mn, mx; | ||
22 | register double *mtx; | ||
23 | register int i, size; | ||
24 | mxArray *arg; | ||
25 | |||
26 | if (nrhs != 1) mexErrMsgTxt("requires 1 argument."); | ||
27 | |||
28 | /* ARG 1: MATRIX */ | ||
29 | arg = prhs[0]; | ||
30 | if notDblMtx(arg) mexErrMsgTxt("MTX arg must be a real non-sparse matrix."); | ||
31 | mtx = mxGetPr(arg); | ||
32 | size = (int) mxGetM(arg) * mxGetN(arg); | ||
33 | |||
34 | /* FIND min, max values of MTX */ | ||
35 | mn = *mtx; mx = *mtx; | ||
36 | for (i=1; i<size; i++) | ||
37 | { | ||
38 | temp = mtx[i]; | ||
39 | if (temp < mn) | ||
40 | mn = temp; | ||
41 | else if (temp > mx) | ||
42 | mx = temp; | ||
43 | } | ||
44 | |||
45 | plhs[0] = (mxArray *) mxCreateDoubleMatrix(1,1,mxREAL); | ||
46 | if (plhs[0] == NULL) mexErrMsgTxt("Error allocating result matrix"); | ||
47 | plhs[1] = (mxArray *) mxCreateDoubleMatrix(1,1,mxREAL); | ||
48 | if (plhs[1] == NULL) mexErrMsgTxt("Error allocating result matrix"); | ||
49 | mtx = mxGetPr(plhs[0]); | ||
50 | mtx[0] = mn; | ||
51 | mtx = mxGetPr(plhs[1]); | ||
52 | mtx[0] = mx; | ||
53 | |||
54 | return; | ||
55 | } | ||
56 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/upConv.c b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/upConv.c deleted file mode 100755 index 3708f8a..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/upConv.c +++ /dev/null | |||
@@ -1,195 +0,0 @@ | |||
1 | /* | ||
2 | RES = upConv(IM, FILT, EDGES, STEP, START, STOP, RES); | ||
3 | >>> See upConv.m for documentation <<< | ||
4 | This is a matlab interface to the internal_expand function. | ||
5 | EPS, 7/96. | ||
6 | */ | ||
7 | |||
8 | #define V4_COMPAT | ||
9 | #include <matrix.h> /* Matlab matrices */ | ||
10 | #include <mex.h> | ||
11 | |||
12 | #include "convolve.h" | ||
13 | |||
14 | #define notDblMtx(it) (!mxIsNumeric(it) || !mxIsDouble(it) || mxIsSparse(it) || mxIsComplex(it)) | ||
15 | |||
16 | void mexFunction(int nlhs, /* Num return vals on lhs */ | ||
17 | mxArray *plhs[], /* Matrices on lhs */ | ||
18 | int nrhs, /* Num args on rhs */ | ||
19 | const mxArray *prhs[] /* Matrices on rhs */ | ||
20 | ) | ||
21 | { | ||
22 | double *image,*filt, *temp, *result, *orig_filt; | ||
23 | int x_fdim, y_fdim, x_idim, y_idim; | ||
24 | int orig_x = 0, orig_y, x, y; | ||
25 | int x_rdim, y_rdim; | ||
26 | int x_start = 1; | ||
27 | int x_step = 1; | ||
28 | int y_start = 1; | ||
29 | int y_step = 1; | ||
30 | int x_stop, y_stop; | ||
31 | mxArray *arg; | ||
32 | double *mxMat; | ||
33 | char edges[15] = "reflect1"; | ||
34 | |||
35 | if (nrhs<2) mexErrMsgTxt("requres at least 2 args."); | ||
36 | |||
37 | /* ARG 1: IMAGE */ | ||
38 | arg = prhs[0]; | ||
39 | if notDblMtx(arg) mexErrMsgTxt("IMAGE arg must be a non-sparse double float matrix."); | ||
40 | image = mxGetPr(arg); | ||
41 | x_idim = (int) mxGetM(arg); /* X is inner index! */ | ||
42 | y_idim = (int) mxGetN(arg); | ||
43 | |||
44 | /* ARG 2: FILTER */ | ||
45 | arg = prhs[1]; | ||
46 | if notDblMtx(arg) mexErrMsgTxt("FILTER arg must be non-sparse double float matrix."); filt = mxGetPr(arg); | ||
47 | x_fdim = (int) mxGetM(arg); | ||
48 | y_fdim = (int) mxGetN(arg); | ||
49 | |||
50 | /* ARG 3 (optional): EDGES */ | ||
51 | if (nrhs>2) | ||
52 | { | ||
53 | if (!mxIsChar(prhs[2])) | ||
54 | mexErrMsgTxt("EDGES arg must be a string."); | ||
55 | mxGetString(prhs[2],edges,15); | ||
56 | } | ||
57 | |||
58 | /* ARG 4 (optional): STEP */ | ||
59 | if (nrhs>3) | ||
60 | { | ||
61 | arg = prhs[3]; | ||
62 | if notDblMtx(arg) mexErrMsgTxt("STEP arg must be double float matrix."); | ||
63 | if (mxGetM(arg) * mxGetN(arg) != 2) | ||
64 | mexErrMsgTxt("STEP arg must contain two elements."); | ||
65 | mxMat = mxGetPr(arg); | ||
66 | x_step = (int) mxMat[0]; | ||
67 | y_step = (int) mxMat[1]; | ||
68 | if ((x_step<1) || (y_step<1)) | ||
69 | mexErrMsgTxt("STEP values must be greater than zero."); | ||
70 | } | ||
71 | |||
72 | /* ARG 5 (optional): START */ | ||
73 | if (nrhs>4) | ||
74 | { | ||
75 | arg = prhs[4]; | ||
76 | if notDblMtx(arg) mexErrMsgTxt("START arg must be double float matrix."); | ||
77 | if (mxGetM(arg) * mxGetN(arg) != 2) | ||
78 | mexErrMsgTxt("START arg must contain two elements."); | ||
79 | mxMat = mxGetPr(arg); | ||
80 | x_start = (int) mxMat[0]; | ||
81 | y_start = (int) mxMat[1]; | ||
82 | if ((x_start<1) || (y_start<1)) | ||
83 | mexErrMsgTxt("START values must be greater than zero."); | ||
84 | } | ||
85 | x_start--; /* convert to standard C indexes */ | ||
86 | y_start--; | ||
87 | |||
88 | /* ARG 6 (optional): STOP */ | ||
89 | if (nrhs>5) | ||
90 | { | ||
91 | if notDblMtx(prhs[5]) mexErrMsgTxt("STOP arg must be double float matrix."); | ||
92 | if (mxGetM(prhs[5]) * mxGetN(prhs[5]) != 2) | ||
93 | mexErrMsgTxt("STOP arg must contain two elements."); | ||
94 | mxMat = mxGetPr(prhs[5]); | ||
95 | x_stop = (int) mxMat[0]; | ||
96 | y_stop = (int) mxMat[1]; | ||
97 | if ((x_stop<x_start) || (y_stop<y_start)) | ||
98 | mexErrMsgTxt("STOP values must be greater than START values."); | ||
99 | } | ||
100 | else | ||
101 | { /* default: make res dims a multiple of STEP size */ | ||
102 | x_stop = x_step * ((x_start/x_step) + x_idim); | ||
103 | y_stop = y_step * ((y_start/y_step) + y_idim); | ||
104 | } | ||
105 | |||
106 | /* ARG 6 (optional): RESULT image */ | ||
107 | if (nrhs>6) | ||
108 | { | ||
109 | arg = prhs[6]; | ||
110 | if notDblMtx(arg) mexErrMsgTxt("RES arg must be double float matrix."); | ||
111 | |||
112 | /* 7/10/97: Returning one of the args causes problems with Matlab's memory | ||
113 | manager, so we don't return anything if the result image is passed */ | ||
114 | /* plhs[0] = arg; */ | ||
115 | result = mxGetPr(arg); | ||
116 | x_rdim = (int) mxGetM(arg); /* X is inner index! */ | ||
117 | y_rdim = (int) mxGetN(arg); | ||
118 | if ((x_stop>x_rdim) || (y_stop>y_rdim)) | ||
119 | mexErrMsgTxt("STOP values must within image dimensions."); | ||
120 | } | ||
121 | else | ||
122 | { | ||
123 | x_rdim = x_stop; | ||
124 | y_rdim = y_stop; | ||
125 | /* x_rdim = x_step * ((x_stop+x_step-1)/x_step); | ||
126 | y_rdim = y_step * ((y_stop+y_step-1)/y_step); */ | ||
127 | |||
128 | plhs[0] = (mxArray *) mxCreateDoubleMatrix(x_rdim,y_rdim,mxREAL); | ||
129 | if (plhs[0] == NULL) mexErrMsgTxt("Cannot allocate result matrix"); | ||
130 | result = mxGetPr(plhs[0]); | ||
131 | } | ||
132 | |||
133 | if ( (((x_stop-x_start+x_step-1) / x_step) != x_idim) || | ||
134 | (((y_stop-y_start+y_step-1) / y_step) != y_idim) ) | ||
135 | { | ||
136 | mexPrintf("Im dims: [%d %d]\n",x_idim,y_idim); | ||
137 | mexPrintf("Start: [%d %d]\n",x_start,y_start); | ||
138 | mexPrintf("Step: [%d %d]\n",x_step,y_step); | ||
139 | mexPrintf("Stop: [%d %d]\n",x_stop,y_stop); | ||
140 | mexPrintf("Res dims: [%d %d]\n",x_rdim,y_rdim); | ||
141 | mexErrMsgTxt("Image sizes and upsampling args are incompatible!"); | ||
142 | } | ||
143 | |||
144 | /* upConv has a bug for even-length kernels when using the | ||
145 | reflect1, extend, or repeat edge-handlers */ | ||
146 | if ((!strcmp(edges,"reflect1") || !strcmp(edges,"extend") || !strcmp(edges,"repeat")) | ||
147 | && | ||
148 | ((x_fdim%2 == 0) || (y_fdim%2 == 0))) | ||
149 | { | ||
150 | orig_filt = filt; | ||
151 | orig_x = x_fdim; | ||
152 | orig_y = y_fdim; | ||
153 | x_fdim = 2*(orig_x/2)+1; | ||
154 | y_fdim = 2*(orig_y/2)+1; | ||
155 | filt = mxCalloc(x_fdim*y_fdim, sizeof(double)); | ||
156 | if (filt == NULL) | ||
157 | mexErrMsgTxt("Cannot allocate necessary temporary space"); | ||
158 | for (y=0; y<orig_y; y++) | ||
159 | for (x=0; x<orig_x; x++) | ||
160 | filt[y*x_fdim + x] = orig_filt[y*orig_x + x]; | ||
161 | } | ||
162 | |||
163 | if ((x_fdim > x_rdim) || (y_fdim > y_rdim)) | ||
164 | { | ||
165 | mexPrintf("Filter: [%d %d], ",x_fdim,y_fdim); | ||
166 | mexPrintf("Result: [%d %d]\n",x_rdim,y_rdim); | ||
167 | mexErrMsgTxt("FILTER dimensions larger than RESULT dimensions."); | ||
168 | } | ||
169 | |||
170 | temp = mxCalloc(x_fdim*y_fdim, sizeof(double)); | ||
171 | if (temp == NULL) | ||
172 | mexErrMsgTxt("Cannot allocate necessary temporary space"); | ||
173 | |||
174 | /* | ||
175 | printf("(%d, %d), (%d, %d), (%d, %d), (%d, %d), (%d, %d), %s\n", | ||
176 | x_idim,y_idim,x_fdim,y_fdim,x_rdim,y_rdim, | ||
177 | x_start,x_step,y_start,y_step,edges); | ||
178 | */ | ||
179 | |||
180 | if (strcmp(edges,"circular") == 0) | ||
181 | internal_wrap_expand(image, filt, x_fdim, y_fdim, | ||
182 | x_start, x_step, x_stop, y_start, y_step, y_stop, | ||
183 | result, x_rdim, y_rdim); | ||
184 | else internal_expand(image, filt, temp, x_fdim, y_fdim, | ||
185 | x_start, x_step, x_stop, y_start, y_step, y_stop, | ||
186 | result, x_rdim, y_rdim, edges); | ||
187 | |||
188 | if (orig_x) mxFree((char *) filt); | ||
189 | mxFree((char *) temp); | ||
190 | |||
191 | return; | ||
192 | } | ||
193 | |||
194 | |||
195 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/wrap.c b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/wrap.c deleted file mode 100755 index a081123..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/wrap.c +++ /dev/null | |||
@@ -1,281 +0,0 @@ | |||
1 | /* | ||
2 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
3 | ;;; File: wrap.c | ||
4 | ;;; Author: Eero Simoncelli | ||
5 | ;;; Description: Circular convolution on 2D images. | ||
6 | ;;; Creation Date: Spring, 1987. | ||
7 | ;;; MODIFICATIONS: | ||
8 | ;;; 6/96: Switched array types to double float. | ||
9 | ;;; 2/97: made more robust and readable. Added STOP arguments. | ||
10 | ;;; ---------------------------------------------------------------- | ||
11 | ;;; Object-Based Vision and Image Understanding System (OBVIUS), | ||
12 | ;;; Copyright 1988, Vision Science Group, Media Laboratory, | ||
13 | ;;; Massachusetts Institute of Technology. | ||
14 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
15 | */ | ||
16 | |||
17 | #include <stdlib.h> | ||
18 | |||
19 | #include "convolve.h" | ||
20 | |||
21 | /* | ||
22 | -------------------------------------------------------------------- | ||
23 | Performs correlation (i.e., convolution with filt(-x,-y)) of FILT | ||
24 | with IMAGE followed by subsampling (a.k.a. REDUCE in Burt&Adelson81). | ||
25 | The operations are combined to avoid unnecessary computation of the | ||
26 | convolution samples that are to be discarded in the subsampling | ||
27 | operation. The convolution is done in 9 sections so that mod | ||
28 | operations are not performed unnecessarily. The subsampling lattice | ||
29 | is specified by the START, STEP and STOP parameters. | ||
30 | -------------------------------------------------------------------- */ | ||
31 | |||
32 | /* abstract out the inner product computation */ | ||
33 | #define INPROD(YSTART,YIND,XSTART,XIND) \ | ||
34 | { \ | ||
35 | sum=0.0; \ | ||
36 | for (y_im=YSTART, filt_pos=0, x_filt_stop=x_fdim; \ | ||
37 | x_filt_stop<=filt_size; \ | ||
38 | y_im++, x_filt_stop+=x_fdim) \ | ||
39 | for (x_im=XSTART ; \ | ||
40 | filt_pos<x_filt_stop; \ | ||
41 | filt_pos++, x_im++) \ | ||
42 | sum += imval[YIND][XIND] * filt[filt_pos]; \ | ||
43 | result[res_pos] = sum; \ | ||
44 | } | ||
45 | |||
46 | int internal_wrap_reduce(image, x_dim, y_dim, filt, x_fdim, y_fdim, | ||
47 | x_start, x_step, x_stop, y_start, y_step, y_stop, | ||
48 | result) | ||
49 | register image_type *filt, *result; | ||
50 | register int x_dim, y_dim, x_fdim, y_fdim; | ||
51 | image_type *image; | ||
52 | int x_start, x_step, x_stop, y_start, y_step, y_stop; | ||
53 | { | ||
54 | register double sum; | ||
55 | register int filt_size = x_fdim*y_fdim; | ||
56 | image_type **imval; | ||
57 | register int filt_pos, x_im, y_im, x_filt_stop; | ||
58 | register int x_pos, y_pos, res_pos; | ||
59 | int x_ctr_stop = x_dim - x_fdim + 1; | ||
60 | int y_ctr_stop = y_dim - y_fdim + 1; | ||
61 | int x_ctr_start = 0; | ||
62 | int y_ctr_start = 0; | ||
63 | int x_fmid = x_fdim/2; | ||
64 | int y_fmid = y_fdim/2; | ||
65 | |||
66 | /* shift start/stop coords to filter upper left hand corner */ | ||
67 | x_start -= x_fmid; y_start -= y_fmid; | ||
68 | x_stop -= x_fmid; y_stop -= y_fmid; | ||
69 | |||
70 | if (x_stop < x_ctr_stop) x_ctr_stop = x_stop; | ||
71 | if (y_stop < y_ctr_stop) y_ctr_stop = y_stop; | ||
72 | |||
73 | /* Set up pointer array for rows */ | ||
74 | imval = (image_type **) malloc(y_dim*sizeof(image_type *)); | ||
75 | if (imval IS NULL) | ||
76 | { | ||
77 | printf("INTERNAL_WRAP: Failed to allocate temp array!"); | ||
78 | return(-1); | ||
79 | } | ||
80 | for (y_pos=y_im=0;y_pos<y_dim;y_pos++,y_im+=x_dim) | ||
81 | imval[y_pos] = (image+y_im); | ||
82 | |||
83 | for (res_pos=0, y_pos=y_start; /* TOP ROWS */ | ||
84 | y_pos<y_ctr_start; | ||
85 | y_pos+=y_step) | ||
86 | { | ||
87 | for (x_pos=x_start; | ||
88 | x_pos<x_ctr_start; | ||
89 | x_pos+=x_step, res_pos++) | ||
90 | INPROD(y_pos+y_dim, y_im%y_dim, x_pos+x_dim, x_im%x_dim) | ||
91 | |||
92 | for (; | ||
93 | x_pos<x_ctr_stop; | ||
94 | x_pos+=x_step, res_pos++) | ||
95 | INPROD(y_pos+y_dim, y_im%y_dim, x_pos, x_im) | ||
96 | |||
97 | for (; | ||
98 | x_pos<x_stop; | ||
99 | x_pos+=x_step, res_pos++) | ||
100 | INPROD(y_pos+y_dim, y_im%y_dim, x_pos, x_im%x_dim) | ||
101 | } /* end TOP ROWS */ | ||
102 | |||
103 | for (; /* MID ROWS */ | ||
104 | y_pos<y_ctr_stop; | ||
105 | y_pos+=y_step) | ||
106 | { | ||
107 | for (x_pos=x_start; | ||
108 | x_pos<x_ctr_start; | ||
109 | x_pos+=x_step, res_pos++) | ||
110 | INPROD(y_pos, y_im, x_pos+x_dim, x_im%x_dim) | ||
111 | |||
112 | for (; /* CENTER SECTION */ | ||
113 | x_pos<x_ctr_stop; | ||
114 | x_pos+=x_step, res_pos++) | ||
115 | INPROD(y_pos, y_im, x_pos, x_im) | ||
116 | |||
117 | for (; | ||
118 | x_pos<x_stop; | ||
119 | x_pos+=x_step, res_pos++) | ||
120 | INPROD(y_pos, y_im, x_pos, x_im%x_dim) | ||
121 | } /* end MID ROWS */ | ||
122 | |||
123 | for (; /* BOTTOM ROWS */ | ||
124 | y_pos<y_stop; | ||
125 | y_pos+=y_step) | ||
126 | { | ||
127 | for (x_pos=x_start; | ||
128 | x_pos<x_ctr_start; | ||
129 | x_pos+=x_step, res_pos++) | ||
130 | INPROD(y_pos, y_im%y_dim, x_pos+x_dim, x_im%x_dim) | ||
131 | |||
132 | for (; | ||
133 | x_pos<x_ctr_stop; | ||
134 | x_pos+=x_step, res_pos++) | ||
135 | INPROD(y_pos, y_im%y_dim, x_pos, x_im) | ||
136 | |||
137 | for (; | ||
138 | x_pos<x_stop; | ||
139 | x_pos+=x_step, res_pos++) | ||
140 | INPROD(y_pos, y_im%y_dim, x_pos, x_im%x_dim) | ||
141 | } /* end BOTTOM ROWS */ | ||
142 | |||
143 | free ((image_type **) imval); | ||
144 | |||
145 | return(0); | ||
146 | } /* end of internal_wrap_reduce */ | ||
147 | |||
148 | |||
149 | |||
150 | /* | ||
151 | -------------------------------------------------------------------- | ||
152 | Performs upsampling (padding with zeros) followed by convolution of | ||
153 | FILT with IMAGE (a.k.a. EXPAND in Burt&Adelson81). The operations | ||
154 | are combined to avoid unnecessary multiplication of filter samples | ||
155 | with zeros in the upsampled image. The convolution is done in 9 | ||
156 | sections so that mod operation is not performed unnecessarily. | ||
157 | Arguments are described in the comment above internal_wrap_reduce. | ||
158 | |||
159 | WARNING: this subroutine destructively modifes the RESULT image, so | ||
160 | the user must zero the result before invocation! | ||
161 | -------------------------------------------------------------------- */ | ||
162 | |||
163 | /* abstract out the inner product computation */ | ||
164 | #define INPROD2(YSTART,YIND,XSTART,XIND) \ | ||
165 | { \ | ||
166 | val = image[im_pos]; \ | ||
167 | for (y_res=YSTART, filt_pos=0, x_filt_stop=x_fdim; \ | ||
168 | x_filt_stop<=filt_size; \ | ||
169 | y_res++, x_filt_stop+=x_fdim) \ | ||
170 | for (x_res=XSTART; \ | ||
171 | filt_pos<x_filt_stop; \ | ||
172 | filt_pos++, x_res++) \ | ||
173 | imval[YIND][XIND] += val * filt[filt_pos]; \ | ||
174 | } | ||
175 | |||
176 | int internal_wrap_expand(image, filt, x_fdim, y_fdim, | ||
177 | x_start, x_step, x_stop, y_start, y_step, y_stop, | ||
178 | result, x_dim, y_dim) | ||
179 | register image_type *filt, *result; | ||
180 | register int x_fdim, y_fdim, x_dim, y_dim; | ||
181 | image_type *image; | ||
182 | int x_start, x_step, x_stop, y_start, y_step, y_stop; | ||
183 | { | ||
184 | register double val; | ||
185 | register int filt_size = x_fdim*y_fdim; | ||
186 | image_type **imval; | ||
187 | register int filt_pos, x_res, y_res, x_filt_stop; | ||
188 | register int x_pos, y_pos, im_pos; | ||
189 | int x_ctr_stop = x_dim - x_fdim + 1; | ||
190 | int y_ctr_stop = y_dim - y_fdim + 1; | ||
191 | int x_ctr_start = 0; | ||
192 | int y_ctr_start = 0; | ||
193 | int x_fmid = x_fdim/2; | ||
194 | int y_fmid = y_fdim/2; | ||
195 | |||
196 | /* shift start/stop coords to filter upper left hand corner */ | ||
197 | x_start -= x_fmid; y_start -= y_fmid; | ||
198 | x_stop -= x_fmid; y_stop -= y_fmid; | ||
199 | |||
200 | if (x_stop < x_ctr_stop) x_ctr_stop = x_stop; | ||
201 | if (y_stop < y_ctr_stop) y_ctr_stop = y_stop; | ||
202 | |||
203 | /* Set up pointer array for rows */ | ||
204 | imval = (image_type **) malloc(y_dim*sizeof(image_type *)); | ||
205 | if (imval IS NULL) | ||
206 | { | ||
207 | printf("INTERNAL_WRAP: Failed to allocate temp array!"); | ||
208 | return(-1); | ||
209 | } | ||
210 | for (y_pos=y_res=0;y_pos<y_dim;y_pos++,y_res+=x_dim) | ||
211 | imval[y_pos] = (result+y_res); | ||
212 | |||
213 | for (im_pos=0, y_pos=y_start; /* TOP ROWS */ | ||
214 | y_pos<y_ctr_start; | ||
215 | y_pos+=y_step) | ||
216 | { | ||
217 | for (x_pos=x_start; | ||
218 | x_pos<x_ctr_start; | ||
219 | x_pos+=x_step, im_pos++) | ||
220 | INPROD2(y_pos+y_dim, y_res%y_dim, x_pos+x_dim, x_res%x_dim) | ||
221 | |||
222 | for (; | ||
223 | x_pos<x_ctr_stop; | ||
224 | x_pos+=x_step, im_pos++) | ||
225 | INPROD2(y_pos+y_dim, y_res%y_dim, x_pos, x_res) | ||
226 | |||
227 | for (; | ||
228 | x_pos<x_stop; | ||
229 | x_pos+=x_step, im_pos++) | ||
230 | INPROD2(y_pos+y_dim, y_res%y_dim, x_pos, x_res%x_dim) | ||
231 | } /* end TOP ROWS */ | ||
232 | |||
233 | for (; /* MID ROWS */ | ||
234 | y_pos<y_ctr_stop; | ||
235 | y_pos+=y_step) | ||
236 | { | ||
237 | for (x_pos=x_start; | ||
238 | x_pos<x_ctr_start; | ||
239 | x_pos+=x_step, im_pos++) | ||
240 | INPROD2(y_pos, y_res, x_pos+x_dim, x_res%x_dim) | ||
241 | |||
242 | for (; /* CENTER SECTION */ | ||
243 | x_pos<x_ctr_stop; | ||
244 | x_pos+=x_step, im_pos++) | ||
245 | INPROD2(y_pos, y_res, x_pos, x_res) | ||
246 | |||
247 | for (; | ||
248 | x_pos<x_stop; | ||
249 | x_pos+=x_step, im_pos++) | ||
250 | INPROD2(y_pos, y_res, x_pos, x_res%x_dim) | ||
251 | } /* end MID ROWS */ | ||
252 | |||
253 | for (; /* BOTTOM ROWS */ | ||
254 | y_pos<y_stop; | ||
255 | y_pos+=y_step) | ||
256 | { | ||
257 | for (x_pos=x_start; | ||
258 | x_pos<x_ctr_start; | ||
259 | x_pos+=x_step, im_pos++) | ||
260 | INPROD2(y_pos, y_res%y_dim, x_pos+x_dim, x_res%x_dim) | ||
261 | |||
262 | for (; | ||
263 | x_pos<x_ctr_stop; | ||
264 | x_pos+=x_step, im_pos++) | ||
265 | INPROD2(y_pos, y_res%y_dim, x_pos, x_res) | ||
266 | |||
267 | for (; | ||
268 | x_pos<x_stop; | ||
269 | x_pos+=x_step, im_pos++) | ||
270 | INPROD2(y_pos, y_res%y_dim, x_pos, x_res%x_dim) | ||
271 | } /* end BOTTOM ROWS */ | ||
272 | |||
273 | free ((image_type **) imval); | ||
274 | return(0); | ||
275 | } /* end of internal_wrap_expand */ | ||
276 | |||
277 | |||
278 | |||
279 | /* Local Variables: */ | ||
280 | /* buffer-read-only: t */ | ||
281 | /* End: */ | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/README b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/README deleted file mode 100755 index 8f339f3..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/README +++ /dev/null | |||
@@ -1,55 +0,0 @@ | |||
1 | This package contains some MatLab tools for multi-scale image | ||
2 | processing. Briefly, the tools include: | ||
3 | - Recursive multi-scale image decompositions (pyramids), including | ||
4 | Laplacian pyramids, QMFs, Wavelets, and steerable pyramids. These | ||
5 | operate on 1D or 2D signals of arbitrary dimension. Data | ||
6 | structures are compatible with the MatLab wavelet toolbox. | ||
7 | - Fast 2D convolution routines, with subsampling and boundary-handling. | ||
8 | - Fast point-operations, histograms, histogram-matching. | ||
9 | - Fast synthetic image generation: sine gratings, zone plates, fractals, etc. | ||
10 | - Display routines for images and pyramids. These include several | ||
11 | auto-scaling options, rounding to integer zoom factors to avoid | ||
12 | resampling artifacts, and useful labeling (dimensions and gray-range). | ||
13 | |||
14 | The package is available as a gnu-zipped UNIX "tar" file, | ||
15 | accessible from the web page: | ||
16 | http://www.cns.nyu.edu/~lcv/software.html | ||
17 | |||
18 | The code works in Matlab versions 4.2 and higher, and has been fully tested | ||
19 | on Linux and Macintosh OSX platforms (it should, however, port easily to | ||
20 | others). To use the code (these lines are for UNIX): | ||
21 | 1) gunzip matlabPyrTools.tar.gz # unpack g'zipped file | ||
22 | 2) tar tvf matlabPyrTools.tar # view contents | ||
23 | 3) tar xvf matlabPyrTools.tar # extract contents | ||
24 | 4) rm matlabPyrTools.tar # delete tarfile | ||
25 | 5) Run matlab, and execute: | ||
26 | path(<pathname-of-matlabPyrTools>, path); | ||
27 | help matlabPyrTools | ||
28 | |||
29 | A few functions are actually MEX interfaces to C code. These are | ||
30 | contained in the subdirectory called MEX. The MEX files have been | ||
31 | tested on Sun (Solaris), LinuX on a Pentium platform, and Macintosh | ||
32 | OSX on a PowerPC, but should not be difficult to compile on most other | ||
33 | platforms. Source code is included in the MEX directory, as well as | ||
34 | Make files. I've included pre-compiled versions for a number of | ||
35 | platforms (Solaris,Linux,Mac,Windows). To make sure these are in your | ||
36 | matlab path, you can do *one* of the following: | ||
37 | 1) Create a symbolic link (or macintosh "alias") for the relavent files | ||
38 | in the main matlabPyrTools directory, or | ||
39 | 2) Copy the relavent files into the main matlabPyrTools directory, or | ||
40 | 3) Put the MEX subdirectory in your matlab path. | ||
41 | |||
42 | Some example script files showing usage of the code are in the | ||
43 | directory <dir>/TUTORIALS. There is a README file in that directory | ||
44 | describing the contents. | ||
45 | |||
46 | Incremental changes to the code are documented in the ChangeLog file. | ||
47 | |||
48 | Comments/Suggestions/Bugs to: | ||
49 | Eero P. Simoncelli | ||
50 | Associate Professor, | ||
51 | Center for Neural Science, and | ||
52 | Courant Institute for Mathematical Sciences | ||
53 | New York University | ||
54 | eero.simoncelli@nyu.edu | ||
55 | http://www.cns.nyu.edu/~eero/ | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/TUTORIALS/README b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/TUTORIALS/README deleted file mode 100755 index 06960a4..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/TUTORIALS/README +++ /dev/null | |||
@@ -1,18 +0,0 @@ | |||
1 | |||
2 | This directory contains some Matlab script files that serve to give | ||
3 | example usage of this code, and also to explain some of the | ||
4 | representations and algorithms. | ||
5 | |||
6 | The files are NOT meant to be executed from the MatLab prompt (like many | ||
7 | of the MatLab demos). You should instead read through the comments, | ||
8 | executing the subsequent pieces of code. This gives you a chance to | ||
9 | explore as you go... | ||
10 | |||
11 | matlabPyrTools.m - Example usage of the code in the distribution. | ||
12 | |||
13 | pyramids.m - An introduction to multi-scale pyramid representations, | ||
14 | covering Laplacian, QMF/Wavelet, and Steerable pyramids. The | ||
15 | file assumes a knowledge of linear systems, matrix algebra, | ||
16 | and 2D Fourier transforms. | ||
17 | |||
18 | more to come.... | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/TUTORIALS/matlabPyrTools.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/TUTORIALS/matlabPyrTools.m deleted file mode 100755 index 44c27ce..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/TUTORIALS/matlabPyrTools.m +++ /dev/null | |||
@@ -1,145 +0,0 @@ | |||
1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
2 | %%% Some examples using the tools in this distribution. | ||
3 | %%% Eero Simoncelli, 2/97. | ||
4 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
5 | |||
6 | %% Add directory to path (YOU'LL NEED TO ADJUST THIS): | ||
7 | path('/lcv/matlab/lib/matlabPyrTools',path); | ||
8 | |||
9 | %% Load an image, and downsample to a size appropriate for the machine speed. | ||
10 | oim = pgmRead('einstein.pgm'); | ||
11 | tic; corrDn(oim,[1 1; 1 1]/4,'reflect1',[2 2]); time = toc; | ||
12 | imSubSample = min(max(floor(log2(time)/2+3),0),2); | ||
13 | im = blurDn(oim, imSubSample,'qmf9'); | ||
14 | clear oim; | ||
15 | |||
16 | %%% ShowIm: | ||
17 | %% 3 types of automatic graylevel scaling, 2 types of automatic | ||
18 | %% sizing, with or without title and Range information. | ||
19 | help showIm | ||
20 | clf; showIm(im,'auto1','auto','Al') | ||
21 | clf; showIm('im','auto2') | ||
22 | clf; showIm(im,'auto3',2) | ||
23 | |||
24 | %%% Statistics: | ||
25 | mean2(im) | ||
26 | var2(im) | ||
27 | skew2(im) | ||
28 | kurt2(im) | ||
29 | entropy2(im) | ||
30 | imStats(im) | ||
31 | |||
32 | %%% Synthetic images. First pick some parameters: | ||
33 | sz = 200; | ||
34 | dir = 2*pi*rand(1) | ||
35 | slope = 10*rand(1)-5 | ||
36 | int = 10*rand(1)-5; | ||
37 | orig = round(1+(sz-1)*rand(2,1)); | ||
38 | expt = 0.8+rand(1) | ||
39 | ampl = 1+5*rand(1) | ||
40 | ph = 2*pi*rand(1) | ||
41 | per = 20 | ||
42 | twidth = 7 | ||
43 | |||
44 | clf; | ||
45 | showIm(mkRamp(sz,dir,slope,int,orig)); | ||
46 | showIm(mkImpulse(sz,orig,ampl)); | ||
47 | showIm(mkR(sz,expt,orig)); | ||
48 | showIm(mkAngle(sz,dir)); | ||
49 | showIm(mkDisc(sz,sz/4,orig,twidth)); | ||
50 | showIm(mkGaussian(sz,(sz/6)^2,orig,ampl)); | ||
51 | showIm(mkZonePlate(sz,ampl,ph)); | ||
52 | showIm(mkAngularSine(sz,3,ampl,ph,orig)); | ||
53 | showIm(mkSine(sz,per,dir,ampl,ph,orig)); | ||
54 | showIm(mkSquare(sz,per,dir,ampl,ph,orig,twidth)); | ||
55 | showIm(mkFract(sz,expt)); | ||
56 | |||
57 | |||
58 | %%% Point operations (lookup tables): | ||
59 | [Xtbl,Ytbl] = rcosFn(20, 25, [-1 1]); | ||
60 | plot(Xtbl,Ytbl); | ||
61 | showIm(pointOp(mkR(100,1,[70,30]), Ytbl, Xtbl(1), Xtbl(2)-Xtbl(1), 0)); | ||
62 | |||
63 | |||
64 | %%% histogram Modification/matching: | ||
65 | [N,X] = histo(im, 150); | ||
66 | [mn, mx] = range2(im); | ||
67 | matched = histoMatch(rand(size(im)), N, X); | ||
68 | showIm(im + sqrt(-1)*matched); | ||
69 | [Nm,Xm] = histo(matched,150); | ||
70 | nextFig(2,1); | ||
71 | subplot(1,2,1); plot(X,N); axis([mn mx 0 max(N)]); | ||
72 | subplot(1,2,2); plot(Xm,Nm); axis([mn mx 0 max(N)]); | ||
73 | nextFig(2,-1); | ||
74 | |||
75 | %%% Convolution routines: | ||
76 | |||
77 | %% Compare speed of convolution/downsampling routines: | ||
78 | noise = rand(400); filt = rand(10); | ||
79 | tic; res1 = corrDn(noise,filt(10:-1:1,10:-1:1),'reflect1',[2 2]); toc; | ||
80 | tic; ires = rconv2(noise,filt); res2 = ires(1:2:400,1:2:400); toc; | ||
81 | imStats(res1,res2) | ||
82 | |||
83 | %% Display image and extension of left and top boundaries: | ||
84 | fsz = [9 9]; | ||
85 | fmid = ceil((fsz+1)/2); | ||
86 | imsz = [16 16]; | ||
87 | |||
88 | % pick one: | ||
89 | im = eye(imsz); | ||
90 | im = mkRamp(imsz,pi/6); | ||
91 | im = mkSquare(imsz,6,pi/6); | ||
92 | |||
93 | % pick one: | ||
94 | edges='reflect1'; | ||
95 | edges='reflect2'; | ||
96 | edges='repeat'; | ||
97 | edges='extend'; | ||
98 | edges='zero'; | ||
99 | edges='circular'; | ||
100 | edges='dont-compute'; | ||
101 | |||
102 | filt = mkImpulse(fsz,[1 1]); | ||
103 | showIm(corrDn(im,filt,edges)); | ||
104 | line([0,0,imsz(2),imsz(2),0]+fmid(2)-0.5, ... | ||
105 | [0,imsz(1),imsz(1),0,0]+fmid(1)-0.5); | ||
106 | title(sprintf('Edges = %s',edges)); | ||
107 | |||
108 | %%% Multi-scale pyramids (see pyramids.m for more examples, | ||
109 | %%% and explanations): | ||
110 | |||
111 | %% A Laplacian pyramid: | ||
112 | [pyr,pind] = buildLpyr(im); | ||
113 | showLpyr(pyr,pind); | ||
114 | |||
115 | res = reconLpyr(pyr, pind); % full reconstruction | ||
116 | imStats(im,res); % essentially perfect | ||
117 | |||
118 | res = reconLpyr(pyr, pind, [2 3]); %reconstruct 2nd and 3rd levels only | ||
119 | showIm(res); | ||
120 | |||
121 | %% Wavelet/QMF pyramids: | ||
122 | filt = 'qmf9'; edges = 'reflect1'; | ||
123 | filt = 'haar'; edges = 'qreflect2'; | ||
124 | filt = 'qmf12'; edges = 'qreflect2'; | ||
125 | filt = 'daub3'; edges = 'circular'; | ||
126 | |||
127 | [pyr,pind] = buildWpyr(im, 5-imSubSample, filt, edges); | ||
128 | showWpyr(pyr,pind,'auto2'); | ||
129 | |||
130 | res = reconWpyr(pyr, pind, filt, edges); | ||
131 | clf; showIm(im + i*res); | ||
132 | imStats(im,res); | ||
133 | |||
134 | res = reconWpyr(pyr, pind, filt, edges, 'all', [2]); %vertical only | ||
135 | clf; showIm(res); | ||
136 | |||
137 | %% Steerable pyramid: | ||
138 | [pyr,pind] = buildSpyr(im,4-imSubSample,'sp3Filters'); | ||
139 | showSpyr(pyr,pind); | ||
140 | |||
141 | %% Steerable pyramid, constructed in frequency domain: | ||
142 | [pyr,pind] = buildSFpyr(im,5-imSubSample,4); %5 orientation bands | ||
143 | showSpyr(pyr,pind); | ||
144 | res = reconSFpyr(pyr,pind); | ||
145 | imStats(im,res); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/TUTORIALS/pyramids.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/TUTORIALS/pyramids.m deleted file mode 100755 index 2123c69..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/TUTORIALS/pyramids.m +++ /dev/null | |||
@@ -1,903 +0,0 @@ | |||
1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
2 | %%% IMAGE PYRAMID TUTORIAL | ||
3 | %%% | ||
4 | %%% A brief introduction to multi-scale pyramid decompositions for image | ||
5 | %%% processing. You should go through this, reading the comments, and | ||
6 | %%% executing the corresponding MatLab instructions. This file assumes | ||
7 | %%% a basic familiarity with matrix algebra, with linear systems and Fourier | ||
8 | %%% theory, and with MatLab. If you don't understand a particular | ||
9 | %%% function call, execute "help <functionName>" to see documentation. | ||
10 | %%% | ||
11 | %%% EPS, 6/96. | ||
12 | %%% Based on the original OBVIUS tutorial. | ||
13 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
14 | |||
15 | %% Determine a subsampling factor for images, based on machine speed: | ||
16 | oim = pgmRead('einstein.pgm'); | ||
17 | tic; corrDn(oim,[1 1; 1 1]/4,'reflect1',[2 2]); time = toc; | ||
18 | imSubSample = min(max(floor(log2(time)/2+3),0),2); | ||
19 | im = blurDn(oim, imSubSample,'qmf9'); | ||
20 | clear oim; | ||
21 | clf; showIm(im, 'auto2', 'auto', 'im'); | ||
22 | |||
23 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
24 | |||
25 | %%% LAPLACIAN PYRAMIDS: | ||
26 | |||
27 | %% Images may be decomposed into information at different scales. | ||
28 | %% Blurring eliminates the fine scales (detail): | ||
29 | |||
30 | binom5 = binomialFilter(5); | ||
31 | lo_filt = binom5*binom5'; | ||
32 | blurred = rconv2(im,lo_filt); | ||
33 | subplot(1,2,1); showIm(im, 'auto2', 'auto', 'im'); | ||
34 | subplot(1,2,2); showIm(blurred, 'auto2', 'auto', 'blurred'); | ||
35 | |||
36 | %% Subtracting the blurred image from the original leaves ONLY the | ||
37 | %% fine scale detail: | ||
38 | fine0 = im - blurred; | ||
39 | subplot(1,2,1); showIm(fine0, 'auto2', 'auto', 'fine0'); | ||
40 | |||
41 | %% The blurred and fine images contain all the information found in | ||
42 | %% the original image. Trivially, adding the blurred image to the | ||
43 | %% fine scale detail will reconstruct the original. We can compare | ||
44 | %% the original image to the sum of blurred and fine using the | ||
45 | %% "imStats" function, which reports on the statistics of the | ||
46 | %% difference between it's arguments: | ||
47 | imStats(im, blurred+fine0); | ||
48 | |||
49 | %% Since the filter is a lowpass filter, we might want to subsample | ||
50 | %% the blurred image. This may cause some aliasing (depends on the | ||
51 | %% filter), but the decomposition structure given above will still be | ||
52 | %% possible. The corrDn function correlates (same as convolution, but | ||
53 | %% flipped filter) and downsamples in a single operation (for | ||
54 | %% efficiency). The string 'reflect1' tells the function to handle | ||
55 | %% boundaries by reflecting the image about the edge pixels. Notice | ||
56 | %% that the blurred1 image is half the size (in each dimension) of the | ||
57 | %% original image. | ||
58 | lo_filt = 2*binom5*binom5'; %construct a separable 2D filter | ||
59 | blurred1 = corrDn(im,lo_filt,'reflect1',[2 2]); | ||
60 | subplot(1,2,2); showIm(blurred1,'auto2','auto','blurred1'); | ||
61 | |||
62 | %% Now, to extract fine scale detail, we must interpolate the image | ||
63 | %% back up to full size before subtracting it from the original. The | ||
64 | %% upConv function does upsampling (padding with zeros between | ||
65 | %% samples) followed by convolution. This can be done using the | ||
66 | %% lowpass filter that was applied before subsampling or it can be | ||
67 | %% done with a different filter. | ||
68 | fine1 = im - upConv(blurred1,lo_filt,'reflect1',[2 2],[1 1],size(im)); | ||
69 | subplot(1,2,1); showIm(fine1,'auto2','auto','fine1'); | ||
70 | |||
71 | %% We now have a technique that takes an image, computes two new | ||
72 | %% images (blurred1 and fine1) containing the coarse scale information | ||
73 | %% and the fine scale information. We can also (trivially) | ||
74 | %% reconstruct the original from these two (even if the subsampling of | ||
75 | %% the blurred1 image caused aliasing): | ||
76 | |||
77 | recon = fine1 + upConv(blurred1,lo_filt,'reflect1',[2 2],[1 1],size(im)); | ||
78 | imStats(im, recon); | ||
79 | |||
80 | %% Thus, we have described an INVERTIBLE linear transform that maps an | ||
81 | %% input image to the two images blurred1 and fine1. The inverse | ||
82 | %% transformation maps blurred1 and fine1 to the result. This is | ||
83 | %% depicted graphically with a system diagram: | ||
84 | %% | ||
85 | %% IM --> blur/down2 ---------> BLURRED1 --> up2/blur --> add --> RECON | ||
86 | %% | | ^ | ||
87 | %% | | | | ||
88 | %% | V | | ||
89 | %% | up2/blur | | ||
90 | %% | | | | ||
91 | %% | | | | ||
92 | %% | V | | ||
93 | %% --------------> subtract --> FINE1 ------------------- | ||
94 | %% | ||
95 | %% Note that the number of samples in the representation (i.e., total | ||
96 | %% samples in BLURRED1 and FINE1) is 1.5 times the number of samples | ||
97 | %% in the original IM. Thus, this representation is OVERCOMPLETE. | ||
98 | |||
99 | %% Often, we will want further subdivisions of scale. We can | ||
100 | %% decompose the (coarse-scale) BLURRED1 image into medium coarse and | ||
101 | %% very coarse images by applying the same splitting technique: | ||
102 | blurred2 = corrDn(blurred1,lo_filt,'reflect1',[2 2]); | ||
103 | showIm(blurred2) | ||
104 | |||
105 | fine2 = blurred1 - upConv(blurred2,lo_filt,'reflect1',[2 2],[1 1],size(blurred1)); | ||
106 | showIm(fine2) | ||
107 | |||
108 | %% Since blurred2 and fine2 can be used to reconstruct blurred1, and | ||
109 | %% blurred1 and fine1 can be used to reconstruct the original image, | ||
110 | %% the set of THREE images (also known as "subbands") {blurred2, | ||
111 | %% fine2, fine1} constitute a complete representation of the original | ||
112 | %% image. Note that the three subbands are displayed at the same size, | ||
113 | %% but they are actually three different sizes. | ||
114 | |||
115 | subplot(1,3,1); showIm(fine1,'auto2',2^(imSubSample-1),'fine1'); | ||
116 | subplot(1,3,2); showIm(fine2,'auto2',2^(imSubSample),'fine2'); | ||
117 | subplot(1,3,3); showIm(blurred2,'auto2',2^(imSubSample+1),'blurred2'); | ||
118 | |||
119 | %% It is useful to consider exactly what information is stored in each | ||
120 | %% of the pyramid subbands. The reconstruction process involves | ||
121 | %% recursively interpolating these images and then adding them to the | ||
122 | %% image at the next finer scale. To see the contribution of ONE of | ||
123 | %% the representation images (say blurred2) to the reconstruction, we | ||
124 | %% imagine filling all the other subbands with zeros and then | ||
125 | %% following our reconstruction procedure. For the blurred2 subband, | ||
126 | %% this is equivalent to simply calling upConv twice: | ||
127 | blurred2_full = upConv(upConv(blurred2,lo_filt,'reflect1',[2 2],[1 1],size(blurred1)),... | ||
128 | lo_filt,'reflect1',[2 2],[1 1],size(im)); | ||
129 | subplot(1,3,3); showIm(blurred2_full,'auto2',2^(imSubSample-1),'blurred2-full'); | ||
130 | |||
131 | %% For the fine2 subband, this is equivalent to calling upConv once: | ||
132 | fine2_full = upConv(fine2,lo_filt,'reflect1',[2 2],[1 1],size(im)); | ||
133 | subplot(1,3,2); showIm(fine2_full,'auto2',2^(imSubSample-1),'fine2-full'); | ||
134 | |||
135 | %% If we did everything correctly, we should be able to add together | ||
136 | %% these three full-size images to reconstruct the original image: | ||
137 | recon = blurred2_full + fine2_full + fine1; | ||
138 | imStats(im, recon) | ||
139 | |||
140 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
141 | |||
142 | %%% FUNCTIONS for CONSTRUCTING/MANIPULATING LAPLACIAN PYRAMIDS | ||
143 | |||
144 | %% We can continue this process, recursively splitting off finer and | ||
145 | %% finer details from the blurred image (like peeling off the outer | ||
146 | %% layers of an onion). The resulting data structure is known as a | ||
147 | %% "Laplacian Pyramid". To make things easier, we have written a | ||
148 | %% MatLab function called buildLpyr to construct this object. The | ||
149 | %% function returns two items: a long vector containing the subbands | ||
150 | %% of the pyramid, and an index matrix that is used to access these | ||
151 | %% subbands. The display routine showLpyr shows all the subbands of the | ||
152 | %% pyramid, at the their correct relative sizes. It should now be | ||
153 | %% clearer why these data structures are called "pyramids". | ||
154 | [pyr,pind] = buildLpyr(im,5-imSubSample); | ||
155 | showLpyr(pyr,pind); | ||
156 | |||
157 | %% There are also "accessor" functions for pulling out a single subband: | ||
158 | showIm(pyrBand(pyr,pind,2)); | ||
159 | |||
160 | %% The reconLpyr function allows you to reconstruct from a laplacian pyramid. | ||
161 | %% The third (optional) arg allows you to select any subset of pyramid bands | ||
162 | %% (default is to use ALL of them). | ||
163 | clf; showIm(reconLpyr(pyr,pind,[1 3]),'auto2','auto','bands 1 and 3 only'); | ||
164 | |||
165 | fullres = reconLpyr(pyr,pind); | ||
166 | showIm(fullres,'auto2','auto','Full reconstruction'); | ||
167 | imStats(im,fullres); | ||
168 | |||
169 | %% buildLpyr uses 5-tap filters by default for building Laplacian | ||
170 | %% pyramids. You can specify other filters: | ||
171 | namedFilter('binom3') | ||
172 | [pyr3,pind3] = buildLpyr(im,5-imSubSample,'binom3'); | ||
173 | showLpyr(pyr3,pind3); | ||
174 | fullres3 = reconLpyr(pyr3,pind3,'all','binom3'); | ||
175 | imStats(im,fullres3); | ||
176 | |||
177 | %% Here we build a "Laplacian" pyramid using random filters. filt1 is | ||
178 | %% used with the downsampling operations and filt2 is used with the | ||
179 | %% upsampling operations. We normalize the filters for display | ||
180 | %% purposes. Of course, these filters are (almost certainly) not very | ||
181 | %% "Gaussian", and the subbands of such a pyramid will be garbage! | ||
182 | %% Nevertheless, it is a simple property of the Laplacian pyramid that | ||
183 | %% we can use ANY filters and we will still be able to reconstruct | ||
184 | %% perfectly. | ||
185 | |||
186 | filt1 = rand(1,5); filt1 = sqrt(2)*filt1/sum(filt1) | ||
187 | filt2 = rand(1,3); filt2 = sqrt(2)*filt2/sum(filt2) | ||
188 | [pyrr,pindr] = buildLpyr(im,5-imSubSample,filt1,filt2); | ||
189 | showLpyr(pyrr,pindr); | ||
190 | fullresr = reconLpyr(pyrr,pindr,'all',filt2); | ||
191 | imStats(im,fullresr); | ||
192 | |||
193 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
194 | |||
195 | %%% ALIASING in the Gaussian and Laplacian pyramids: | ||
196 | |||
197 | %% Unless one is careful, the subsampling operations will introduce aliasing | ||
198 | %% artifacts in these pyramid transforms. This is true even though the | ||
199 | %% Laplacian pyramid can be used to reconstruct the original image perfectly. | ||
200 | %% When reconstructing, the pyramid is designed in such a way that these | ||
201 | %% aliasing artifacts cancel out. So it's not a problem if the only thing we | ||
202 | %% want to do is reconstruct. However, it can be a serious problem if we | ||
203 | %% intend to process each of the subbands independently. | ||
204 | |||
205 | %% One way to see the consequences of the aliasing artifacts is by | ||
206 | %% examining variations that occur when the input is shifted. We | ||
207 | %% choose an image and shift it by some number of pixels. Then blur | ||
208 | %% (filter-downsample-upsample-filter) the original image and blur the | ||
209 | %% shifted image. If there's no aliasing, then the blur and shift | ||
210 | %% operations should commute (i.e., | ||
211 | %% shift-filter-downsample-upsample-filter is the same as | ||
212 | %% filter-downsample-upsample-filter-shift). Try this for 2 different | ||
213 | %% filters (by replacing 'binom3' with 'binom5' or 'binom7' below), | ||
214 | %% and you'll see that the aliasing is much worse for the 3 tap | ||
215 | %% filter. | ||
216 | |||
217 | sig = 100*randn([1 16]); | ||
218 | sh = [0 7]; %shift amount | ||
219 | lev = 2; % level of pyramid to look at | ||
220 | flt = 'binom3'; %filter to use: | ||
221 | |||
222 | shiftIm = shift(sig,sh); | ||
223 | [pyr,pind] = buildLpyr(shiftIm, lev, flt, flt, 'circular'); | ||
224 | shiftBlur = reconLpyr(pyr, pind, lev, flt, 'circular'); | ||
225 | |||
226 | [pyr,pind] = buildLpyr(sig, lev, flt, flt, 'circular'); | ||
227 | res = reconLpyr(pyr, pind, lev, flt, 'circular'); | ||
228 | blurShift = shift(res,sh); | ||
229 | |||
230 | subplot(2,1,1); r = showIm(shiftBlur,'auto2','auto','shiftBlur'); | ||
231 | subplot(2,1,2); showIm(blurShift,r,'auto','blurShift'); | ||
232 | imStats(blurShift,shiftBlur); | ||
233 | |||
234 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
235 | |||
236 | %%% PROJECTION and BASIS functions: | ||
237 | |||
238 | %% An invertible, linear transform can be characterized in terms | ||
239 | %% of a set of PROJECTION and BASIS functions. In matlab matrix | ||
240 | %% notation: | ||
241 | % | ||
242 | %% c = P' * x | ||
243 | %% x = B * c | ||
244 | % | ||
245 | %% where x is an input, c are the transform coefficients, P and B | ||
246 | %% are matrices. The columns of P are the projection functions (the | ||
247 | %% input is projected onto the the columns of P to get each successive | ||
248 | %% transform coefficient). The columns of B are the basis | ||
249 | %% functions (x is a linear combination of the columns of B). | ||
250 | |||
251 | %% Since the Laplacian pyramid is a linear transform, we can ask: what | ||
252 | %% are its BASIS functions? We consider these in one dimension for | ||
253 | %% simplicity. The BASIS function corresponding to a given | ||
254 | %% coefficient tells us how much that coefficient contributes to each | ||
255 | %% pixel in the reconstructed image. We can construct a single basis | ||
256 | %% function by setting one sample of one subband equal to 1.0 (and all | ||
257 | %% others to zero) and reconstructing. To build the entire matrix, we | ||
258 | %% have to do this for every sample of every subband: | ||
259 | sz = min(round(48/(sqrt(2)^imSubSample)),36); | ||
260 | sig = zeros(sz,1); | ||
261 | [pyr,pind] = buildLpyr(sig); | ||
262 | basis = zeros(sz,size(pyr,1)); | ||
263 | for n=1:size(pyr,1) | ||
264 | pyr = zeros(size(pyr)); | ||
265 | pyr(n) = 1; | ||
266 | basis(:,n) = reconLpyr(pyr,pind); | ||
267 | end | ||
268 | clf; showIm(basis) | ||
269 | |||
270 | %% The columns of the basis matrix are the basis functions. The | ||
271 | %% matrix is short and fat, corresponding to the fact that the | ||
272 | %% representation is OVERCOMPLETE. Below, we plot the middle one from | ||
273 | %% each subband, starting with the finest scale. Note that all of | ||
274 | %% these basis functions are lowpass (Gaussian-like) functions. | ||
275 | locations = round(sz * (2 - 3./2.^[1:max(4,size(pind,1))]))+1; | ||
276 | for lev=1:size(locations,2) | ||
277 | subplot(2,2,lev); | ||
278 | showIm(basis(:,locations(lev))); | ||
279 | axis([0 sz 0 1.1]); | ||
280 | end | ||
281 | |||
282 | %% Now, we'd also like see the inverse (we'll them PROJECTION) | ||
283 | %% functions. We need to ask how much of each sample of the input | ||
284 | %% image contributes to a given pyramid coefficient. Thus, the matrix | ||
285 | %% is constructed by building pyramids on the set of images with | ||
286 | %% impulses at each possible location. The rows of this matrix are | ||
287 | %% the projection functions. | ||
288 | projection = zeros(size(pyr,1),sz); | ||
289 | for pos=1:sz | ||
290 | [pyr,pind] = buildLpyr(mkImpulse([1 sz], [1 pos])); | ||
291 | projection(:,pos) = pyr; | ||
292 | end | ||
293 | clf; showIm(projection); | ||
294 | |||
295 | %% Building a pyramid corresponds to multiplication by the projection | ||
296 | %% matrix. Reconstructing from this pyramid corresponds to | ||
297 | %% multiplication by the basis matrix. Thus, the product of the two | ||
298 | %% matrices (in this order) should be the identity matrix: | ||
299 | showIm(basis*projection); | ||
300 | |||
301 | %% We can plot a few example projection functions at different scales. | ||
302 | %% Note that all of the projection functions are bandpass functions, | ||
303 | %% except for the coarsest subband which is lowpass. | ||
304 | for lev=1:size(locations,2) | ||
305 | subplot(2,2,lev); | ||
306 | showIm(projection(locations(lev),:)); | ||
307 | axis([0 sz -0.3 0.8]); | ||
308 | end | ||
309 | |||
310 | %% Now consider the frequency response of these functions, plotted over the | ||
311 | %% range [-pi,pi]: | ||
312 | for lev=1:size(locations,2) | ||
313 | subplot(2,2,lev); | ||
314 | proj = projection(locations(lev),:); | ||
315 | plot(pi*[-32:31]/32,fftshift(abs(fft(proj',64)))); | ||
316 | axis([-pi pi -0.1 3]); | ||
317 | end | ||
318 | |||
319 | %% The first projection function is highpass, and the second is bandpass. Both | ||
320 | %% of these look something like the Laplacian (2nd derivative) of a Gaussian. | ||
321 | %% The last is lowpass, as are the basis functions. Thus, the basic operation | ||
322 | %% used to create each level of the pyramid involves a simple highpass/lowpass | ||
323 | %% split. | ||
324 | |||
325 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
326 | |||
327 | %%% QMF/WAVELET PYRAMIDS. | ||
328 | |||
329 | %% Two things about Laplacian pyramids are a bit unsatisfactory. | ||
330 | %% First, there are more pixels (coefficients) in the representation | ||
331 | %% than in the original image. Specifically, the 1-dimensional | ||
332 | %% transform is overcomplete by a factor of 4/3, and the 2-dimensional | ||
333 | %% transform is overcomplete by a factor of 2. Secondly, the | ||
334 | %% "bandpass" images (fineN) do not segregate information according to | ||
335 | %% orientation. | ||
336 | |||
337 | %% There are other varieties of pyramid. One type that arose in the | ||
338 | %% speech coding community is based on a particular pairs of filters | ||
339 | %% known as a "Quadrature Mirror Filters" or QMFs. These are closely | ||
340 | %% related to Wavelets (essentially, they are approximate wavelet | ||
341 | %% filters). | ||
342 | |||
343 | %% Recall that the Laplacian pyramid is formed by simple hi/low | ||
344 | %% splitting at each level. The lowpass band is subsampled by a | ||
345 | %% factor of 2, but the highpass band is NOT subsampled. In the QMF | ||
346 | %% pyramid, we apply two filters (hi- and lo- pass) and subsample BOTH | ||
347 | %% by a factor of 2, thus eliminating the excess coefficients of the | ||
348 | %% Laplacian pyramid. | ||
349 | |||
350 | %% The two filters must have a specific relationship to each | ||
351 | %% other. In particular, let n be an index for the filter samples. | ||
352 | %% The highpass filter may be constructed from the lowpass filter by | ||
353 | %% (1) modulating (multiplying) by (-1)^n (equivalent to shifting by | ||
354 | %% pi in the Fourier domain), (2) flipping (i.e., reversing the order | ||
355 | %% of the taps), (3) spatially shifting by one sample. Try to | ||
356 | %% convince yourself that the resulting filters will always be | ||
357 | %% orthogonal to each other (i.e., their inner products will be zero) | ||
358 | %% when shifted by any multiple of two. | ||
359 | |||
360 | %% The function modulateFlip performs the first two of these operations. The | ||
361 | %% third (spatial shifting) step is built into the convolution code. | ||
362 | flo = namedFilter('qmf9')'; | ||
363 | fhi = modulateFlip(flo)'; | ||
364 | subplot(2,1,1); lplot(flo); axis([0 10 -0.5 1.0]); title('lowpass'); | ||
365 | subplot(2,1,2); lplot(fhi); axis([0 10 -0.5 1.0]); title('highpass'); | ||
366 | |||
367 | %% In the Fourier domain, these filters are (approximately) | ||
368 | %% "power-complementary": the sum of their squared power spectra is | ||
369 | %% (approximately) a constant. But note that neither is a perfect | ||
370 | %% bandlimiter (i.e., a sinc function), and thus subsampling by a | ||
371 | %% factor of 2 will cause aliasing in each of the subbands. See below | ||
372 | %% for a discussion of the effect of this aliasing. | ||
373 | |||
374 | %% Plot the two frequency responses: | ||
375 | freq = pi*[-32:31]/32; | ||
376 | subplot(2,1,1); | ||
377 | plot(freq,fftshift(abs(fft(flo,64))),'--',freq,fftshift(abs(fft(fhi,64))),'-'); | ||
378 | axis([-pi pi 0 1.5]); title('FFT magnitudes'); | ||
379 | subplot(2,1,2); | ||
380 | plot(freq,fftshift(abs(fft(flo,64)).^2)+fftshift(abs(fft(fhi,64)).^2)); | ||
381 | axis([-pi pi 0 2.2]); title('Sum of squared magnitudes'); | ||
382 | |||
383 | %% We can split an input signal into two bands as follows: | ||
384 | sig = mkFract([1,64],1.6); | ||
385 | subplot(2,1,1); showIm(sig,'auto1','auto','sig'); | ||
386 | lo1 = corrDn(sig,flo,'reflect1',[1 2],[1 1]); | ||
387 | hi1 = corrDn(sig,fhi,'reflect1',[1 2],[1 2]); | ||
388 | subplot(2,1,2); | ||
389 | showIm(lo1,'auto1','auto','low and high bands'); hold on; plot(hi1,'--r'); hold off; | ||
390 | |||
391 | %% Notice that the two subbands are half the size of the original | ||
392 | %% image, due to the subsampling by a factor of 2. One subtle point: | ||
393 | %% the highpass and lowpass bands are subsampled on different | ||
394 | %% lattices: the lowpass band retains the odd-numbered samples and the | ||
395 | %% highpass band retains the even-numbered samples. This was the | ||
396 | %% 1-sample shift relating the high and lowpass kernels (mentioned | ||
397 | %% above). We've used the 'reflect1' to handle boundaries, which | ||
398 | %% works properly for symmetric odd-length QMFs. | ||
399 | |||
400 | %% We can reconstruct the original image by interpolating these two subbands | ||
401 | %% USING THE SAME FILTERS: | ||
402 | reconlo = upConv(lo1,flo,'reflect1',[1 2]); | ||
403 | reconhi = upConv(hi1,fhi,'reflect1',[1 2],[1 2]); | ||
404 | subplot(2,1,2); showIm(reconlo+reconhi,'auto1','auto','reconstructed'); | ||
405 | imStats(sig,reconlo+reconhi); | ||
406 | |||
407 | %% We have described an INVERTIBLE linear transform that maps an input | ||
408 | %% image to the two images lo1 and hi1. The inverse transformation | ||
409 | %% maps these two images to the result. This is depicted graphically | ||
410 | %% with a system diagram: | ||
411 | %% | ||
412 | %% IM ---> flo/down2 --> LO1 --> up2/flo --> add --> RECON | ||
413 | %% | ^ | ||
414 | %% | | | ||
415 | %% | | | ||
416 | %% -> fhi/down2 --> HI1 --> up2/fhi ----- | ||
417 | %% | ||
418 | %% Note that the number of samples in the representation (i.e., total | ||
419 | %% samples in LO1 and HI1) is equal to the number of samples in the | ||
420 | %% original IM. Thus, this representation is exactly COMPLETE, or | ||
421 | %% "critically sampled". | ||
422 | |||
423 | %% So we've fixed one of the problems that we had with Laplacian | ||
424 | %% pyramid. But the system diagram above places strong constraints on | ||
425 | %% the filters. In particular, for these filters the reconstruction | ||
426 | %% is no longer perfect. Turns out there are NO | ||
427 | %% perfect-reconstruction symmetric filters that are | ||
428 | %% power-complementary, except for the trivial case [1] and the | ||
429 | %% nearly-trivial case [1 1]/sqrt(2). | ||
430 | |||
431 | %% Let's consider the projection functions of this 2-band splitting | ||
432 | %% operation. We can construct these by applying the transform to | ||
433 | %% impulse input signals, for all possible impulse locations. The | ||
434 | %% rows of the following matrix are the projection functions for each | ||
435 | %% coefficient in the transform. | ||
436 | M = [corrDn(eye(32),flo','circular',[1 2]), ... | ||
437 | corrDn(eye(32),fhi','circular',[1 2],[1 2])]'; | ||
438 | clf; showIm(M,'auto1','auto','M'); | ||
439 | |||
440 | %% The transform matrix is composed of two sub-matrices. The top half | ||
441 | %% contains the lowpass kernel, shifted by increments of 2 samples. | ||
442 | %% The bottom half contains the highpass. Now we compute the inverse | ||
443 | %% of this matrix: | ||
444 | M_inv = inv(M); | ||
445 | showIm(M_inv,'auto1','auto','M_inv'); | ||
446 | |||
447 | %% The inverse is (very close to) the transpose of the original | ||
448 | %% matrix! In other words, the transform is orthonormal. | ||
449 | imStats(M_inv',M); | ||
450 | |||
451 | %% This also points out a nice relationship between the corrDn and | ||
452 | %% upConv functions, and the matrix representation. corrDn is | ||
453 | %% equivalent to multiplication by a matrix with copies of the filter | ||
454 | %% on the ROWS, translated in multiples of the downsampling factor. | ||
455 | %% upConv is equivalent to multiplication by a matrix with copies of | ||
456 | %% the filter on the COLUMNS, translated by the upsampling factor. | ||
457 | |||
458 | %% As in the Laplacian pyramid, we can recursively apply this QMF | ||
459 | %% band-splitting operation to the lowpass band: | ||
460 | lo2 = corrDn(lo1,flo,'reflect1',[1 2]); | ||
461 | hi2 = corrDn(lo1,fhi,'reflect1',[1 2],[1 2]); | ||
462 | |||
463 | %% The representation of the original signal is now comprised of the | ||
464 | %% three subbands {hi1, hi2, lo2} (we don't hold onto lo1, because it | ||
465 | %% can be reconstructed from lo2 and hi2). Note that hi1 is at 1/2 | ||
466 | %% resolution, and hi2 and lo2 are at 1/4 resolution: The total number | ||
467 | %% of samples in these three subbands is thus equal to the number of | ||
468 | %% samples in the original signal. | ||
469 | imnames=['hi1'; 'hi2'; 'lo2']; | ||
470 | for bnum=1:3 | ||
471 | band = eval(imnames(bnum,:)); | ||
472 | subplot(3,1,bnum); showIm(band); ylabel(imnames(bnum,:)); | ||
473 | axis([1 size(band,2) 1.1*min(lo2) 1.1*max(lo2)]); | ||
474 | end | ||
475 | |||
476 | %% Reconstruction proceeds as with the Laplacian pyramid: combine lo2 and hi2 | ||
477 | %% to reconstruct lo1, which is then combined with hi1 to reconstruct the | ||
478 | %% original signal: | ||
479 | recon_lo1 = upConv(hi2,fhi,'reflect1',[1 2],[1 2]) + ... | ||
480 | upConv(lo2,flo,'reflect1',[1 2],[1 1]); | ||
481 | reconstructed = upConv(hi1,fhi,'reflect1',[1 2],[1 2]) + ... | ||
482 | upConv(recon_lo1,flo,'reflect1',[1 2],[1 1]); | ||
483 | imStats(sig,reconstructed); | ||
484 | |||
485 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
486 | |||
487 | %%% FUNCTIONS for CONSTRUCTING/MANIPULATING QMF/Wavelet PYRAMIDS | ||
488 | |||
489 | %% To make things easier, we have bundled these qmf operations and | ||
490 | %% data structures into an object in MATLAB. | ||
491 | |||
492 | sig = mkFract([1 64], 1.5); | ||
493 | [pyr,pind] = buildWpyr(sig); | ||
494 | showWpyr(pyr,pind); | ||
495 | |||
496 | nbands = size(pind,1); | ||
497 | for b = 1:nbands | ||
498 | subplot(nbands,1,b); lplot(pyrBand(pyr,pind,b)); | ||
499 | end | ||
500 | |||
501 | res = reconWpyr(pyr,pind); | ||
502 | imStats(sig,res); | ||
503 | |||
504 | %% Now for 2D, we use separable filters. There are 4 ways to apply the two | ||
505 | %% filters to the input image (followed by the relavent subsampling operation): | ||
506 | %% (1) lowpass in both x and y | ||
507 | %% (2) lowpass in x and highpass in y | ||
508 | %% (3) lowpass in y and highpass in x | ||
509 | %% (4) highpass in both x and y. | ||
510 | %% The pyramid is built by recursively subdividing the first of these bands | ||
511 | %% into four new subbands. | ||
512 | |||
513 | %% First, we'll take a look at some of the basis functions. | ||
514 | sz = 40; | ||
515 | zim = zeros(sz); | ||
516 | flo = 'qmf9'; edges = 'reflect1'; | ||
517 | [pyr,pind] = buildWpyr(zim); | ||
518 | |||
519 | % Put an impulse into the middle of each band: | ||
520 | for lev=1:size(pind,1) | ||
521 | mid = sum(prod(pind(1:lev-1,:)')); | ||
522 | mid = mid + floor(pind(lev,2)/2)*pind(lev,1) + floor(pind(lev,1)/2) + 1; | ||
523 | pyr(mid,1) = 1; | ||
524 | end | ||
525 | |||
526 | % And take a look at the reconstruction of each band: | ||
527 | for lnum=1:wpyrHt(pind)+1 | ||
528 | for bnum=1:3 | ||
529 | subplot(wpyrHt(pind)+1,3,(wpyrHt(pind)+1-lnum)*3+bnum); | ||
530 | showIm(reconWpyr(pyr, pind, flo, edges, lnum, bnum),'auto1',2,0); | ||
531 | end | ||
532 | end | ||
533 | |||
534 | %% Note that the first column contains horizontally oriented basis functions at | ||
535 | %% different scales. The second contains vertically oriented basis functions. | ||
536 | %% The third contains both diagonals (a checkerboard pattern). The bottom row | ||
537 | %% shows (3 identical images of) a lowpass basis function. | ||
538 | |||
539 | %% Now look at the corresponding Fourier transform magnitudes (these | ||
540 | %% are plotted over the frequency range [-pi, pi] ): | ||
541 | nextFig(2,1); | ||
542 | freq = 2 * pi * [-sz/2:(sz/2-1)]/sz; | ||
543 | for lnum=1:wpyrHt(pind)+1 | ||
544 | for bnum=1:3 | ||
545 | subplot(wpyrHt(pind)+1,3,(wpyrHt(pind)+1-lnum)*3+bnum); | ||
546 | basisFn = reconWpyr(pyr, pind, flo, edges, lnum, bnum); | ||
547 | basisFmag = fftshift(abs(fft2(basisFn,sz,sz))); | ||
548 | imagesc(freq,freq,basisFmag); | ||
549 | axis('square'); axis('xy'); colormap('gray'); | ||
550 | end | ||
551 | end | ||
552 | nextFig(2,-1); | ||
553 | |||
554 | %% The filters at a given scale sum to a squarish annular region: | ||
555 | sumSpectra = zeros(sz); | ||
556 | lnum = 2; | ||
557 | for bnum=1:3 | ||
558 | basisFn = reconWpyr(pyr, pind, flo, edges, lnum, bnum); | ||
559 | basisFmag = fftshift(abs(fft2(basisFn,sz,sz))); | ||
560 | sumSpectra = basisFmag.^2 + sumSpectra; | ||
561 | end | ||
562 | clf; imagesc(freq,freq,sumSpectra); axis('square'); axis('xy'); title('one scale'); | ||
563 | |||
564 | %% Now decompose an image: | ||
565 | [pyr,pind] = buildWpyr(im); | ||
566 | |||
567 | %% View all of the subbands (except lowpass), scaled to be the same size | ||
568 | %% (requires a big figure window): | ||
569 | nlevs = wpyrHt(pind); | ||
570 | for lnum=1:nlevs | ||
571 | for bnum=1:3 | ||
572 | subplot(nlevs,3,(lnum-1)*3+bnum); | ||
573 | showIm(wpyrBand(pyr,pind,lnum,bnum), 'auto2', 2^(lnum+imSubSample-2)); | ||
574 | end | ||
575 | end | ||
576 | |||
577 | %% In addition to the bands shown above, there's a lowpass residual: | ||
578 | nextFig(2,1); | ||
579 | clf; showIm(pyrLow(pyr,pind)); | ||
580 | nextFig(2,-1); | ||
581 | |||
582 | % Alternatively, display the pyramid with the subbands shown at their | ||
583 | % correct relative sizes: | ||
584 | clf; showWpyr(pyr, pind); | ||
585 | |||
586 | %% The reconWpyr function can be used to reconstruct the entire pyramid: | ||
587 | reconstructed = reconWpyr(pyr,pind); | ||
588 | imStats(im,reconstructed); | ||
589 | |||
590 | %% As with Laplacian pyramids, you can specify sub-levels and subbands | ||
591 | %% to be included in the reconstruction. For example: | ||
592 | clf | ||
593 | showIm(reconWpyr(pyr,pind,'qmf9','reflect1',[1:wpyrHt(pind)],[1])); %Horizontal only | ||
594 | showIm(reconWpyr(pyr,pind,'qmf9','reflect1',[2,3])); %two middle scales | ||
595 | |||
596 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
597 | |||
598 | %%% PERFECT RECONSTRUCTION: HAAR AND DEBAUCHIES WAVELETS | ||
599 | |||
600 | %% The symmetric QMF filters used above are not perfectly orthogonal. | ||
601 | %% In fact, it's impossible to construct a symmetric filter of size | ||
602 | %% greater than 2 that is perfectly orthogonal to shifted copies | ||
603 | %% (shifted by multiples of 2) of itself. For example, consider a | ||
604 | %% symmetric kernel of length 3. Shift by two and the right end of | ||
605 | %% the original kernel is aligned with the left end of the shifted | ||
606 | %% one. Thus, the inner product of these two will be the square of | ||
607 | %% the end tap, which will be non-zero. | ||
608 | |||
609 | %% However, one can easily create wavelet filters of length 2 that | ||
610 | %% will do the job. This is the oldest known wavelet, known as the | ||
611 | %% "Haar". The two kernels are [1,1]/sqrt(2) and [1,-1]/sqrt(2). | ||
612 | %% These are trivially seen to be orthogonal to each other, and shifts | ||
613 | %% by multiples of two are also trivially orthogonal. The projection | ||
614 | %% functions of the Haar transform are in the rows of the following | ||
615 | %% matrix, constructed by applying the transform to impulse input | ||
616 | %% signals, for all possible impulse locations: | ||
617 | |||
618 | haarLo = namedFilter('haar') | ||
619 | haarHi = modulateFlip(haarLo) | ||
620 | subplot(2,1,1); lplot(haarLo); axis([0 3 -1 1]); title('lowpass'); | ||
621 | subplot(2,1,2); lplot(haarHi); axis([0 3 -1 1]); title('highpass'); | ||
622 | |||
623 | M = [corrDn(eye(32), haarLo, 'reflect1', [2 1], [2 1]); ... | ||
624 | corrDn(eye(32), haarHi, 'reflect1', [2 1], [2 1])]; | ||
625 | clf; showIm(M) | ||
626 | showIm(M*M') %identity! | ||
627 | |||
628 | %% As before, the filters are power-complementary (although the | ||
629 | %% frequency isolation is rather poor, and thus the subbands will be | ||
630 | %% heavily aliased): | ||
631 | plot(pi*[-32:31]/32,abs(fft(haarLo,64)).^2,'--',... | ||
632 | pi*[-32:31]/32,abs(fft(haarHi,64)).^2,'-'); | ||
633 | |||
634 | sig = mkFract([1,64],0.5); | ||
635 | [pyr,pind] = buildWpyr(sig,4,'haar','reflect1'); | ||
636 | showWpyr(pyr,pind); | ||
637 | |||
638 | %% check perfect reconstruction: | ||
639 | res = reconWpyr(pyr,pind, 'haar', 'reflect1'); | ||
640 | imStats(sig,res) | ||
641 | |||
642 | %% If you want perfect reconstruction, but don't like the Haar | ||
643 | %% transform, there's another option: drop the symmetry requirement. | ||
644 | %% Ingrid Daubechies developed one of the earliest sets of such | ||
645 | %% perfect-reconstruction wavelets. The simplest of these is of | ||
646 | %% length 4: | ||
647 | |||
648 | daub_lo = namedFilter('daub2'); | ||
649 | daub_hi = modulateFlip(daub_lo); | ||
650 | |||
651 | %% The daub_lo filter is constructed to be orthogonal to 2shifted | ||
652 | %% copy of itself. For example: | ||
653 | [daub_lo;0;0]'*[0;0;daub_lo] | ||
654 | |||
655 | M = [corrDn(eye(32), daub_lo, 'circular', [2 1], [2 1]); ... | ||
656 | corrDn(eye(32), daub_hi, 'circular', [2 1], [2 1])]; | ||
657 | clf; showIm(M) | ||
658 | showIm(M*M') % identity! | ||
659 | |||
660 | %% Again, they're power complementary: | ||
661 | plot(pi*[-32:31]/32,abs(fft(daub_lo,64)).^2,'--',... | ||
662 | pi*[-32:31]/32,abs(fft(daub_hi,64)).^2,'-'); | ||
663 | |||
664 | %% The sum of the power spectra is again flat | ||
665 | plot(pi*[-32:31]/32,... | ||
666 | fftshift(abs(fft(daub_lo,64)).^2)+fftshift(abs(fft(daub_hi,64)).^2)); | ||
667 | |||
668 | %% Make a pyramid using the same code as before (except that we can't | ||
669 | %% use reflected boundaries with asymmetric filters): | ||
670 | [pyr,pind] = buildWpyr(sig, maxPyrHt(size(sig),size(daub_lo)), daub_lo, 'circular'); | ||
671 | showWpyr(pyr,pind,'indep1'); | ||
672 | |||
673 | res = reconWpyr(pyr,pind, daub_lo,'circular'); | ||
674 | imStats(sig,res); | ||
675 | |||
676 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
677 | |||
678 | %%% ALIASING IN WAVELET TRANSFORMS | ||
679 | |||
680 | %% All of these orthonormal pyramid/wavelet transforms have a lot | ||
681 | %% of aliasing in the subbands. You can see that in the frequency | ||
682 | %% response plots since the frequency response of each filter | ||
683 | %% covers well more than half the frequency domain. The aliasing | ||
684 | %% can have serious consequences... | ||
685 | |||
686 | %% Get one of the basis functions of the 2D Daubechies wavelet transform: | ||
687 | [pyr,pind] = buildWpyr(zeros(1,64),4,daub_lo,'circular'); | ||
688 | lev = 3; | ||
689 | pyr(1+sum(pind(1:lev-1,2))+pind(lev,2)/2,1) = 1; | ||
690 | sig = reconWpyr(pyr,pind, daub_lo,'circular'); | ||
691 | clf; lplot(sig) | ||
692 | |||
693 | %% Since the basis functions are orthonormal, building a pyramid using this | ||
694 | %% input will yield a single non-zero coefficient. | ||
695 | [pyr,pind] = buildWpyr(sig, 4, daub_lo, 'circular'); | ||
696 | figure(1); | ||
697 | nbands = size(pind,1) | ||
698 | for b=1:nbands | ||
699 | subplot(nbands,1,b); lplot(pyrBand(pyr,pind,b)); | ||
700 | axis([1 size(pyrBand(pyr,pind,b),2) -0.3 1.3]); | ||
701 | end | ||
702 | |||
703 | %% Now shift the input by one sample and re-build the pyramid. | ||
704 | shifted_sig = [0,sig(1:size(sig,2)-1)]; | ||
705 | [spyr,spind] = buildWpyr(shifted_sig, 4, daub_lo, 'circular'); | ||
706 | |||
707 | %% Plot each band of the unshifted and shifted decomposition | ||
708 | nextFig(2); | ||
709 | nbands = size(spind,1) | ||
710 | for b=1:nbands | ||
711 | subplot(nbands,1,b); lplot(pyrBand(spyr,spind,b)); | ||
712 | axis([1 size(pyrBand(spyr,spind,b),2) -0.3 1.3]); | ||
713 | end | ||
714 | nextFig(2,-1); | ||
715 | |||
716 | %% In the third band, we expected the coefficients to move around | ||
717 | %% because the signal was shifted. But notice that in the original | ||
718 | %% signal decomposition, the other bands were filled with zeros. | ||
719 | %% After the shift, they have significant content. Although these | ||
720 | %% subbands are supposed to represent information at different scales, | ||
721 | %% their content also depends on the relative POSITION of the input | ||
722 | %% signal. | ||
723 | |||
724 | %% This problem is not unique to the Daubechies transform. The same | ||
725 | %% is true for the QMF transform. Try it... In fact, the same kind | ||
726 | %% of problem occurs for almost any orthogonal pyramid transform (the | ||
727 | %% only exception is the limiting case in which the filter is a sinc | ||
728 | %% function). | ||
729 | |||
730 | %% Orthogonal pyramid transforms are not shift-invariant. Although | ||
731 | %% orthogonality may be an important property for some applications | ||
732 | %% (e.g., data compression), orthogonal pyramid transforms are | ||
733 | %% generally not so good for image analysis. | ||
734 | |||
735 | %% The overcompleteness of the Laplacian pyramid turns out to be a | ||
736 | %% good thing in the end. By using an overcomplete representation | ||
737 | %% (and by choosing the filters properly to avoid aliasing as much as | ||
738 | %% possible), you end up with a representation that is useful for | ||
739 | %% image analysis. | ||
740 | |||
741 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
742 | |||
743 | %%% The "STEERABLE PYRAMID" | ||
744 | |||
745 | %% The steerable pyramid is a multi-scale representation that is | ||
746 | %% translation-invariant, but that also includes representation of | ||
747 | %% orientation. Furthermore, the representation of orientation is | ||
748 | %% designed to be rotation-invariant. The basis/projection functions | ||
749 | %% are oriented (steerable) filters, localized in space and frequency. | ||
750 | %% It is overcomplete to avoid aliasing. And it is "self-inverting" | ||
751 | %% (like the QMF/Wavelet transform): the projection functions and | ||
752 | %% basis functions are identical. The mathematical phrase for a | ||
753 | %% transform obeying this property is "tight frame". | ||
754 | |||
755 | %% The system diagram for the steerable pyramid (described in the | ||
756 | %% reference given below) is as follows: | ||
757 | % | ||
758 | % IM ---> fhi0 -----------------> H0 ---------------- fhi0 ---> RESULT | ||
759 | % | | | ||
760 | % | | | ||
761 | % |-> flo0 ---> fl1/down2 --> L1 --> up2/fl1 ---> flo0 -| | ||
762 | % | | | ||
763 | % |----> fb0 -----> B0 ----> fb0 ---| | ||
764 | % | | | ||
765 | % |----> fb1 -----> B1 ----> fb1 ---| | ||
766 | % . . | ||
767 | % . . | ||
768 | % |----> fbK -----> BK ----> fbK ---| | ||
769 | % | ||
770 | %% The filters {fhi0,flo0} are used to initially split the image into | ||
771 | %% a highpass residual band H0 and a lowpass subband. This lowpass | ||
772 | %% band is then split into a low(er)pass band L1 and K+1 oriented | ||
773 | %% subbands {B0,B1,...,BK}. The representatation is substantially | ||
774 | %% overcomplete. The pyramid is built by recursively splitting the | ||
775 | %% lowpass band (L1) using the inner portion of the diagram (i.e., | ||
776 | %% using the filters {fl1,fb0,fb1,...,fbK}). The resulting transform is | ||
777 | %% overcomplete by a factor of 4k/3. | ||
778 | |||
779 | %% The scale tuning of the filters is constrained by the recursive | ||
780 | %% system diagram. The orientation tuning is constrained by requiring | ||
781 | %% the property of steerability. A set of filters form a steerable | ||
782 | %% basis if they 1) are rotated copies of each other, and 2) a copy of | ||
783 | %% the filter at any orientation may be computed as a linear | ||
784 | %% combination of the basis filters. The simplest examples of | ||
785 | %% steerable filters is a set of N+1 Nth-order directional | ||
786 | %% derivatives. | ||
787 | |||
788 | %% Choose a filter set (options are 'sp0Filters', 'sp1Filters', | ||
789 | %% 'sp3Filters', 'sp5Filters'): | ||
790 | filts = 'sp3Filters'; | ||
791 | [lo0filt,hi0filt,lofilt,bfilts,steermtx,harmonics] = eval(filts); | ||
792 | fsz = round(sqrt(size(bfilts,1))); fsz = [fsz fsz]; | ||
793 | nfilts = size(bfilts,2); | ||
794 | nrows = floor(sqrt(nfilts)); | ||
795 | |||
796 | %% Look at the oriented bandpass filters: | ||
797 | for f = 1:nfilts | ||
798 | subplot(nrows,ceil(nfilts/nrows),f); | ||
799 | showIm(conv2(reshape(bfilts(:,f),fsz),lo0filt)); | ||
800 | end | ||
801 | |||
802 | %% Try "steering" to a new orientation (new_ori in degrees): | ||
803 | new_ori = 360*rand(1) | ||
804 | clf; showIm(conv2(reshape(steer(bfilts, new_ori*pi/180 ), fsz), lo0filt)); | ||
805 | |||
806 | %% Look at Fourier transform magnitudes: | ||
807 | lo0 = fftshift(abs(fft2(lo0filt,64,64))); | ||
808 | fsum = zeros(size(lo0)); | ||
809 | for f = 1:size(bfilts,2) | ||
810 | subplot(nrows,ceil(nfilts/nrows),f); | ||
811 | flt = reshape(bfilts(:,f),fsz); | ||
812 | freq = lo0 .* fftshift(abs(fft2(flt,64,64))); | ||
813 | fsum = fsum + freq.^2; | ||
814 | showIm(freq); | ||
815 | end | ||
816 | |||
817 | %% The filters sum to a smooth annular ring: | ||
818 | clf; showIm(fsum); | ||
819 | |||
820 | %% build a Steerable pyramid: | ||
821 | [pyr,pind] = buildSpyr(im, 4-imSubSample, filts); | ||
822 | |||
823 | %% Look at first (vertical) bands, different scales: | ||
824 | for s = 1:min(4,spyrHt(pind)) | ||
825 | band = spyrBand(pyr,pind,s,1); | ||
826 | subplot(2,2,s); showIm(band); | ||
827 | end | ||
828 | |||
829 | %% look at all orientation bands at one level (scale): | ||
830 | for b = 1:spyrNumBands(pind) | ||
831 | band = spyrBand(pyr,pind,1,b); | ||
832 | subplot(nrows,ceil(nfilts/nrows),b); | ||
833 | showIm(band); | ||
834 | end | ||
835 | |||
836 | %% To access the high-pass and low-pass bands: | ||
837 | low = pyrLow(pyr,pind); | ||
838 | showIm(low); | ||
839 | high = spyrHigh(pyr,pind); | ||
840 | showIm(high); | ||
841 | |||
842 | %% Display the whole pyramid (except for the highpass residual band), | ||
843 | %% with images shown at proper relative sizes: | ||
844 | showSpyr(pyr,pind); | ||
845 | |||
846 | %% Spin a level of the pyramid, interpolating (steering to) | ||
847 | %% intermediate orienations: | ||
848 | |||
849 | [lev,lind] = spyrLev(pyr,pind,2); | ||
850 | lev2 = reshape(lev,prod(lind(1,:)),size(bfilts,2)); | ||
851 | figure(1); subplot(1,1,1); showIm(spyrBand(pyr,pind,2,1)); | ||
852 | M = moviein(16); | ||
853 | for frame = 1:16 | ||
854 | steered_im = steer(lev2, 2*pi*(frame-1)/16, harmonics, steermtx); | ||
855 | showIm(reshape(steered_im, lind(1,:)),'auto2'); | ||
856 | M(:,frame) = getframe; | ||
857 | end | ||
858 | |||
859 | %% Show the movie 3 times: | ||
860 | movie(M,3); | ||
861 | |||
862 | %% Reconstruct. Note that the filters are not perfect, although they are good | ||
863 | %% enough for most applications. | ||
864 | res = reconSpyr(pyr, pind, filts); | ||
865 | showIm(im + i * res); | ||
866 | imStats(im,res); | ||
867 | |||
868 | %% As with previous pyramids, you can select subsets of the levels | ||
869 | %% and orientation bands to be included in the reconstruction. For example: | ||
870 | |||
871 | %% All levels (including highpass and lowpass residuals), one orientation: | ||
872 | clf; showIm(reconSpyr(pyr,pind,filts,'reflect1','all', [1])); | ||
873 | |||
874 | %% Without the highpass and lowpass: | ||
875 | clf; showIm(reconSpyr(pyr,pind,filts,'reflect1',[1:spyrHt(pind)], [1])); | ||
876 | |||
877 | %% We also provide an implementation of the Steerable pyramid in the | ||
878 | %% Frequency domain. The advantages are perfect-reconstruction | ||
879 | %% (within floating-point error), and any number of orientation | ||
880 | %% bands. The disadvantages are that it is typically slower, and the | ||
881 | %% boundary handling is always circular. | ||
882 | |||
883 | [pyr,pind] = buildSFpyr(im,4,4); % 4 levels, 5 orientation bands | ||
884 | showSpyr(pyr,pind); | ||
885 | res = reconSFpyr(pyr,pind); | ||
886 | imStats(im,res); % nearly perfect | ||
887 | |||
888 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
889 | % The steerable pyramid transform given above is described in: | ||
890 | % | ||
891 | % E P Simoncelli and W T Freeman. | ||
892 | % The Steerable Pyramid: A Flexible Architecture for Multi-Scale | ||
893 | % Derivative Computation. IEEE Second Int'l Conf on Image Processing. | ||
894 | % Washington DC, October 1995. | ||
895 | % | ||
896 | % Online access: | ||
897 | % Abstract: http://www.cis.upenn.edu/~eero/ABSTRACTS/simoncelli95b-abstract.html | ||
898 | % Full (PostScript): ftp://ftp.cis.upenn.edu/pub/eero/simoncelli95b.ps.Z | ||
899 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
900 | |||
901 | %% Local Variables: | ||
902 | %% buffer-read-only: t | ||
903 | %% End: | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/binomialFilter.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/binomialFilter.m deleted file mode 100755 index e5670c7..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/binomialFilter.m +++ /dev/null | |||
@@ -1,18 +0,0 @@ | |||
1 | % KERNEL = binomialFilter(size) | ||
2 | % | ||
3 | % Returns a vector of binomial coefficients of order (size-1) . | ||
4 | |||
5 | % Eero Simoncelli, 2/97. | ||
6 | |||
7 | function [kernel] = binomialFilter(sz) | ||
8 | |||
9 | if (sz < 2) | ||
10 | error('size argument must be larger than 1'); | ||
11 | end | ||
12 | |||
13 | kernel = [0.5 0.5]'; | ||
14 | |||
15 | for n=1:sz-2 | ||
16 | kernel = conv([0.5 0.5]', kernel); | ||
17 | end | ||
18 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/blur.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/blur.m deleted file mode 100755 index f993d09..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/blur.m +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
1 | % RES = blur(IM, LEVELS, FILT) | ||
2 | % | ||
3 | % Blur an image, by filtering and downsampling LEVELS times | ||
4 | % (default=1), followed by upsampling and filtering LEVELS times. The | ||
5 | % blurring is done with filter kernel specified by FILT (default = | ||
6 | % 'binom5'), which can be a string (to be passed to namedFilter), a | ||
7 | % vector (applied separably as a 1D convolution kernel in X and Y), or | ||
8 | % a matrix (applied as a 2D convolution kernel). The downsampling is | ||
9 | % always by 2 in each direction. | ||
10 | |||
11 | % Eero Simoncelli, 3/04. | ||
12 | |||
13 | function res = blur(im, nlevs, filt) | ||
14 | |||
15 | %------------------------------------------------------------ | ||
16 | %% OPTIONAL ARGS: | ||
17 | |||
18 | if (exist('nlevs') ~= 1) | ||
19 | nlevs = 1; | ||
20 | end | ||
21 | |||
22 | if (exist('filt') ~= 1) | ||
23 | filt = 'binom5'; | ||
24 | end | ||
25 | |||
26 | %------------------------------------------------------------ | ||
27 | |||
28 | res = upBlur(blurDn(im,nlevs,filt)); \ No newline at end of file | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/blurDn.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/blurDn.m deleted file mode 100755 index 8120c04..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/blurDn.m +++ /dev/null | |||
@@ -1,59 +0,0 @@ | |||
1 | % RES = blurDn(IM, LEVELS, FILT) | ||
2 | % | ||
3 | % Blur and downsample an image. The blurring is done with filter | ||
4 | % kernel specified by FILT (default = 'binom5'), which can be a string | ||
5 | % (to be passed to namedFilter), a vector (applied separably as a 1D | ||
6 | % convolution kernel in X and Y), or a matrix (applied as a 2D | ||
7 | % convolution kernel). The downsampling is always by 2 in each | ||
8 | % direction. | ||
9 | % | ||
10 | % The procedure is applied recursively LEVELS times (default=1). | ||
11 | |||
12 | % Eero Simoncelli, 3/97. | ||
13 | |||
14 | function res = blurDn(im, nlevs, filt) | ||
15 | |||
16 | %------------------------------------------------------------ | ||
17 | %% OPTIONAL ARGS: | ||
18 | |||
19 | if (exist('nlevs') ~= 1) | ||
20 | nlevs = 1; | ||
21 | end | ||
22 | |||
23 | if (exist('filt') ~= 1) | ||
24 | filt = 'binom5'; | ||
25 | end | ||
26 | |||
27 | %------------------------------------------------------------ | ||
28 | |||
29 | if isstr(filt) | ||
30 | filt = namedFilter(filt); | ||
31 | end | ||
32 | |||
33 | filt = filt/sum(filt(:)); | ||
34 | |||
35 | if nlevs > 1 | ||
36 | im = blurDn(im,nlevs-1,filt); | ||
37 | end | ||
38 | |||
39 | if (nlevs >= 1) | ||
40 | if (any(size(im)==1)) | ||
41 | if (~any(size(filt)==1)) | ||
42 | error('Cant apply 2D filter to 1D signal'); | ||
43 | end | ||
44 | if (size(im,2)==1) | ||
45 | filt = filt(:); | ||
46 | else | ||
47 | filt = filt(:)'; | ||
48 | end | ||
49 | res = corrDn(im,filt,'reflect1',(size(im)~=1)+1); | ||
50 | elseif (any(size(filt)==1)) | ||
51 | filt = filt(:); | ||
52 | res = corrDn(im,filt,'reflect1',[2 1]); | ||
53 | res = corrDn(res,filt','reflect1',[1 2]); | ||
54 | else | ||
55 | res = corrDn(im,filt,'reflect1',[2 2]); | ||
56 | end | ||
57 | else | ||
58 | res = im; | ||
59 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/buildGpyr.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/buildGpyr.m deleted file mode 100755 index 3f3d07b..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/buildGpyr.m +++ /dev/null | |||
@@ -1,82 +0,0 @@ | |||
1 | % [PYR, INDICES] = buildGpyr(IM, HEIGHT, FILT, EDGES) | ||
2 | % | ||
3 | % Construct a Gaussian pyramid on matrix IM. | ||
4 | % | ||
5 | % HEIGHT (optional) specifies the number of pyramid levels to build. Default | ||
6 | % is 1+maxPyrHt(size(IM),size(FILT)). | ||
7 | % You can also specify 'auto' to use this value. | ||
8 | % | ||
9 | % FILT (optional) can be a string naming a standard filter (see | ||
10 | % namedFilter), or a vector which will be used for (separable) | ||
11 | % convolution. Default = 'binom5'. EDGES specifies edge-handling, and | ||
12 | % defaults to 'reflect1' (see corrDn). | ||
13 | % | ||
14 | % PYR is a vector containing the N pyramid subbands, ordered from fine | ||
15 | % to coarse. INDICES is an Nx2 matrix containing the sizes of | ||
16 | % each subband. This is compatible with the MatLab Wavelet toolbox. | ||
17 | |||
18 | % Eero Simoncelli, 6/96. | ||
19 | |||
20 | function [pyr,pind] = buildGpyr(im, ht, filt, edges) | ||
21 | |||
22 | if (nargin < 1) | ||
23 | error('First argument (IM) is required'); | ||
24 | end | ||
25 | |||
26 | im_sz = size(im); | ||
27 | |||
28 | %------------------------------------------------------------ | ||
29 | %% OPTIONAL ARGS: | ||
30 | |||
31 | if (exist('filt') ~= 1) | ||
32 | filt = 'binom5'; | ||
33 | end | ||
34 | |||
35 | if isstr(filt) | ||
36 | filt = namedFilter(filt); | ||
37 | end | ||
38 | |||
39 | if ( (size(filt,1) > 1) & (size(filt,2) > 1) ) | ||
40 | error('FILT should be a 1D filter (i.e., a vector)'); | ||
41 | else | ||
42 | filt = filt(:); | ||
43 | end | ||
44 | |||
45 | max_ht = 1 + maxPyrHt(im_sz, size(filt,1)); | ||
46 | if ( (exist('ht') ~= 1) | (ht == 'auto') ) | ||
47 | ht = max_ht; | ||
48 | else | ||
49 | if (ht > max_ht) | ||
50 | error(sprintf('Cannot build pyramid higher than %d levels.',max_ht)); | ||
51 | end | ||
52 | end | ||
53 | |||
54 | if (exist('edges') ~= 1) | ||
55 | edges= 'reflect1'; | ||
56 | end | ||
57 | |||
58 | %------------------------------------------------------------ | ||
59 | |||
60 | if (ht <= 1) | ||
61 | |||
62 | pyr = im(:); | ||
63 | pind = im_sz; | ||
64 | |||
65 | else | ||
66 | |||
67 | if (im_sz(2) == 1) | ||
68 | lo2 = corrDn(im, filt, edges, [2 1], [1 1]); | ||
69 | elseif (im_sz(1) == 1) | ||
70 | lo2 = corrDn(im, filt', edges, [1 2], [1 1]); | ||
71 | else | ||
72 | lo = corrDn(im, filt', edges, [1 2], [1 1]); | ||
73 | lo2 = corrDn(lo, filt, edges, [2 1], [1 1]); | ||
74 | end | ||
75 | |||
76 | [npyr,nind] = buildGpyr(lo2, ht-1, filt, edges); | ||
77 | |||
78 | pyr = [im(:); npyr]; | ||
79 | pind = [im_sz; nind]; | ||
80 | |||
81 | end | ||
82 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/buildLpyr.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/buildLpyr.m deleted file mode 100755 index facb0f3..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/buildLpyr.m +++ /dev/null | |||
@@ -1,109 +0,0 @@ | |||
1 | % [PYR, INDICES] = buildLpyr(IM, HEIGHT, FILT1, FILT2, EDGES) | ||
2 | % | ||
3 | % Construct a Laplacian pyramid on matrix (or vector) IM. | ||
4 | % | ||
5 | % HEIGHT (optional) specifies the number of pyramid levels to build. Default | ||
6 | % is 1+maxPyrHt(size(IM),size(FILT)). You can also specify 'auto' to | ||
7 | % use this value. | ||
8 | % | ||
9 | % FILT1 (optional) can be a string naming a standard filter (see | ||
10 | % namedFilter), or a vector which will be used for (separable) | ||
11 | % convolution. Default = 'binom5'. FILT2 specifies the "expansion" | ||
12 | % filter (default = filt1). EDGES specifies edge-handling, and | ||
13 | % defaults to 'reflect1' (see corrDn). | ||
14 | % | ||
15 | % PYR is a vector containing the N pyramid subbands, ordered from fine | ||
16 | % to coarse. INDICES is an Nx2 matrix containing the sizes of | ||
17 | % each subband. This is compatible with the MatLab Wavelet toolbox. | ||
18 | |||
19 | % Eero Simoncelli, 6/96. | ||
20 | |||
21 | function [pyr,pind] = buildLpyr(im, ht, filt1, filt2, edges) | ||
22 | |||
23 | if (nargin < 1) | ||
24 | error('First argument (IM) is required'); | ||
25 | end | ||
26 | |||
27 | im_sz = size(im); | ||
28 | |||
29 | %------------------------------------------------------------ | ||
30 | %% OPTIONAL ARGS: | ||
31 | |||
32 | if (exist('filt1') ~= 1) | ||
33 | filt1 = 'binom5'; | ||
34 | end | ||
35 | |||
36 | if isstr(filt1) | ||
37 | filt1 = namedFilter(filt1); | ||
38 | end | ||
39 | |||
40 | if ( (size(filt1,1) > 1) & (size(filt1,2) > 1) ) | ||
41 | error('FILT1 should be a 1D filter (i.e., a vector)'); | ||
42 | else | ||
43 | filt1 = filt1(:); | ||
44 | end | ||
45 | |||
46 | if (exist('filt2') ~= 1) | ||
47 | filt2 = filt1; | ||
48 | end | ||
49 | |||
50 | if isstr(filt2) | ||
51 | filt2 = namedFilter(filt2); | ||
52 | end | ||
53 | |||
54 | if ( (size(filt2,1) > 1) & (size(filt2,2) > 1) ) | ||
55 | error('FILT2 should be a 1D filter (i.e., a vector)'); | ||
56 | else | ||
57 | filt2 = filt2(:); | ||
58 | end | ||
59 | |||
60 | max_ht = 1 + maxPyrHt(im_sz, max(size(filt1,1), size(filt2,1))); | ||
61 | if ( (exist('ht') ~= 1) | (ht == 'auto') ) | ||
62 | ht = max_ht; | ||
63 | else | ||
64 | if (ht > max_ht) | ||
65 | error(sprintf('Cannot build pyramid higher than %d levels.',max_ht)); | ||
66 | end | ||
67 | end | ||
68 | |||
69 | if (exist('edges') ~= 1) | ||
70 | edges= 'reflect1'; | ||
71 | end | ||
72 | |||
73 | %------------------------------------------------------------ | ||
74 | |||
75 | if (ht <= 1) | ||
76 | |||
77 | pyr = im(:); | ||
78 | pind = im_sz; | ||
79 | |||
80 | else | ||
81 | |||
82 | if (im_sz(2) == 1) | ||
83 | lo2 = corrDn(im, filt1, edges, [2 1], [1 1]); | ||
84 | elseif (im_sz(1) == 1) | ||
85 | lo2 = corrDn(im, filt1', edges, [1 2], [1 1]); | ||
86 | else | ||
87 | lo = corrDn(im, filt1', edges, [1 2], [1 1]); | ||
88 | int_sz = size(lo); | ||
89 | lo2 = corrDn(lo, filt1, edges, [2 1], [1 1]); | ||
90 | end | ||
91 | |||
92 | [npyr,nind] = buildLpyr(lo2, ht-1, filt1, filt2, edges); | ||
93 | |||
94 | if (im_sz(1) == 1) | ||
95 | hi2 = upConv(lo2, filt2', edges, [1 2], [1 1], im_sz); | ||
96 | elseif (im_sz(2) == 1) | ||
97 | hi2 = upConv(lo2, filt2, edges, [2 1], [1 1], im_sz); | ||
98 | else | ||
99 | hi = upConv(lo2, filt2, edges, [2 1], [1 1], int_sz); | ||
100 | hi2 = upConv(hi, filt2', edges, [1 2], [1 1], im_sz); | ||
101 | end | ||
102 | |||
103 | hi2 = im - hi2; | ||
104 | |||
105 | pyr = [hi2(:); npyr]; | ||
106 | pind = [im_sz; nind]; | ||
107 | |||
108 | end | ||
109 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/buildSCFpyr.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/buildSCFpyr.m deleted file mode 100755 index 101b6d2..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/buildSCFpyr.m +++ /dev/null | |||
@@ -1,90 +0,0 @@ | |||
1 | % [PYR, INDICES, STEERMTX, HARMONICS] = buildSCFpyr(IM, HEIGHT, ORDER, TWIDTH) | ||
2 | % | ||
3 | % This is a modified version of buildSFpyr, that constructs a | ||
4 | % complex-valued steerable pyramid using Hilbert-transform pairs | ||
5 | % of filters. Note that the imaginary parts will *not* be steerable. | ||
6 | % | ||
7 | % To reconstruct from this representation, either call reconSFpyr | ||
8 | % on the real part of the pyramid, *or* call reconSCFpyr which will | ||
9 | % use both real and imaginary parts (forcing analyticity). | ||
10 | % | ||
11 | % Description of this transform appears in: Portilla & Simoncelli, | ||
12 | % Int'l Journal of Computer Vision, 40(1):49-71, Oct 2000. | ||
13 | % Further information: http://www.cns.nyu.edu/~eero/STEERPYR/ | ||
14 | |||
15 | % Original code: Eero Simoncelli, 5/97. | ||
16 | % Modified by Javier Portilla to return complex (quadrature pair) channels, | ||
17 | % 9/97. | ||
18 | |||
19 | function [pyr,pind,steermtx,harmonics] = buildSCFpyr(im, ht, order, twidth) | ||
20 | |||
21 | %----------------------------------------------------------------- | ||
22 | %% DEFAULTS: | ||
23 | |||
24 | max_ht = floor(log2(min(size(im)))) - 2; | ||
25 | |||
26 | if (exist('ht') ~= 1) | ||
27 | ht = max_ht; | ||
28 | else | ||
29 | if (ht > max_ht) | ||
30 | error(sprintf('Cannot build pyramid higher than %d levels.',max_ht)); | ||
31 | end | ||
32 | end | ||
33 | |||
34 | if (exist('order') ~= 1) | ||
35 | order = 3; | ||
36 | elseif ((order > 15) | (order < 0)) | ||
37 | fprintf(1,'Warning: ORDER must be an integer in the range [0,15]. Truncating.\n'); | ||
38 | order = min(max(order,0),15); | ||
39 | else | ||
40 | order = round(order); | ||
41 | end | ||
42 | nbands = order+1; | ||
43 | |||
44 | if (exist('twidth') ~= 1) | ||
45 | twidth = 1; | ||
46 | elseif (twidth <= 0) | ||
47 | fprintf(1,'Warning: TWIDTH must be positive. Setting to 1.\n'); | ||
48 | twidth = 1; | ||
49 | end | ||
50 | |||
51 | %----------------------------------------------------------------- | ||
52 | %% Steering stuff: | ||
53 | |||
54 | if (mod((nbands),2) == 0) | ||
55 | harmonics = [0:(nbands/2)-1]'*2 + 1; | ||
56 | else | ||
57 | harmonics = [0:(nbands-1)/2]'*2; | ||
58 | end | ||
59 | |||
60 | steermtx = steer2HarmMtx(harmonics, pi*[0:nbands-1]/nbands, 'even'); | ||
61 | |||
62 | %----------------------------------------------------------------- | ||
63 | |||
64 | dims = size(im); | ||
65 | ctr = ceil((dims+0.5)/2); | ||
66 | |||
67 | [xramp,yramp] = meshgrid( ([1:dims(2)]-ctr(2))./(dims(2)/2), ... | ||
68 | ([1:dims(1)]-ctr(1))./(dims(1)/2) ); | ||
69 | angle = atan2(yramp,xramp); | ||
70 | log_rad = sqrt(xramp.^2 + yramp.^2); | ||
71 | log_rad(ctr(1),ctr(2)) = log_rad(ctr(1),ctr(2)-1); | ||
72 | log_rad = log2(log_rad); | ||
73 | |||
74 | %% Radial transition function (a raised cosine in log-frequency): | ||
75 | [Xrcos,Yrcos] = rcosFn(twidth,(-twidth/2),[0 1]); | ||
76 | Yrcos = sqrt(Yrcos); | ||
77 | |||
78 | YIrcos = sqrt(1.0 - Yrcos.^2); | ||
79 | lo0mask = pointOp(log_rad, YIrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); | ||
80 | imdft = fftshift(fft2(im)); | ||
81 | lo0dft = imdft .* lo0mask; | ||
82 | |||
83 | [pyr,pind] = buildSCFpyrLevs(lo0dft, log_rad, Xrcos, Yrcos, angle, ht, nbands); | ||
84 | |||
85 | hi0mask = pointOp(log_rad, Yrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); | ||
86 | hi0dft = imdft .* hi0mask; | ||
87 | hi0 = ifft2(ifftshift(hi0dft)); | ||
88 | |||
89 | pyr = [real(hi0(:)) ; pyr]; | ||
90 | pind = [size(hi0); pind]; | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/buildSCFpyrLevs.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/buildSCFpyrLevs.m deleted file mode 100755 index bd75695..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/buildSCFpyrLevs.m +++ /dev/null | |||
@@ -1,73 +0,0 @@ | |||
1 | % [PYR, INDICES] = buildSCFpyrLevs(LODFT, LOGRAD, XRCOS, YRCOS, ANGLE, HEIGHT, NBANDS) | ||
2 | % | ||
3 | % Recursive function for constructing levels of a steerable pyramid. This | ||
4 | % is called by buildSCFpyr, and is not usually called directly. | ||
5 | |||
6 | % Original code: Eero Simoncelli, 5/97. | ||
7 | % Modified by Javier Portilla to generate complex bands in 9/97. | ||
8 | |||
9 | function [pyr,pind] = buildSCFpyrLevs(lodft,log_rad,Xrcos,Yrcos,angle,ht,nbands); | ||
10 | |||
11 | if (ht <= 0) | ||
12 | |||
13 | lo0 = ifft2(ifftshift(lodft)); | ||
14 | pyr = real(lo0(:)); | ||
15 | pind = size(lo0); | ||
16 | |||
17 | else | ||
18 | |||
19 | bands = zeros(prod(size(lodft)), nbands); | ||
20 | bind = zeros(nbands,2); | ||
21 | |||
22 | % log_rad = log_rad + 1; | ||
23 | Xrcos = Xrcos - log2(2); % shift origin of lut by 1 octave. | ||
24 | |||
25 | lutsize = 1024; | ||
26 | Xcosn = pi*[-(2*lutsize+1):(lutsize+1)]/lutsize; % [-2*pi:pi] | ||
27 | order = nbands-1; | ||
28 | %% divide by sqrt(sum_(n=0)^(N-1) cos(pi*n/N)^(2(N-1)) ) | ||
29 | %% Thanks to Patrick Teo for writing this out :) | ||
30 | const = (2^(2*order))*(factorial(order)^2)/(nbands*factorial(2*order)); | ||
31 | |||
32 | % | ||
33 | % Ycosn = sqrt(const) * (cos(Xcosn)).^order; | ||
34 | % | ||
35 | % analityc version: only take one lobe | ||
36 | alfa= mod(pi+Xcosn,2*pi)-pi; | ||
37 | Ycosn = 2*sqrt(const) * (cos(Xcosn).^order) .* (abs(alfa)<pi/2); | ||
38 | |||
39 | himask = pointOp(log_rad, Yrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); | ||
40 | |||
41 | for b = 1:nbands | ||
42 | anglemask = pointOp(angle, Ycosn, Xcosn(1)+pi*(b-1)/nbands, Xcosn(2)-Xcosn(1)); | ||
43 | banddft = ((-i)^(nbands-1)) .* lodft .* anglemask .* himask; | ||
44 | band = ifft2(ifftshift(banddft)); | ||
45 | |||
46 | % bands(:,b) = real(band(:)); | ||
47 | % analytic version: full complex value | ||
48 | bands(:,b)=band(:); | ||
49 | bind(b,:) = size(band); | ||
50 | end | ||
51 | |||
52 | dims = size(lodft); | ||
53 | ctr = ceil((dims+0.5)/2); | ||
54 | lodims = ceil((dims-0.5)/2); | ||
55 | loctr = ceil((lodims+0.5)/2); | ||
56 | lostart = ctr-loctr+1; | ||
57 | loend = lostart+lodims-1; | ||
58 | |||
59 | log_rad = log_rad(lostart(1):loend(1),lostart(2):loend(2)); | ||
60 | angle = angle(lostart(1):loend(1),lostart(2):loend(2)); | ||
61 | lodft = lodft(lostart(1):loend(1),lostart(2):loend(2)); | ||
62 | YIrcos = abs(sqrt(1.0 - Yrcos.^2)); | ||
63 | lomask = pointOp(log_rad, YIrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); | ||
64 | |||
65 | lodft = lomask .* lodft; | ||
66 | |||
67 | [npyr,nind] = buildSCFpyrLevs(lodft, log_rad, Xrcos, Yrcos, angle, ht-1, nbands); | ||
68 | |||
69 | pyr = [bands(:); npyr]; | ||
70 | pind = [bind; nind]; | ||
71 | |||
72 | end | ||
73 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/buildSFpyr.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/buildSFpyr.m deleted file mode 100755 index ae67206..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/buildSFpyr.m +++ /dev/null | |||
@@ -1,102 +0,0 @@ | |||
1 | % [PYR, INDICES, STEERMTX, HARMONICS] = buildSFpyr(IM, HEIGHT, ORDER, TWIDTH) | ||
2 | % | ||
3 | % Construct a steerable pyramid on matrix IM, in the Fourier domain. | ||
4 | % This is similar to buildSpyr, except that: | ||
5 | % | ||
6 | % + Reconstruction is exact (within floating point errors) | ||
7 | % + It can produce any number of orientation bands. | ||
8 | % - Typically slower, especially for non-power-of-two sizes. | ||
9 | % - Boundary-handling is circular. | ||
10 | % | ||
11 | % HEIGHT (optional) specifies the number of pyramid levels to build. Default | ||
12 | % is maxPyrHt(size(IM),size(FILT)); | ||
13 | % | ||
14 | % The squared radial functions tile the Fourier plane, with a raised-cosine | ||
15 | % falloff. Angular functions are cos(theta-k\pi/(K+1))^K, where K is | ||
16 | % the ORDER (one less than the number of orientation bands, default= 3). | ||
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 | % PYR is a vector containing the N pyramid subbands, ordered from fine | ||
23 | % to coarse. INDICES is an Nx2 matrix containing the sizes of | ||
24 | % each subband. This is compatible with the MatLab Wavelet toolbox. | ||
25 | % See the function STEER for a description of STEERMTX and HARMONICS. | ||
26 | |||
27 | % Eero Simoncelli, 5/97. | ||
28 | % See http://www.cns.nyu.edu/~eero/STEERPYR/ for more | ||
29 | % information about the Steerable Pyramid image decomposition. | ||
30 | |||
31 | function [pyr,pind,steermtx,harmonics] = buildSFpyr(im, ht, order, twidth) | ||
32 | |||
33 | %----------------------------------------------------------------- | ||
34 | %% DEFAULTS: | ||
35 | |||
36 | max_ht = floor(log2(min(size(im)))) - 2; | ||
37 | |||
38 | if (exist('ht') ~= 1) | ||
39 | ht = max_ht; | ||
40 | else | ||
41 | if (ht > max_ht) | ||
42 | error(sprintf('Cannot build pyramid higher than %d levels.',max_ht)); | ||
43 | end | ||
44 | end | ||
45 | |||
46 | if (exist('order') ~= 1) | ||
47 | order = 3; | ||
48 | elseif ((order > 15) | (order < 0)) | ||
49 | fprintf(1,'Warning: ORDER must be an integer in the range [0,15]. Truncating.\n'); | ||
50 | order = min(max(order,0),15); | ||
51 | else | ||
52 | order = round(order); | ||
53 | end | ||
54 | nbands = order+1; | ||
55 | |||
56 | if (exist('twidth') ~= 1) | ||
57 | twidth = 1; | ||
58 | elseif (twidth <= 0) | ||
59 | fprintf(1,'Warning: TWIDTH must be positive. Setting to 1.\n'); | ||
60 | twidth = 1; | ||
61 | end | ||
62 | |||
63 | %----------------------------------------------------------------- | ||
64 | %% Steering stuff: | ||
65 | |||
66 | if (mod((nbands),2) == 0) | ||
67 | harmonics = [0:(nbands/2)-1]'*2 + 1; | ||
68 | else | ||
69 | harmonics = [0:(nbands-1)/2]'*2; | ||
70 | end | ||
71 | |||
72 | steermtx = steer2HarmMtx(harmonics, pi*[0:nbands-1]/nbands, 'even'); | ||
73 | |||
74 | %----------------------------------------------------------------- | ||
75 | |||
76 | dims = size(im); | ||
77 | ctr = ceil((dims+0.5)/2); | ||
78 | |||
79 | [xramp,yramp] = meshgrid( ([1:dims(2)]-ctr(2))./(dims(2)/2), ... | ||
80 | ([1:dims(1)]-ctr(1))./(dims(1)/2) ); | ||
81 | angle = atan2(yramp,xramp); | ||
82 | log_rad = sqrt(xramp.^2 + yramp.^2); | ||
83 | log_rad(ctr(1),ctr(2)) = log_rad(ctr(1),ctr(2)-1); | ||
84 | log_rad = log2(log_rad); | ||
85 | |||
86 | %% Radial transition function (a raised cosine in log-frequency): | ||
87 | [Xrcos,Yrcos] = rcosFn(twidth,(-twidth/2),[0 1]); | ||
88 | Yrcos = sqrt(Yrcos); | ||
89 | |||
90 | YIrcos = sqrt(1.0 - Yrcos.^2); | ||
91 | lo0mask = pointOp(log_rad, YIrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); | ||
92 | imdft = fftshift(fft2(im)); | ||
93 | lo0dft = imdft .* lo0mask; | ||
94 | |||
95 | [pyr,pind] = buildSFpyrLevs(lo0dft, log_rad, Xrcos, Yrcos, angle, ht, nbands); | ||
96 | |||
97 | hi0mask = pointOp(log_rad, Yrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); | ||
98 | hi0dft = imdft .* hi0mask; | ||
99 | hi0 = ifft2(ifftshift(hi0dft)); | ||
100 | |||
101 | pyr = [real(hi0(:)) ; pyr]; | ||
102 | pind = [size(hi0); pind]; | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/buildSFpyrLevs.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/buildSFpyrLevs.m deleted file mode 100755 index 472d861..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/buildSFpyrLevs.m +++ /dev/null | |||
@@ -1,63 +0,0 @@ | |||
1 | % [PYR, INDICES] = buildSFpyrLevs(LODFT, LOGRAD, XRCOS, YRCOS, ANGLE, HEIGHT, NBANDS) | ||
2 | % | ||
3 | % Recursive function for constructing levels of a steerable pyramid. This | ||
4 | % is called by buildSFpyr, and is not usually called directly. | ||
5 | |||
6 | % Eero Simoncelli, 5/97. | ||
7 | |||
8 | function [pyr,pind] = buildSFpyrLevs(lodft,log_rad,Xrcos,Yrcos,angle,ht,nbands); | ||
9 | |||
10 | if (ht <= 0) | ||
11 | |||
12 | lo0 = ifft2(ifftshift(lodft)); | ||
13 | pyr = real(lo0(:)); | ||
14 | pind = size(lo0); | ||
15 | |||
16 | else | ||
17 | |||
18 | bands = zeros(prod(size(lodft)), nbands); | ||
19 | bind = zeros(nbands,2); | ||
20 | |||
21 | % log_rad = log_rad + 1; | ||
22 | Xrcos = Xrcos - log2(2); % shift origin of lut by 1 octave. | ||
23 | |||
24 | lutsize = 1024; | ||
25 | Xcosn = pi*[-(2*lutsize+1):(lutsize+1)]/lutsize; % [-2*pi:pi] | ||
26 | order = nbands-1; | ||
27 | %% divide by sqrt(sum_(n=0)^(N-1) cos(pi*n/N)^(2(N-1)) ) | ||
28 | %% Thanks to Patrick Teo for writing this out :) | ||
29 | const = (2^(2*order))*(factorial(order)^2)/(nbands*factorial(2*order)); | ||
30 | Ycosn = sqrt(const) * (cos(Xcosn)).^order; | ||
31 | himask = pointOp(log_rad, Yrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); | ||
32 | |||
33 | for b = 1:nbands | ||
34 | anglemask = pointOp(angle, Ycosn, Xcosn(1)+pi*(b-1)/nbands, Xcosn(2)-Xcosn(1)); | ||
35 | banddft = ((-sqrt(-1))^(nbands-1)) .* lodft .* anglemask .* himask; | ||
36 | band = ifft2(ifftshift(banddft)); | ||
37 | |||
38 | bands(:,b) = real(band(:)); | ||
39 | bind(b,:) = size(band); | ||
40 | end | ||
41 | |||
42 | dims = size(lodft); | ||
43 | ctr = ceil((dims+0.5)/2); | ||
44 | lodims = ceil((dims-0.5)/2); | ||
45 | loctr = ceil((lodims+0.5)/2); | ||
46 | lostart = ctr-loctr+1; | ||
47 | loend = lostart+lodims-1; | ||
48 | |||
49 | log_rad = log_rad(lostart(1):loend(1),lostart(2):loend(2)); | ||
50 | angle = angle(lostart(1):loend(1),lostart(2):loend(2)); | ||
51 | lodft = lodft(lostart(1):loend(1),lostart(2):loend(2)); | ||
52 | YIrcos = abs(sqrt(1.0 - Yrcos.^2)); | ||
53 | lomask = pointOp(log_rad, YIrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); | ||
54 | |||
55 | lodft = lomask .* lodft; | ||
56 | |||
57 | [npyr,nind] = buildSFpyrLevs(lodft, log_rad, Xrcos, Yrcos, angle, ht-1, nbands); | ||
58 | |||
59 | pyr = [bands(:); npyr]; | ||
60 | pind = [bind; nind]; | ||
61 | |||
62 | end | ||
63 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/buildSpyr.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/buildSpyr.m deleted file mode 100755 index b2bead6..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/buildSpyr.m +++ /dev/null | |||
@@ -1,61 +0,0 @@ | |||
1 | % [PYR, INDICES, STEERMTX, HARMONICS] = buildSpyr(IM, HEIGHT, FILTFILE, EDGES) | ||
2 | % | ||
3 | % Construct a steerable pyramid on matrix IM. | ||
4 | % | ||
5 | % HEIGHT (optional) specifies the number of pyramid levels to build. Default | ||
6 | % is maxPyrHt(size(IM),size(FILT)). | ||
7 | % You can also specify 'auto' to use this value. | ||
8 | % | ||
9 | % FILTFILE (optional) should be a string referring to an m-file that | ||
10 | % returns the rfilters. (examples: 'sp0Filters', 'sp1Filters', | ||
11 | % 'sp3Filters','sp5Filters'. default = 'sp1Filters'). EDGES specifies | ||
12 | % edge-handling, and defaults to 'reflect1' (see corrDn). | ||
13 | % | ||
14 | % PYR is a vector containing the N pyramid subbands, ordered from fine | ||
15 | % to coarse. INDICES is an Nx2 matrix containing the sizes of | ||
16 | % each subband. This is compatible with the MatLab Wavelet toolbox. | ||
17 | % See the function STEER for a description of STEERMTX and HARMONICS. | ||
18 | |||
19 | % Eero Simoncelli, 6/96. | ||
20 | % See http://www.cis.upenn.edu/~eero/steerpyr.html for more | ||
21 | % information about the Steerable Pyramid image decomposition. | ||
22 | |||
23 | function [pyr,pind,steermtx,harmonics] = buildSpyr(im, ht, filtfile, edges) | ||
24 | |||
25 | %----------------------------------------------------------------- | ||
26 | %% DEFAULTS: | ||
27 | |||
28 | if (exist('filtfile') ~= 1) | ||
29 | filtfile = 'sp1Filters'; | ||
30 | end | ||
31 | |||
32 | if (exist('edges') ~= 1) | ||
33 | edges= 'reflect1'; | ||
34 | end | ||
35 | |||
36 | if (isstr(filtfile) & (exist(filtfile) == 2)) | ||
37 | [lo0filt,hi0filt,lofilt,bfilts,steermtx,harmonics] = eval(filtfile); | ||
38 | else | ||
39 | fprintf(1,'\nUse buildSFpyr for pyramids with arbitrary numbers of orientation bands.\n'); | ||
40 | error('FILTFILE argument must be the name of an M-file containing SPYR filters.'); | ||
41 | end | ||
42 | |||
43 | max_ht = maxPyrHt(size(im), size(lofilt,1)); | ||
44 | if ( (exist('ht') ~= 1) | (ht == 'auto') ) | ||
45 | ht = max_ht; | ||
46 | else | ||
47 | if (ht > max_ht) | ||
48 | error(sprintf('Cannot build pyramid higher than %d levels.',max_ht)); | ||
49 | end | ||
50 | end | ||
51 | |||
52 | %----------------------------------------------------------------- | ||
53 | |||
54 | hi0 = corrDn(im, hi0filt, edges); | ||
55 | lo0 = corrDn(im, lo0filt, edges); | ||
56 | |||
57 | [pyr,pind] = buildSpyrLevs(lo0, ht, lofilt, bfilts, edges); | ||
58 | |||
59 | pyr = [hi0(:) ; pyr]; | ||
60 | pind = [size(hi0); pind]; | ||
61 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/buildSpyrLevs.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/buildSpyrLevs.m deleted file mode 100755 index 4c00077..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/buildSpyrLevs.m +++ /dev/null | |||
@@ -1,37 +0,0 @@ | |||
1 | % [PYR, INDICES] = buildSpyrLevs(LOIM, HEIGHT, LOFILT, BFILTS, EDGES) | ||
2 | % | ||
3 | % Recursive function for constructing levels of a steerable pyramid. This | ||
4 | % is called by buildSpyr, and is not usually called directly. | ||
5 | |||
6 | % Eero Simoncelli, 6/96. | ||
7 | |||
8 | function [pyr,pind] = buildSpyrLevs(lo0,ht,lofilt,bfilts,edges); | ||
9 | |||
10 | if (ht <= 0) | ||
11 | |||
12 | pyr = lo0(:); | ||
13 | pind = size(lo0); | ||
14 | |||
15 | else | ||
16 | |||
17 | % Assume square filters: | ||
18 | bfiltsz = round(sqrt(size(bfilts,1))); | ||
19 | |||
20 | bands = zeros(prod(size(lo0)),size(bfilts,2)); | ||
21 | bind = zeros(size(bfilts,2),2); | ||
22 | |||
23 | for b = 1:size(bfilts,2) | ||
24 | filt = reshape(bfilts(:,b),bfiltsz,bfiltsz); | ||
25 | band = corrDn(lo0, filt, edges); | ||
26 | bands(:,b) = band(:); | ||
27 | bind(b,:) = size(band); | ||
28 | end | ||
29 | |||
30 | lo = corrDn(lo0, lofilt, edges, [2 2], [1 1]); | ||
31 | |||
32 | [npyr,nind] = buildSpyrLevs(lo, ht-1, lofilt, bfilts, edges); | ||
33 | |||
34 | pyr = [bands(:); npyr]; | ||
35 | pind = [bind; nind]; | ||
36 | |||
37 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/buildWpyr.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/buildWpyr.m deleted file mode 100755 index 22ae32f..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/buildWpyr.m +++ /dev/null | |||
@@ -1,100 +0,0 @@ | |||
1 | % [PYR, INDICES] = buildWpyr(IM, HEIGHT, FILT, EDGES) | ||
2 | % | ||
3 | % Construct a separable orthonormal QMF/wavelet pyramid on matrix (or vector) IM. | ||
4 | % | ||
5 | % HEIGHT (optional) specifies the number of pyramid levels to build. Default | ||
6 | % is maxPyrHt(IM,FILT). You can also specify 'auto' to use this value. | ||
7 | % | ||
8 | % FILT (optional) can be a string naming a standard filter (see | ||
9 | % namedFilter), or a vector which will be used for (separable) | ||
10 | % convolution. Filter can be of even or odd length, but should be symmetric. | ||
11 | % Default = 'qmf9'. EDGES specifies edge-handling, and | ||
12 | % defaults to 'reflect1' (see corrDn). | ||
13 | % | ||
14 | % PYR is a vector containing the N pyramid subbands, ordered from fine | ||
15 | % to coarse. INDICES is an Nx2 matrix containing the sizes of | ||
16 | % each subband. This is compatible with the MatLab Wavelet toolbox. | ||
17 | |||
18 | % Eero Simoncelli, 6/96. | ||
19 | |||
20 | function [pyr,pind] = buildWpyr(im, ht, filt, edges) | ||
21 | |||
22 | if (nargin < 1) | ||
23 | error('First argument (IM) is required'); | ||
24 | end | ||
25 | |||
26 | %------------------------------------------------------------ | ||
27 | %% OPTIONAL ARGS: | ||
28 | |||
29 | if (exist('filt') ~= 1) | ||
30 | filt = 'qmf9'; | ||
31 | end | ||
32 | |||
33 | if (exist('edges') ~= 1) | ||
34 | edges= 'reflect1'; | ||
35 | end | ||
36 | |||
37 | if isstr(filt) | ||
38 | filt = namedFilter(filt); | ||
39 | end | ||
40 | |||
41 | if ( (size(filt,1) > 1) & (size(filt,2) > 1) ) | ||
42 | error('FILT should be a 1D filter (i.e., a vector)'); | ||
43 | else | ||
44 | filt = filt(:); | ||
45 | end | ||
46 | |||
47 | hfilt = modulateFlip(filt); | ||
48 | |||
49 | % Stagger sampling if filter is odd-length: | ||
50 | if (mod(size(filt,1),2) == 0) | ||
51 | stag = 2; | ||
52 | else | ||
53 | stag = 1; | ||
54 | end | ||
55 | |||
56 | im_sz = size(im); | ||
57 | |||
58 | max_ht = maxPyrHt(im_sz, size(filt,1)); | ||
59 | if ( (exist('ht') ~= 1) | (ht == 'auto') ) | ||
60 | ht = max_ht; | ||
61 | else | ||
62 | if (ht > max_ht) | ||
63 | error(sprintf('Cannot build pyramid higher than %d levels.',max_ht)); | ||
64 | end | ||
65 | end | ||
66 | |||
67 | if (ht <= 0) | ||
68 | |||
69 | pyr = im(:); | ||
70 | pind = im_sz; | ||
71 | |||
72 | else | ||
73 | |||
74 | if (im_sz(2) == 1) | ||
75 | lolo = corrDn(im, filt, edges, [2 1], [stag 1]); | ||
76 | hihi = corrDn(im, hfilt, edges, [2 1], [2 1]); | ||
77 | elseif (im_sz(1) == 1) | ||
78 | lolo = corrDn(im, filt', edges, [1 2], [1 stag]); | ||
79 | hihi = corrDn(im, hfilt', edges, [1 2], [1 2]); | ||
80 | else | ||
81 | lo = corrDn(im, filt, edges, [2 1], [stag 1]); | ||
82 | hi = corrDn(im, hfilt, edges, [2 1], [2 1]); | ||
83 | lolo = corrDn(lo, filt', edges, [1 2], [1 stag]); | ||
84 | lohi = corrDn(hi, filt', edges, [1 2], [1 stag]); % horizontal | ||
85 | hilo = corrDn(lo, hfilt', edges, [1 2], [1 2]); % vertical | ||
86 | hihi = corrDn(hi, hfilt', edges, [1 2], [1 2]); % diagonal | ||
87 | end | ||
88 | |||
89 | [npyr,nind] = buildWpyr(lolo, ht-1, filt, edges); | ||
90 | |||
91 | if ((im_sz(1) == 1) | (im_sz(2) == 1)) | ||
92 | pyr = [hihi(:); npyr]; | ||
93 | pind = [size(hihi); nind]; | ||
94 | else | ||
95 | pyr = [lohi(:); hilo(:); hihi(:); npyr]; | ||
96 | pind = [size(lohi); size(hilo); size(hihi); nind]; | ||
97 | end | ||
98 | |||
99 | end | ||
100 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/cconv2.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/cconv2.m deleted file mode 100755 index efba438..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/cconv2.m +++ /dev/null | |||
@@ -1,50 +0,0 @@ | |||
1 | % RES = CCONV2(MTX1, MTX2, CTR) | ||
2 | % | ||
3 | % Circular convolution of two matrices. Result will be of size of | ||
4 | % LARGER vector. | ||
5 | % | ||
6 | % The origin of the smaller matrix is assumed to be its center. | ||
7 | % For even dimensions, the origin is determined by the CTR (optional) | ||
8 | % argument: | ||
9 | % CTR origin | ||
10 | % 0 DIM/2 (default) | ||
11 | % 1 (DIM/2)+1 | ||
12 | |||
13 | % Eero Simoncelli, 6/96. Modified 2/97. | ||
14 | |||
15 | function c = cconv2(a,b,ctr) | ||
16 | |||
17 | if (exist('ctr') ~= 1) | ||
18 | ctr = 0; | ||
19 | end | ||
20 | |||
21 | if (( size(a,1) >= size(b,1) ) & ( size(a,2) >= size(b,2) )) | ||
22 | large = a; small = b; | ||
23 | elseif (( size(a,1) <= size(b,1) ) & ( size(a,2) <= size(b,2) )) | ||
24 | large = b; small = a; | ||
25 | else | ||
26 | error('one arg must be larger than the other in both dimensions!'); | ||
27 | end | ||
28 | |||
29 | ly = size(large,1); | ||
30 | lx = size(large,2); | ||
31 | sy = size(small,1); | ||
32 | sx = size(small,2); | ||
33 | |||
34 | %% These values are the index of the small mtx that falls on the | ||
35 | %% border pixel of the large matrix when computing the first | ||
36 | %% convolution response sample: | ||
37 | sy2 = floor((sy+ctr+1)/2); | ||
38 | sx2 = floor((sx+ctr+1)/2); | ||
39 | |||
40 | % pad: | ||
41 | clarge = [ ... | ||
42 | large(ly-sy+sy2+1:ly,lx-sx+sx2+1:lx), large(ly-sy+sy2+1:ly,:), ... | ||
43 | large(ly-sy+sy2+1:ly,1:sx2-1); ... | ||
44 | large(:,lx-sx+sx2+1:lx), large, large(:,1:sx2-1); ... | ||
45 | large(1:sy2-1,lx-sx+sx2+1:lx), ... | ||
46 | large(1:sy2-1,:), ... | ||
47 | large(1:sy2-1,1:sx2-1) ]; | ||
48 | |||
49 | c = conv2(clarge,small,'valid'); | ||
50 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/clip.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/clip.m deleted file mode 100755 index 28804f3..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/clip.m +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | % [RES] = clip(IM, MINVALorRANGE, MAXVAL) | ||
2 | % | ||
3 | % Clip values of matrix IM to lie between minVal and maxVal: | ||
4 | % RES = max(min(IM,MAXVAL),MINVAL) | ||
5 | % The first argument can also specify both min and max, as a 2-vector. | ||
6 | % If only one argument is passed, the range defaults to [0,1]. | ||
7 | |||
8 | function res = clip(im, minValOrRange, maxVal) | ||
9 | |||
10 | if (exist('minValOrRange') ~= 1) | ||
11 | minVal = 0; | ||
12 | maxVal = 1; | ||
13 | elseif (length(minValOrRange) == 2) | ||
14 | minVal = minValOrRange(1); | ||
15 | maxVal = minValOrRange(2); | ||
16 | elseif (length(minValOrRange) == 1) | ||
17 | minVal = minValOrRange; | ||
18 | if (exist('maxVal') ~= 1) | ||
19 | maxVal=minVal+1; | ||
20 | end | ||
21 | else | ||
22 | error('MINVAL must be a scalar or a 2-vector'); | ||
23 | end | ||
24 | |||
25 | if ( maxVal < minVal ) | ||
26 | error('MAXVAL should be less than MINVAL'); | ||
27 | end | ||
28 | |||
29 | res = im; | ||
30 | res(find(im < minVal)) = minVal; | ||
31 | res(find(im > maxVal)) = maxVal; | ||
32 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/corrDn.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/corrDn.m deleted file mode 100755 index afe09d2..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/corrDn.m +++ /dev/null | |||
@@ -1,63 +0,0 @@ | |||
1 | % RES = corrDn(IM, FILT, EDGES, STEP, START, STOP) | ||
2 | % | ||
3 | % Compute correlation of matrices IM with FILT, followed by | ||
4 | % downsampling. These arguments should be 1D or 2D matrices, and IM | ||
5 | % must be larger (in both dimensions) than FILT. The origin of filt | ||
6 | % is assumed to be floor(size(filt)/2)+1. | ||
7 | % | ||
8 | % EDGES is a string determining boundary handling: | ||
9 | % 'circular' - Circular convolution | ||
10 | % 'reflect1' - Reflect about the edge pixels | ||
11 | % 'reflect2' - Reflect, doubling the edge pixels | ||
12 | % 'repeat' - Repeat the edge pixels | ||
13 | % 'zero' - Assume values of zero outside image boundary | ||
14 | % 'extend' - Reflect and invert | ||
15 | % 'dont-compute' - Zero output when filter overhangs input boundaries | ||
16 | % | ||
17 | % Downsampling factors are determined by STEP (optional, default=[1 1]), | ||
18 | % which should be a 2-vector [y,x]. | ||
19 | % | ||
20 | % The window over which the convolution occurs is specfied by START | ||
21 | % (optional, default=[1,1], and STOP (optional, default=size(IM)). | ||
22 | % | ||
23 | % NOTE: this operation corresponds to multiplication of a signal | ||
24 | % vector by a matrix whose rows contain copies of the FILT shifted by | ||
25 | % multiples of STEP. See upConv.m for the operation corresponding to | ||
26 | % the transpose of this matrix. | ||
27 | |||
28 | % Eero Simoncelli, 6/96, revised 2/97. | ||
29 | |||
30 | function res = corrDn(im, filt, edges, step, start, stop) | ||
31 | |||
32 | %% NOTE: THIS CODE IS NOT ACTUALLY USED! (MEX FILE IS CALLED INSTEAD) | ||
33 | |||
34 | fprintf(1,'WARNING: You should compile the MEX version of "corrDn.c",\n found in the MEX subdirectory of matlabPyrTools, and put it in your matlab path. It is MUCH faster, and provides more boundary-handling options.\n'); | ||
35 | |||
36 | %------------------------------------------------------------ | ||
37 | %% OPTIONAL ARGS: | ||
38 | |||
39 | if (exist('edges') == 1) | ||
40 | if (strcmp(edges,'reflect1') ~= 1) | ||
41 | warning('Using REFLECT1 edge-handling (use MEX code for other options).'); | ||
42 | end | ||
43 | end | ||
44 | |||
45 | if (exist('step') ~= 1) | ||
46 | step = [1,1]; | ||
47 | end | ||
48 | |||
49 | if (exist('start') ~= 1) | ||
50 | start = [1,1]; | ||
51 | end | ||
52 | |||
53 | if (exist('stop') ~= 1) | ||
54 | stop = size(im); | ||
55 | end | ||
56 | |||
57 | %------------------------------------------------------------ | ||
58 | |||
59 | % Reverse order of taps in filt, to do correlation instead of convolution | ||
60 | filt = filt(size(filt,1):-1:1,size(filt,2):-1:1); | ||
61 | |||
62 | tmp = rconv2(im,filt); | ||
63 | res = tmp(start(1):step(1):stop(1),start(2):step(2):stop(2)); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/einstein.pgm b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/einstein.pgm deleted file mode 100755 index 99b974c..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/einstein.pgm +++ /dev/null | |||
Binary files differ | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/entropy2.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/entropy2.m deleted file mode 100755 index 68a2a9f..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/entropy2.m +++ /dev/null | |||
@@ -1,31 +0,0 @@ | |||
1 | % E = ENTROPY2(MTX,BINSIZE) | ||
2 | % | ||
3 | % Compute the first-order sample entropy of MTX. Samples of VEC are | ||
4 | % first discretized. Optional argument BINSIZE controls the | ||
5 | % discretization, and defaults to 256/(max(VEC)-min(VEC)). | ||
6 | % | ||
7 | % NOTE: This is a heavily biased estimate of entropy when you | ||
8 | % don't have much data. | ||
9 | |||
10 | % Eero Simoncelli, 6/96. | ||
11 | |||
12 | function res = entropy2(mtx,binsize) | ||
13 | |||
14 | %% Ensure it's a vector, not a matrix. | ||
15 | vec = mtx(:); | ||
16 | [mn,mx] = range2(vec); | ||
17 | |||
18 | if (exist('binsize') == 1) | ||
19 | nbins = max((mx-mn)/binsize, 1); | ||
20 | else | ||
21 | nbins = 256; | ||
22 | end | ||
23 | |||
24 | [bincount,bins] = histo(vec,nbins); | ||
25 | |||
26 | %% Collect non-zero bins: | ||
27 | H = bincount(find(bincount)); | ||
28 | H = H/sum(H); | ||
29 | |||
30 | res = -sum(H .* log2(H)); | ||
31 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/factorial.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/factorial.m deleted file mode 100755 index 9255f43..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/factorial.m +++ /dev/null | |||
@@ -1,16 +0,0 @@ | |||
1 | %% RES = factorial(NUM) | ||
2 | % | ||
3 | % Factorial function that works on matrices (matlab's does not). | ||
4 | |||
5 | % EPS, 11/02 | ||
6 | |||
7 | function res = factorial(num) | ||
8 | |||
9 | res = ones(size(num)); | ||
10 | |||
11 | ind = find(num > 0); | ||
12 | if ( ~isempty(ind) ) | ||
13 | subNum = num(ind); | ||
14 | res(ind) = subNum .* factorial(subNum-1); | ||
15 | end | ||
16 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/feynman.pgm b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/feynman.pgm deleted file mode 100755 index 7d14101..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/feynman.pgm +++ /dev/null | |||
Binary files differ | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/histo.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/histo.m deleted file mode 100755 index 3366301..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/histo.m +++ /dev/null | |||
@@ -1,58 +0,0 @@ | |||
1 | % [N,X] = histo(MTX, nbinsOrBinsize, binCenter); | ||
2 | % | ||
3 | % Compute a histogram of (all) elements of MTX. N contains the histogram | ||
4 | % counts, X is a vector containg the centers of the histogram bins. | ||
5 | % | ||
6 | % nbinsOrBinsize (optional, default = 101) specifies either | ||
7 | % the number of histogram bins, or the negative of the binsize. | ||
8 | % | ||
9 | % binCenter (optional, default = mean2(MTX)) specifies a center position | ||
10 | % for (any one of) the histogram bins. | ||
11 | % | ||
12 | % How does this differ from MatLab's HIST function? This function: | ||
13 | % - allows uniformly spaced bins only. | ||
14 | % +/- operates on all elements of MTX, instead of columnwise. | ||
15 | % + is much faster (approximately a factor of 80 on my machine). | ||
16 | % + allows specification of number of bins OR binsize. Default=101 bins. | ||
17 | % + allows (optional) specification of binCenter. | ||
18 | |||
19 | % Eero Simoncelli, 3/97. | ||
20 | |||
21 | function [N, X] = histo(mtx, nbins, binCtr) | ||
22 | |||
23 | %% NOTE: THIS CODE IS NOT ACTUALLY USED! (MEX FILE IS CALLED INSTEAD) | ||
24 | |||
25 | fprintf(1,'WARNING: You should compile the MEX version of "histo.c",\n found in the MEX subdirectory of matlabPyrTools, and put it in your matlab path. It is MUCH faster.\n'); | ||
26 | |||
27 | mtx = mtx(:); | ||
28 | |||
29 | %------------------------------------------------------------ | ||
30 | %% OPTIONAL ARGS: | ||
31 | |||
32 | [mn,mx] = range2(mtx); | ||
33 | |||
34 | if (exist('binCtr') ~= 1) | ||
35 | binCtr = mean(mtx); | ||
36 | end | ||
37 | |||
38 | if (exist('nbins') == 1) | ||
39 | if (nbins < 0) | ||
40 | binSize = -nbins; | ||
41 | else | ||
42 | binSize = ((mx-mn)/nbins); | ||
43 | tmpNbins = round((mx-binCtr)/binSize) - round((mn-binCtr)/binSize); | ||
44 | if (tmpNbins ~= nbins) | ||
45 | warning('Using %d bins instead of requested number (%d)',tmpNbins,nbins); | ||
46 | end | ||
47 | end | ||
48 | else | ||
49 | binSize = ((mx-mn)/101); | ||
50 | end | ||
51 | |||
52 | firstBin = binCtr + binSize*round( (mn-binCtr)/binSize ); | ||
53 | |||
54 | tmpNbins = round((mx-binCtr)/binSize) - round((mn-binCtr)/binSize); | ||
55 | |||
56 | bins = firstBin + binSize*[0:tmpNbins]; | ||
57 | |||
58 | [N, X] = hist(mtx, bins); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/histoMatch.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/histoMatch.m deleted file mode 100755 index ab82782..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/histoMatch.m +++ /dev/null | |||
@@ -1,35 +0,0 @@ | |||
1 | % RES = histoMatch(MTX, N, X) | ||
2 | % | ||
3 | % Modify elements of MTX so that normalized histogram matches that | ||
4 | % specified by vectors X and N, where N contains the histogram counts | ||
5 | % and X the histogram bin positions (see histo). | ||
6 | |||
7 | % Eero Simoncelli, 7/96. | ||
8 | |||
9 | function res = histoMatch(mtx, N, X) | ||
10 | |||
11 | if ( exist('histo') == 3 ) | ||
12 | [oN, oX] = histo(mtx(:), size(X(:),1)); | ||
13 | else | ||
14 | [oN, oX] = hist(mtx(:), size(X(:),1)); | ||
15 | end | ||
16 | |||
17 | oStep = oX(2) - oX(1); | ||
18 | oC = [0, cumsum(oN)]/sum(oN); | ||
19 | oX = [oX(1)-oStep/2, oX+oStep/2]; | ||
20 | |||
21 | N = N(:)'; | ||
22 | X = X(:)'; | ||
23 | N = N + mean(N)/(1e8); %% HACK: no empty bins ensures nC strictly monotonic | ||
24 | |||
25 | nStep = X(2) - X(1); | ||
26 | nC = [0, cumsum(N)]/sum(N); | ||
27 | nX = [X(1)-nStep/2, X+nStep/2]; | ||
28 | |||
29 | nnX = interp1(nC, nX, oC, 'linear'); | ||
30 | |||
31 | if ( exist('pointOp') == 3 ) | ||
32 | res = pointOp(mtx, nnX, oX(1), oStep); | ||
33 | else | ||
34 | res = reshape(interp1(oX, nnX, mtx(:)),size(mtx,1),size(mtx,2)); | ||
35 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/ifftshift.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/ifftshift.m deleted file mode 100755 index 2ade297..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/ifftshift.m +++ /dev/null | |||
@@ -1,15 +0,0 @@ | |||
1 | % [RES] = ifftshift (MTX) | ||
2 | % | ||
3 | % Inverse of MatLab's FFTSHIFT. That is, | ||
4 | % ifftshift(fftshift(MTX)) = MTX | ||
5 | % for any size MTX. | ||
6 | |||
7 | % Eero Simoncelli, 2/97. | ||
8 | |||
9 | function [res] = ifftshift(mtx) | ||
10 | |||
11 | sz = size(mtx); | ||
12 | DC = ceil((sz+1)./2); % location of DC term in a matlab fft. | ||
13 | |||
14 | res = [mtx(DC(1):sz(1), DC(2):sz(2)) , mtx(DC(1):sz(1), 1:DC(2)-1); ... | ||
15 | mtx(1:DC(1)-1, DC(2):sz(2)) , mtx(1:DC(1)-1, 1:DC(2)-1)]; | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/imGradient.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/imGradient.m deleted file mode 100755 index 23187e3..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/imGradient.m +++ /dev/null | |||
@@ -1,48 +0,0 @@ | |||
1 | % [dx, dy] = imGradient(im, edges) | ||
2 | % | ||
3 | % Compute the gradient of the image using smooth derivative filters | ||
4 | % optimized for accurate direction estimation. Coordinate system | ||
5 | % corresponds to standard pixel indexing: X axis points rightward. Y | ||
6 | % axis points downward. EDGES specify boundary handling (see corrDn | ||
7 | % for options). | ||
8 | |||
9 | % EPS, 1997. | ||
10 | % original filters from Int'l Conf Image Processing, 1994. | ||
11 | % updated filters 10/2003. | ||
12 | % Added to matlabPyrTools 10/2004. | ||
13 | |||
14 | function [dx, dy] = imGradient(im, edges) | ||
15 | |||
16 | %% 1D smoothing and differentiation kernels. | ||
17 | %% See Farid & Simoncelli, IEEE Trans Image Processing, 13(4):496-508, April 2004. | ||
18 | |||
19 | if (exist('edges') ~= 1) | ||
20 | edges = 'dont-compute'; | ||
21 | end | ||
22 | |||
23 | gp = [0.037659 0.249153 0.426375 0.249153 0.037659]'; | ||
24 | gd = [-0.109604 -0.276691 0.000000 0.276691 0.109604]'; | ||
25 | |||
26 | dx = corrDn(corrDn(im, gp, edges), gd', edges); | ||
27 | dy = corrDn(corrDn(im, gd, edges), gp', edges); | ||
28 | |||
29 | return | ||
30 | |||
31 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
32 | %%% TEST: | ||
33 | |||
34 | %%Make a ramp with random slope and direction | ||
35 | dir = 2*pi*rand - pi; | ||
36 | slope = 10*rand; | ||
37 | |||
38 | sz = 32 | ||
39 | im = mkRamp(sz, dir, slope); | ||
40 | [dx,dy] = imGradient(im); | ||
41 | showIm(dx + sqrt(-1)*dy); | ||
42 | |||
43 | ctr = (sz*sz/2)+sz/2; | ||
44 | slopeEst = sqrt(dx(ctr).^2 + dy(ctr).^2); | ||
45 | dirEst = atan2(dy(ctr), dx(ctr)); | ||
46 | |||
47 | [slope, slopeEst] | ||
48 | [dir, dirEst] | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/imStats.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/imStats.m deleted file mode 100755 index 3d79b4c..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/imStats.m +++ /dev/null | |||
@@ -1,41 +0,0 @@ | |||
1 | % imStats(IM1,IM2) | ||
2 | % | ||
3 | % Report image (matrix) statistics. | ||
4 | % When called on a single image IM1, report min, max, mean, stdev, | ||
5 | % and kurtosis. | ||
6 | % When called on two images (IM1 and IM2), report min, max, mean, | ||
7 | % stdev of the difference, and also SNR (relative to IM1). | ||
8 | |||
9 | % Eero Simoncelli, 6/96. | ||
10 | |||
11 | function [] = imStats(im1,im2) | ||
12 | |||
13 | if (~isreal(im1)) | ||
14 | error('Args must be real-valued matrices'); | ||
15 | end | ||
16 | |||
17 | if (exist('im2') == 1) | ||
18 | difference = im1 - im2; | ||
19 | [mn,mx] = range2(difference); | ||
20 | mean = mean2(difference); | ||
21 | v = var2(difference,mean); | ||
22 | if (v < realmin) | ||
23 | snr = Inf; | ||
24 | else | ||
25 | snr = 10 * log10(var2(im1)/v); | ||
26 | end | ||
27 | fprintf(1, 'Difference statistics:\n'); | ||
28 | fprintf(1, ' Range: [%c, %c]\n',mn,mx); | ||
29 | fprintf(1, ' Mean: %f, Stdev (rmse): %f, SNR (dB): %f\n',... | ||
30 | mean,sqrt(v),snr); | ||
31 | else | ||
32 | [mn,mx] = range2(im1); | ||
33 | mean = mean2(im1); | ||
34 | var = var2(im1); | ||
35 | stdev = sqrt(real(var))+sqrt(imag(var)); | ||
36 | kurt = kurt2(im1, mean, stdev^2); | ||
37 | fprintf(1, 'Image statistics:\n'); | ||
38 | fprintf(1, ' Range: [%f, %f]\n',mn,mx); | ||
39 | fprintf(1, ' Mean: %f, Stdev: %f, Kurtosis: %f\n',mean,stdev,kurt); | ||
40 | end | ||
41 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/innerProd.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/innerProd.m deleted file mode 100755 index da82321..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/innerProd.m +++ /dev/null | |||
@@ -1,12 +0,0 @@ | |||
1 | % RES = innerProd(MTX) | ||
2 | % | ||
3 | % Compute (MTX' * MTX) efficiently (i.e., without copying the matrix) | ||
4 | |||
5 | function res = innerProd(mtx) | ||
6 | |||
7 | fprintf(1,['WARNING: You should compile the MEX version of' ... | ||
8 | ' "innerProd.c",\n found in the MEX subdirectory' ... | ||
9 | ' of matlabPyrTools, and put it in your matlab path.' ... | ||
10 | ' It is MUCH faster and requires less memory.\n']); | ||
11 | |||
12 | res = mtx' * mtx; | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/kurt2.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/kurt2.m deleted file mode 100755 index 8351eb4..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/kurt2.m +++ /dev/null | |||
@@ -1,24 +0,0 @@ | |||
1 | % K = KURT2(MTX,MEAN,VAR) | ||
2 | % | ||
3 | % Sample kurtosis (fourth moment divided by squared variance) | ||
4 | % of a matrix. Kurtosis of a Gaussian distribution is 3. | ||
5 | % MEAN (optional) and VAR (optional) make the computation faster. | ||
6 | |||
7 | % Eero Simoncelli, 6/96. | ||
8 | |||
9 | function res = kurt2(mtx, mn, v) | ||
10 | |||
11 | if (exist('mn') ~= 1) | ||
12 | mn = mean(mean(mtx)); | ||
13 | end | ||
14 | |||
15 | if (exist('v') ~= 1) | ||
16 | v = var2(mtx,mn); | ||
17 | end | ||
18 | |||
19 | if (isreal(mtx)) | ||
20 | res = mean(mean(abs(mtx-mn).^4)) / (v^2); | ||
21 | else | ||
22 | res = mean(mean(real(mtx-mn).^4)) / (real(v)^2) + ... | ||
23 | i*mean(mean(imag(mtx-mn).^4)) / (imag(v)^2); | ||
24 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/lplot.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/lplot.m deleted file mode 100755 index 3c67d8b..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/lplot.m +++ /dev/null | |||
@@ -1,43 +0,0 @@ | |||
1 | % lplot(VEC, XRANGE) | ||
2 | % | ||
3 | % Plot VEC, a vector, in "lollipop" format. | ||
4 | % XRANGE (optional, default = [1,length(VEC)]), should be a 2-vector | ||
5 | % specifying the X positions (for labeling purposes) of the first and | ||
6 | % last sample of VEC. | ||
7 | |||
8 | % Mark Liberman, Linguistics Dept, UPenn, 1994. | ||
9 | |||
10 | function lplot(x,xrange) | ||
11 | |||
12 | if (exist('xrange') ~= 1) | ||
13 | xrange = [1,length(x)]; | ||
14 | end | ||
15 | |||
16 | msize = size(x); | ||
17 | if ( msize(2) == 1) | ||
18 | x = x'; | ||
19 | elseif (msize(1) ~= 1) | ||
20 | error('First arg must be a vector'); | ||
21 | end | ||
22 | |||
23 | if (~isreal(x)) | ||
24 | fprintf(1,'Warning: Imaginary part of signal ignored\n'); | ||
25 | x = abs(x); | ||
26 | end | ||
27 | |||
28 | N = length(x); | ||
29 | index = xrange(1) + (xrange(2)-xrange(1))*[0:(N-1)]/(N-1) | ||
30 | xinc = index(2)-index(1); | ||
31 | |||
32 | xx = [zeros(1,N);x;zeros(1,N)]; | ||
33 | indexis = [index;index;index]; | ||
34 | xdiscrete = [0 xx(:)' 0]; | ||
35 | idiscrete = [index(1)-xinc indexis(:)' index(N)+xinc]; | ||
36 | |||
37 | [mn,mx] = range2(xdiscrete); | ||
38 | ypad = (mx-mn)/12; % MAGIC NUMBER: graph padding | ||
39 | |||
40 | plot(idiscrete, xdiscrete, index, x, 'o'); | ||
41 | axis([index(1)-xinc, index(N)+xinc, mn-ypad, mx+ypad]); | ||
42 | |||
43 | return | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/lpyrHt.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/lpyrHt.m deleted file mode 100755 index d6834d7..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/lpyrHt.m +++ /dev/null | |||
@@ -1,11 +0,0 @@ | |||
1 | % [HEIGHT] = lpyrHt(INDICES) | ||
2 | % | ||
3 | % Compute height of Laplacian pyramid with given its INDICES matrix. | ||
4 | % See buildLpyr.m | ||
5 | |||
6 | % Eero Simoncelli, 6/96. | ||
7 | |||
8 | function [ht] = lpyrHt(pind) | ||
9 | |||
10 | % Don't count lowpass residual band | ||
11 | ht = size(pind,1)-1; | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/maxPyrHt.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/maxPyrHt.m deleted file mode 100755 index 84bcf29..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/maxPyrHt.m +++ /dev/null | |||
@@ -1,25 +0,0 @@ | |||
1 | % HEIGHT = maxPyrHt(IMSIZE, FILTSIZE) | ||
2 | % | ||
3 | % Compute maximum pyramid height for given image and filter sizes. | ||
4 | % Specifically: the number of corrDn operations that can be sequentially | ||
5 | % performed when subsampling by a factor of 2. | ||
6 | |||
7 | % Eero Simoncelli, 6/96. | ||
8 | |||
9 | function height = maxPyrHt(imsz, filtsz) | ||
10 | |||
11 | imsz = imsz(:); | ||
12 | filtsz = filtsz(:); | ||
13 | |||
14 | if any(imsz == 1) % 1D image | ||
15 | imsz = prod(imsz); | ||
16 | filtsz = prod(filtsz); | ||
17 | elseif any(filtsz == 1) % 2D image, 1D filter | ||
18 | filtsz = [filtsz(1); filtsz(1)]; | ||
19 | end | ||
20 | |||
21 | if any(imsz < filtsz) | ||
22 | height = 0; | ||
23 | else | ||
24 | height = 1 + maxPyrHt( floor(imsz/2), filtsz ); | ||
25 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mean2.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mean2.m deleted file mode 100755 index 177f7ac..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mean2.m +++ /dev/null | |||
@@ -1,7 +0,0 @@ | |||
1 | % M = MEAN2(MTX) | ||
2 | % | ||
3 | % Sample mean of a matrix. | ||
4 | |||
5 | function res = mean2(mtx) | ||
6 | |||
7 | res = mean(mean(mtx)); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mkAngle.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mkAngle.m deleted file mode 100755 index bd54f8d..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mkAngle.m +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | % IM = mkAngle(SIZE, PHASE, ORIGIN) | ||
2 | % | ||
3 | % Compute a matrix of dimension SIZE (a [Y X] 2-vector, or a scalar) | ||
4 | % containing samples of the polar angle (in radians, CW from the | ||
5 | % X-axis, ranging from -pi to pi), relative to angle PHASE (default = | ||
6 | % 0), about ORIGIN pixel (default = (size+1)/2). | ||
7 | |||
8 | % Eero Simoncelli, 6/96. | ||
9 | |||
10 | function [res] = mkAngle(sz, phase, origin) | ||
11 | |||
12 | sz = sz(:); | ||
13 | if (size(sz,1) == 1) | ||
14 | sz = [sz,sz]; | ||
15 | end | ||
16 | |||
17 | % ----------------------------------------------------------------- | ||
18 | % OPTIONAL args: | ||
19 | |||
20 | if (exist('origin') ~= 1) | ||
21 | origin = (sz+1)/2; | ||
22 | end | ||
23 | |||
24 | % ----------------------------------------------------------------- | ||
25 | |||
26 | [xramp,yramp] = meshgrid( [1:sz(2)]-origin(2), [1:sz(1)]-origin(1) ); | ||
27 | |||
28 | res = atan2(yramp,xramp); | ||
29 | |||
30 | if (exist('phase') == 1) | ||
31 | res = mod(res+(pi-phase),2*pi)-pi; | ||
32 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mkAngularSine.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mkAngularSine.m deleted file mode 100755 index f5238cc..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mkAngularSine.m +++ /dev/null | |||
@@ -1,42 +0,0 @@ | |||
1 | % IM = mkAngularSine(SIZE, HARMONIC, AMPL, PHASE, ORIGIN) | ||
2 | % | ||
3 | % Make an angular sinusoidal image: | ||
4 | % AMPL * sin( HARMONIC*theta + PHASE), | ||
5 | % where theta is the angle about the origin. | ||
6 | % SIZE specifies the matrix size, as for zeros(). | ||
7 | % AMPL (default = 1) and PHASE (default = 0) are optional. | ||
8 | |||
9 | % Eero Simoncelli, 2/97. | ||
10 | |||
11 | function [res] = mkAngularSine(sz, harmonic, ampl, ph, origin) | ||
12 | |||
13 | sz = sz(:); | ||
14 | if (size(sz,1) == 1) | ||
15 | sz = [sz,sz]; | ||
16 | end | ||
17 | |||
18 | mxsz = max(sz(1),sz(2)); | ||
19 | |||
20 | %------------------------------------------------------------ | ||
21 | %% OPTIONAL ARGS: | ||
22 | |||
23 | if (exist('harmonic') ~= 1) | ||
24 | harmonic = 1; | ||
25 | end | ||
26 | |||
27 | if (exist('ampl') ~= 1) | ||
28 | ampl = 1; | ||
29 | end | ||
30 | |||
31 | if (exist('ph') ~= 1) | ||
32 | ph = 0; | ||
33 | end | ||
34 | |||
35 | if (exist('origin') ~= 1) | ||
36 | origin = (sz+1)/2; | ||
37 | end | ||
38 | |||
39 | %------------------------------------------------------------ | ||
40 | |||
41 | res = ampl * sin(harmonic*mkAngle(sz,ph,origin) + ph); | ||
42 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mkDisc.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mkDisc.m deleted file mode 100755 index 33e7d6d..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mkDisc.m +++ /dev/null | |||
@@ -1,61 +0,0 @@ | |||
1 | % IM = mkDisc(SIZE, RADIUS, ORIGIN, TWIDTH, VALS) | ||
2 | % | ||
3 | % Make a "disk" image. SIZE specifies the matrix size, as for | ||
4 | % zeros(). RADIUS (default = min(size)/4) specifies the radius of | ||
5 | % the disk. ORIGIN (default = (size+1)/2) specifies the | ||
6 | % location of the disk center. TWIDTH (in pixels, default = 2) | ||
7 | % specifies the width over which a soft threshold transition is made. | ||
8 | % VALS (default = [0,1]) should be a 2-vector containing the | ||
9 | % intensity value inside and outside the disk. | ||
10 | |||
11 | % Eero Simoncelli, 6/96. | ||
12 | |||
13 | function [res] = mkDisc(sz, rad, origin, twidth, vals) | ||
14 | |||
15 | if (nargin < 1) | ||
16 | error('Must pass at least a size argument'); | ||
17 | end | ||
18 | |||
19 | sz = sz(:); | ||
20 | if (size(sz,1) == 1) | ||
21 | sz = [sz sz]; | ||
22 | end | ||
23 | |||
24 | %------------------------------------------------------------ | ||
25 | % OPTIONAL ARGS: | ||
26 | |||
27 | if (exist('rad') ~= 1) | ||
28 | rad = min(sz(1),sz(2))/4; | ||
29 | end | ||
30 | |||
31 | if (exist('origin') ~= 1) | ||
32 | origin = (sz+1)./2; | ||
33 | end | ||
34 | |||
35 | if (exist('twidth') ~= 1) | ||
36 | twidth = 2; | ||
37 | end | ||
38 | |||
39 | if (exist('vals') ~= 1) | ||
40 | vals = [1,0]; | ||
41 | end | ||
42 | |||
43 | %------------------------------------------------------------ | ||
44 | |||
45 | res = mkR(sz,1,origin); | ||
46 | |||
47 | if (abs(twidth) < realmin) | ||
48 | res = vals(2) + (vals(1) - vals(2)) * (res <= rad); | ||
49 | else | ||
50 | [Xtbl,Ytbl] = rcosFn(twidth, rad, [vals(1), vals(2)]); | ||
51 | res = pointOp(res, Ytbl, Xtbl(1), Xtbl(2)-Xtbl(1), 0); | ||
52 | % | ||
53 | % OLD interp1 VERSION: | ||
54 | % res = res(:); | ||
55 | % Xtbl(1) = min(res); | ||
56 | % Xtbl(size(Xtbl,2)) = max(res); | ||
57 | % res = reshape(interp1(Xtbl,Ytbl,res), sz(1), sz(2)); | ||
58 | % | ||
59 | end | ||
60 | |||
61 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mkFract.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mkFract.m deleted file mode 100755 index af95cd5..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mkFract.m +++ /dev/null | |||
@@ -1,36 +0,0 @@ | |||
1 | % IM = mkFract(SIZE, FRACT_DIM) | ||
2 | % | ||
3 | % Make a matrix of dimensions SIZE (a [Y X] 2-vector, or a scalar) | ||
4 | % containing fractal (pink) noise with power spectral density of the | ||
5 | % form: 1/f^(5-2*FRACT_DIM). Image variance is normalized to 1.0. | ||
6 | % FRACT_DIM defaults to 1.0 | ||
7 | |||
8 | % Eero Simoncelli, 6/96. | ||
9 | |||
10 | %% TODO: Verify that this matches Mandelbrot defn of fractal dimension. | ||
11 | %% Make this more efficient! | ||
12 | |||
13 | function res = mkFract(dims, fract_dim) | ||
14 | |||
15 | if (exist('fract_dim') ~= 1) | ||
16 | fract_dim = 1.0; | ||
17 | end | ||
18 | |||
19 | res = randn(dims); | ||
20 | fres = fft2(res); | ||
21 | |||
22 | sz = size(res); | ||
23 | ctr = ceil((sz+1)./2); | ||
24 | |||
25 | shape = ifftshift(mkR(sz, -(2.5-fract_dim), ctr)); | ||
26 | shape(1,1) = 1; %%DC term | ||
27 | |||
28 | fres = shape .* fres; | ||
29 | fres = ifft2(fres); | ||
30 | |||
31 | if (max(max(abs(imag(fres)))) > 1e-10) | ||
32 | error('Symmetry error in creating fractal'); | ||
33 | else | ||
34 | res = real(fres); | ||
35 | res = res / sqrt(var2(res)); | ||
36 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mkGaussian.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mkGaussian.m deleted file mode 100755 index fa8a554..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mkGaussian.m +++ /dev/null | |||
@@ -1,58 +0,0 @@ | |||
1 | % IM = mkGaussian(SIZE, COVARIANCE, MEAN, AMPLITUDE) | ||
2 | % | ||
3 | % Compute a matrix with dimensions SIZE (a [Y X] 2-vector, or a | ||
4 | % scalar) containing a Gaussian function, centered at pixel position | ||
5 | % specified by MEAN (default = (size+1)/2), with given COVARIANCE (can | ||
6 | % be a scalar, 2-vector, or 2x2 matrix. Default = (min(size)/6)^2), | ||
7 | % and AMPLITUDE. AMPLITUDE='norm' (default) will produce a | ||
8 | % probability-normalized function. All but the first argument are | ||
9 | % optional. | ||
10 | |||
11 | % Eero Simoncelli, 6/96. | ||
12 | |||
13 | function [res] = mkGaussian(sz, cov, mn, ampl) | ||
14 | |||
15 | sz = sz(:); | ||
16 | if (size(sz,1) == 1) | ||
17 | sz = [sz,sz]; | ||
18 | end | ||
19 | |||
20 | %------------------------------------------------------------ | ||
21 | %% OPTIONAL ARGS: | ||
22 | |||
23 | if (exist('cov') ~= 1) | ||
24 | cov = (min(sz(1),sz(2))/6)^2; | ||
25 | end | ||
26 | |||
27 | if (exist('mn') ~= 1) | ||
28 | mn = (sz+1)/2; | ||
29 | end | ||
30 | |||
31 | if (exist('ampl') ~= 1) | ||
32 | ampl = 'norm'; | ||
33 | end | ||
34 | |||
35 | %------------------------------------------------------------ | ||
36 | |||
37 | [xramp,yramp] = meshgrid([1:sz(2)]-mn(2),[1:sz(1)]-mn(1)); | ||
38 | |||
39 | if (sum(size(cov)) == 2) % scalar | ||
40 | if (strcmp(ampl,'norm')) | ||
41 | ampl = 1/(2*pi*cov(1)); | ||
42 | end | ||
43 | e = (xramp.^2 + yramp.^2)/(-2 * cov); | ||
44 | elseif (sum(size(cov)) == 3) % a 2-vector | ||
45 | if (strcmp(ampl,'norm')) | ||
46 | ampl = 1/(2*pi*sqrt(cov(1)*cov(2))); | ||
47 | end | ||
48 | e = xramp.^2/(-2 * cov(2)) + yramp.^2/(-2 * cov(1)); | ||
49 | else | ||
50 | if (strcmp(ampl,'norm')) | ||
51 | ampl = 1/(2*pi*sqrt(det(cov))); | ||
52 | end | ||
53 | cov = -inv(cov)/2; | ||
54 | e = cov(2,2)*xramp.^2 + (cov(1,2)+cov(2,1))*(xramp.*yramp) ... | ||
55 | + cov(1,1)*yramp.^2; | ||
56 | end | ||
57 | |||
58 | res = ampl .* exp(e); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mkImpulse.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mkImpulse.m deleted file mode 100755 index 9844ee8..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mkImpulse.m +++ /dev/null | |||
@@ -1,25 +0,0 @@ | |||
1 | % IM = mkImpulse(SIZE, ORIGIN, AMPLITUDE) | ||
2 | % | ||
3 | % Compute a matrix of dimension SIZE (a [Y X] 2-vector, or a scalar) | ||
4 | % containing a single non-zero entry, at position ORIGIN (defaults to | ||
5 | % ceil(size/2)), of value AMPLITUDE (defaults to 1). | ||
6 | |||
7 | % Eero Simoncelli, 6/96. | ||
8 | |||
9 | function [res] = mkImpulse(sz, origin, amplitude) | ||
10 | |||
11 | sz = sz(:)'; | ||
12 | if (size(sz,2) == 1) | ||
13 | sz = [sz sz]; | ||
14 | end | ||
15 | |||
16 | if (exist('origin') ~= 1) | ||
17 | origin = ceil(sz/2); | ||
18 | end | ||
19 | |||
20 | if (exist('amplitude') ~= 1) | ||
21 | amplitude = 1; | ||
22 | end | ||
23 | |||
24 | res = zeros(sz); | ||
25 | res(origin(1),origin(2)) = amplitude; | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mkR.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mkR.m deleted file mode 100755 index a1e8448..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mkR.m +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | % IM = mkR(SIZE, EXPT, ORIGIN) | ||
2 | % | ||
3 | % Compute a matrix of dimension SIZE (a [Y X] 2-vector, or a scalar) | ||
4 | % containing samples of a radial ramp function, raised to power EXPT | ||
5 | % (default = 1), with given ORIGIN (default = (size+1)/2, [1 1] = | ||
6 | % upper left). All but the first argument are optional. | ||
7 | |||
8 | % Eero Simoncelli, 6/96. | ||
9 | |||
10 | function [res] = mkR(sz, expt, origin) | ||
11 | |||
12 | sz = sz(:); | ||
13 | if (size(sz,1) == 1) | ||
14 | sz = [sz,sz]; | ||
15 | end | ||
16 | |||
17 | % ----------------------------------------------------------------- | ||
18 | % OPTIONAL args: | ||
19 | |||
20 | if (exist('expt') ~= 1) | ||
21 | expt = 1; | ||
22 | end | ||
23 | |||
24 | if (exist('origin') ~= 1) | ||
25 | origin = (sz+1)/2; | ||
26 | end | ||
27 | |||
28 | % ----------------------------------------------------------------- | ||
29 | |||
30 | [xramp,yramp] = meshgrid( [1:sz(2)]-origin(2), [1:sz(1)]-origin(1) ); | ||
31 | |||
32 | res = (xramp.^2 + yramp.^2).^(expt/2); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mkRamp.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mkRamp.m deleted file mode 100755 index dd37164..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mkRamp.m +++ /dev/null | |||
@@ -1,47 +0,0 @@ | |||
1 | % IM = mkRamp(SIZE, DIRECTION, SLOPE, INTERCEPT, ORIGIN) | ||
2 | % | ||
3 | % Compute a matrix of dimension SIZE (a [Y X] 2-vector, or a scalar) | ||
4 | % containing samples of a ramp function, with given gradient DIRECTION | ||
5 | % (radians, CW from X-axis, default = 0), SLOPE (per pixel, default = | ||
6 | % 1), and a value of INTERCEPT (default = 0) at the ORIGIN (default = | ||
7 | % (size+1)/2, [1 1] = upper left). All but the first argument are | ||
8 | % optional. | ||
9 | |||
10 | % Eero Simoncelli, 6/96. 2/97: adjusted coordinate system. | ||
11 | |||
12 | function [res] = mkRamp(sz, dir, slope, intercept, origin) | ||
13 | |||
14 | sz = sz(:); | ||
15 | if (size(sz,1) == 1) | ||
16 | sz = [sz,sz]; | ||
17 | end | ||
18 | |||
19 | % ----------------------------------------------------------------- | ||
20 | % OPTIONAL args: | ||
21 | |||
22 | if (exist('dir') ~= 1) | ||
23 | dir = 0; | ||
24 | end | ||
25 | |||
26 | if (exist('slope') ~= 1) | ||
27 | slope = 1; | ||
28 | end | ||
29 | |||
30 | if (exist('intercept') ~= 1) | ||
31 | intercept = 0; | ||
32 | end | ||
33 | |||
34 | if (exist('origin') ~= 1) | ||
35 | origin = (sz+1)/2; | ||
36 | end | ||
37 | |||
38 | % ----------------------------------------------------------------- | ||
39 | |||
40 | xinc = slope*cos(dir); | ||
41 | yinc = slope*sin(dir); | ||
42 | |||
43 | [xramp,yramp] = meshgrid( xinc*([1:sz(2)]-origin(2)), ... | ||
44 | yinc*([1:sz(1)]-origin(1)) ); | ||
45 | |||
46 | res = intercept + xramp + yramp; | ||
47 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mkSine.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mkSine.m deleted file mode 100755 index 147eb01..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mkSine.m +++ /dev/null | |||
@@ -1,67 +0,0 @@ | |||
1 | % IM = mkSine(SIZE, PERIOD, DIRECTION, AMPLITUDE, PHASE, ORIGIN) | ||
2 | % or | ||
3 | % IM = mkSine(SIZE, FREQ, AMPLITUDE, PHASE, ORIGIN) | ||
4 | % | ||
5 | % Compute a matrix of dimension SIZE (a [Y X] 2-vector, or a scalar) | ||
6 | % containing samples of a 2D sinusoid, with given PERIOD (in pixels), | ||
7 | % DIRECTION (radians, CW from X-axis, default = 0), AMPLITUDE (default | ||
8 | % = 1), and PHASE (radians, relative to ORIGIN, default = 0). ORIGIN | ||
9 | % defaults to the center of the image. | ||
10 | % | ||
11 | % In the second form, FREQ is a 2-vector of frequencies (radians/pixel). | ||
12 | |||
13 | % Eero Simoncelli, 6/96. | ||
14 | |||
15 | function [res] = mkSine(sz, per_freq, dir_amp, amp_phase, phase_orig, orig) | ||
16 | |||
17 | %------------------------------------------------------------ | ||
18 | %% OPTIONAL ARGS: | ||
19 | |||
20 | if (prod(size(per_freq)) == 2) | ||
21 | frequency = norm(per_freq); | ||
22 | direction = atan2(per_freq(1),per_freq(2)); | ||
23 | if (exist('dir_amp') == 1) | ||
24 | amplitude = dir_amp; | ||
25 | else | ||
26 | amplitude = 1; | ||
27 | end | ||
28 | if (exist('amp_phase') == 1) | ||
29 | phase = amp_phase; | ||
30 | else | ||
31 | phase = 0; | ||
32 | end | ||
33 | if (exist('phase_orig') == 1) | ||
34 | origin = phase_orig; | ||
35 | end | ||
36 | if (exist('orig') == 1) | ||
37 | error('Too many arguments for (second form) of mkSine'); | ||
38 | end | ||
39 | else | ||
40 | frequency = 2*pi/per_freq; | ||
41 | if (exist('dir_amp') == 1) | ||
42 | direction = dir_amp; | ||
43 | else | ||
44 | direction = 0; | ||
45 | end | ||
46 | if (exist('amp_phase') == 1) | ||
47 | amplitude = amp_phase; | ||
48 | else | ||
49 | amplitude = 1; | ||
50 | end | ||
51 | if (exist('phase_orig') == 1) | ||
52 | phase = phase_orig; | ||
53 | else | ||
54 | phase = 0; | ||
55 | end | ||
56 | if (exist('orig') == 1) | ||
57 | origin = orig; | ||
58 | end | ||
59 | end | ||
60 | |||
61 | %------------------------------------------------------------ | ||
62 | |||
63 | if (exist('origin') == 1) | ||
64 | res = amplitude*sin(mkRamp(sz, direction, frequency, phase, origin)); | ||
65 | else | ||
66 | res = amplitude*sin(mkRamp(sz, direction, frequency, phase)); | ||
67 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mkSquare.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mkSquare.m deleted file mode 100755 index 84ef466..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mkSquare.m +++ /dev/null | |||
@@ -1,89 +0,0 @@ | |||
1 | % IM = mkSquare(SIZE, PERIOD, DIRECTION, AMPLITUDE, PHASE, ORIGIN, TWIDTH) | ||
2 | % or | ||
3 | % IM = mkSine(SIZE, FREQ, AMPLITUDE, PHASE, ORIGIN, TWIDTH) | ||
4 | % | ||
5 | % Compute a matrix of dimension SIZE (a [Y X] 2-vector, or a scalar) | ||
6 | % containing samples of a 2D square wave, with given PERIOD (in | ||
7 | % pixels), DIRECTION (radians, CW from X-axis, default = 0), AMPLITUDE | ||
8 | % (default = 1), and PHASE (radians, relative to ORIGIN, default = 0). | ||
9 | % ORIGIN defaults to the center of the image. TWIDTH specifies width | ||
10 | % of raised-cosine edges on the bars of the grating (default = | ||
11 | % min(2,period/3)). | ||
12 | % | ||
13 | % In the second form, FREQ is a 2-vector of frequencies (radians/pixel). | ||
14 | |||
15 | % Eero Simoncelli, 6/96. | ||
16 | |||
17 | % TODO: Add duty cycle. | ||
18 | |||
19 | function [res] = mkSquare(sz, per_freq, dir_amp, amp_phase, phase_orig, orig_twidth, twidth) | ||
20 | |||
21 | %------------------------------------------------------------ | ||
22 | %% OPTIONAL ARGS: | ||
23 | |||
24 | if (prod(size(per_freq)) == 2) | ||
25 | frequency = norm(per_freq); | ||
26 | direction = atan2(per_freq(1),per_freq(2)); | ||
27 | if (exist('dir_amp') == 1) | ||
28 | amplitude = dir_amp; | ||
29 | else | ||
30 | amplitude = 1; | ||
31 | end | ||
32 | if (exist('amp_phase') == 1) | ||
33 | phase = amp_phase; | ||
34 | else | ||
35 | phase = 0; | ||
36 | end | ||
37 | if (exist('phase_orig') == 1) | ||
38 | origin = phase_orig; | ||
39 | end | ||
40 | if (exist('orig_twidth') == 1) | ||
41 | transition = orig_twidth; | ||
42 | else | ||
43 | transition = min(2,2*pi/(3*frequency)); | ||
44 | end | ||
45 | if (exist('twidth') == 1) | ||
46 | error('Too many arguments for (second form) of mkSine'); | ||
47 | end | ||
48 | else | ||
49 | frequency = 2*pi/per_freq; | ||
50 | if (exist('dir_amp') == 1) | ||
51 | direction = dir_amp; | ||
52 | else | ||
53 | direction = 0; | ||
54 | end | ||
55 | if (exist('amp_phase') == 1) | ||
56 | amplitude = amp_phase; | ||
57 | else | ||
58 | amplitude = 1; | ||
59 | end | ||
60 | if (exist('phase_orig') == 1) | ||
61 | phase = phase_orig; | ||
62 | else | ||
63 | phase = 0; | ||
64 | end | ||
65 | if (exist('orig_twidth') == 1) | ||
66 | origin = orig_twidth; | ||
67 | end | ||
68 | if (exist('twidth') == 1) | ||
69 | transition = twidth; | ||
70 | else | ||
71 | transition = min(2,2*pi/(3*frequency)); | ||
72 | end | ||
73 | |||
74 | end | ||
75 | |||
76 | %------------------------------------------------------------ | ||
77 | |||
78 | if (exist('origin') == 1) | ||
79 | res = mkRamp(sz, direction, frequency, phase, origin) - pi/2; | ||
80 | else | ||
81 | res = mkRamp(sz, direction, frequency, phase) - pi/2; | ||
82 | end | ||
83 | |||
84 | [Xtbl,Ytbl] = rcosFn(transition*frequency,pi/2,[-amplitude amplitude]); | ||
85 | |||
86 | res = pointOp(abs(mod(res+pi, 2*pi)-pi),Ytbl,Xtbl(1),Xtbl(2)-Xtbl(1),0); | ||
87 | |||
88 | % OLD threshold version: | ||
89 | %res = amplitude * (mod(res,2*pi) < pi); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mkZonePlate.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mkZonePlate.m deleted file mode 100755 index 2b6a4a5..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mkZonePlate.m +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | % IM = mkZonePlate(SIZE, AMPL, PHASE) | ||
2 | % | ||
3 | % Make a "zone plate" image: | ||
4 | % AMPL * cos( r^2 + PHASE) | ||
5 | % SIZE specifies the matrix size, as for zeros(). | ||
6 | % AMPL (default = 1) and PHASE (default = 0) are optional. | ||
7 | |||
8 | % Eero Simoncelli, 6/96. | ||
9 | |||
10 | function [res] = mkZonePlate(sz, ampl, ph) | ||
11 | |||
12 | sz = sz(:); | ||
13 | if (size(sz,1) == 1) | ||
14 | sz = [sz,sz]; | ||
15 | end | ||
16 | |||
17 | mxsz = max(sz(1),sz(2)); | ||
18 | |||
19 | %------------------------------------------------------------ | ||
20 | %% OPTIONAL ARGS: | ||
21 | |||
22 | if (exist('ampl') ~= 1) | ||
23 | ampl = 1; | ||
24 | end | ||
25 | |||
26 | if (exist('ph') ~= 1) | ||
27 | ph = 0; | ||
28 | end | ||
29 | |||
30 | %------------------------------------------------------------ | ||
31 | |||
32 | res = ampl * cos( (pi/mxsz) * mkR(sz,2) + ph ); | ||
33 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mod.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mod.m deleted file mode 100755 index 21167e5..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/mod.m +++ /dev/null | |||
@@ -1,14 +0,0 @@ | |||
1 | % M = mod(A,B) | ||
2 | % | ||
3 | % Modulus operator: returns A mod B. | ||
4 | % Works on matrics, vectors or scalars. | ||
5 | % | ||
6 | % NOTE: This function is a Matlab-5 builtin, but was missing from Matlab-4. | ||
7 | |||
8 | % Eero Simoncelli, 7/96. | ||
9 | |||
10 | function m = mod(a,n) | ||
11 | |||
12 | m = a - n .* floor(a./n); | ||
13 | return; | ||
14 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/modulateFlip.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/modulateFlip.m deleted file mode 100755 index eb27303..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/modulateFlip.m +++ /dev/null | |||
@@ -1,19 +0,0 @@ | |||
1 | % [HFILT] = modulateFlipShift(LFILT) | ||
2 | % | ||
3 | % QMF/Wavelet highpass filter construction: modulate by (-1)^n, | ||
4 | % reverse order (and shift by one, which is handled by the convolution | ||
5 | % routines). This is an extension of the original definition of QMF's | ||
6 | % (e.g., see Simoncelli90). | ||
7 | |||
8 | % Eero Simoncelli, 7/96. | ||
9 | |||
10 | function [hfilt] = modulateFlipShift(lfilt) | ||
11 | |||
12 | lfilt = lfilt(:); | ||
13 | |||
14 | sz = size(lfilt,1); | ||
15 | sz2 = ceil(sz/2); | ||
16 | |||
17 | ind = [sz:-1:1]'; | ||
18 | |||
19 | hfilt = lfilt(ind) .* (-1).^(ind-sz2); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/namedFilter.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/namedFilter.m deleted file mode 100755 index 0689dbc..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/namedFilter.m +++ /dev/null | |||
@@ -1,71 +0,0 @@ | |||
1 | % KERNEL = NAMED_FILTER(NAME) | ||
2 | % | ||
3 | % Some standard 1D filter kernels. These are scaled such that | ||
4 | % their L2-norm is 1.0. | ||
5 | % | ||
6 | % binomN - binomial coefficient filter of order N-1 | ||
7 | % haar: - Haar wavelet. | ||
8 | % qmf8, qmf12, qmf16 - Symmetric Quadrature Mirror Filters [Johnston80] | ||
9 | % daub2,daub3,daub4 - Daubechies wavelet [Daubechies88]. | ||
10 | % qmf5, qmf9, qmf13: - Symmetric Quadrature Mirror Filters [Simoncelli88,Simoncelli90] | ||
11 | % | ||
12 | % See bottom of file for full citations. | ||
13 | |||
14 | % Eero Simoncelli, 6/96. | ||
15 | |||
16 | function [kernel] = named_filter(name) | ||
17 | |||
18 | if strcmp(name(1:min(5,size(name,2))), 'binom') | ||
19 | kernel = sqrt(2) * binomialFilter(str2num(name(6:size(name,2)))); | ||
20 | elseif strcmp(name,'qmf5') | ||
21 | kernel = [-0.076103 0.3535534 0.8593118 0.3535534 -0.076103]'; | ||
22 | elseif strcmp(name,'qmf9') | ||
23 | kernel = [0.02807382 -0.060944743 -0.073386624 0.41472545 0.7973934 ... | ||
24 | 0.41472545 -0.073386624 -0.060944743 0.02807382]'; | ||
25 | elseif strcmp(name,'qmf13') | ||
26 | kernel = [-0.014556438 0.021651438 0.039045125 -0.09800052 ... | ||
27 | -0.057827797 0.42995453 0.7737113 0.42995453 -0.057827797 ... | ||
28 | -0.09800052 0.039045125 0.021651438 -0.014556438]'; | ||
29 | elseif strcmp(name,'qmf8') | ||
30 | kernel = sqrt(2) * [0.00938715 -0.07065183 0.06942827 0.4899808 ... | ||
31 | 0.4899808 0.06942827 -0.07065183 0.00938715 ]'; | ||
32 | elseif strcmp(name,'qmf12') | ||
33 | kernel = sqrt(2) * [-0.003809699 0.01885659 -0.002710326 -0.08469594 ... | ||
34 | 0.08846992 0.4843894 0.4843894 0.08846992 -0.08469594 -0.002710326 ... | ||
35 | 0.01885659 -0.003809699 ]'; | ||
36 | elseif strcmp(name,'qmf16') | ||
37 | kernel = sqrt(2) * [0.001050167 -0.005054526 -0.002589756 0.0276414 -0.009666376 ... | ||
38 | -0.09039223 0.09779817 0.4810284 0.4810284 0.09779817 -0.09039223 -0.009666376 ... | ||
39 | 0.0276414 -0.002589756 -0.005054526 0.001050167 ]'; | ||
40 | elseif strcmp(name,'haar') | ||
41 | kernel = [1 1]' / sqrt(2); | ||
42 | elseif strcmp(name,'daub2') | ||
43 | kernel = [0.482962913145 0.836516303738 0.224143868042 -0.129409522551]'; | ||
44 | elseif strcmp(name,'daub3') | ||
45 | kernel = [0.332670552950 0.806891509311 0.459877502118 -0.135011020010 ... | ||
46 | -0.085441273882 0.035226291882]'; | ||
47 | elseif strcmp(name,'daub4') | ||
48 | kernel = [0.230377813309 0.714846570553 0.630880767930 -0.027983769417 ... | ||
49 | -0.187034811719 0.030841381836 0.032883011667 -0.010597401785]'; | ||
50 | elseif strcmp(name,'gauss5') % for backward-compatibility | ||
51 | kernel = sqrt(2) * [0.0625 0.25 0.375 0.25 0.0625]'; | ||
52 | elseif strcmp(name,'gauss3') % for backward-compatibility | ||
53 | kernel = sqrt(2) * [0.25 0.5 0.25]'; | ||
54 | else | ||
55 | error(sprintf('Bad filter name: %s\n',name)); | ||
56 | end | ||
57 | |||
58 | % [Johnston80] - J D Johnston, "A filter family designed for use in quadrature | ||
59 | % mirror filter banks", Proc. ICASSP, pp 291-294, 1980. | ||
60 | % | ||
61 | % [Daubechies88] - I Daubechies, "Orthonormal bases of compactly supported wavelets", | ||
62 | % Commun. Pure Appl. Math, vol. 42, pp 909-996, 1988. | ||
63 | % | ||
64 | % [Simoncelli88] - E P Simoncelli, "Orthogonal sub-band image transforms", | ||
65 | % PhD Thesis, MIT Dept. of Elec. Eng. and Comp. Sci. May 1988. | ||
66 | % Also available as: MIT Media Laboratory Vision and Modeling Technical | ||
67 | % Report #100. | ||
68 | % | ||
69 | % [Simoncelli90] - E P Simoncelli and E H Adelson, "Subband image coding", | ||
70 | % Subband Transforms, chapter 4, ed. John W Woods, Kluwer Academic | ||
71 | % Publishers, Norwell, MA, 1990, pp 143--192. | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/nextFig.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/nextFig.m deleted file mode 100755 index e0ac73f..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/nextFig.m +++ /dev/null | |||
@@ -1,19 +0,0 @@ | |||
1 | % nextFig (MAXFIGS, SKIP) | ||
2 | % | ||
3 | % Make figure number mod((GCF+SKIP), MAXFIGS) the current figure. | ||
4 | % MAXFIGS is optional, and defaults to 2. | ||
5 | % SKIP is optional, and defaults to 1. | ||
6 | |||
7 | % Eero Simoncelli, 2/97. | ||
8 | |||
9 | function nextFig(maxfigs, skip) | ||
10 | |||
11 | if (exist('maxfigs') ~= 1) | ||
12 | maxfigs = 2; | ||
13 | end | ||
14 | |||
15 | if (exist('skip') ~= 1) | ||
16 | skip = 1; | ||
17 | end | ||
18 | |||
19 | figure(1+mod(gcf-1+skip,maxfigs)); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/pgmRead.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/pgmRead.m deleted file mode 100755 index 86c3b62..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/pgmRead.m +++ /dev/null | |||
@@ -1,59 +0,0 @@ | |||
1 | % IM = pgmRead( FILENAME ) | ||
2 | % | ||
3 | % Load a pgm image into a MatLab matrix. | ||
4 | % This format is accessible from the XV image browsing utility. | ||
5 | % Only works for 8bit gray images (raw or ascii) | ||
6 | |||
7 | % Hany Farid, Spring '96. Modified by Eero Simoncelli, 6/96. | ||
8 | |||
9 | function im = pgmRead( fname ); | ||
10 | |||
11 | [fid,msg] = fopen( fname, 'r' ); | ||
12 | |||
13 | if (fid == -1) | ||
14 | error(msg); | ||
15 | end | ||
16 | |||
17 | %%% First line contains ID string: | ||
18 | %%% "P1" = ascii bitmap, "P2" = ascii greymap, | ||
19 | %%% "P3" = ascii pixmap, "P4" = raw bitmap, | ||
20 | %%% "P5" = raw greymap, "P6" = raw pixmap | ||
21 | TheLine = fgetl(fid); | ||
22 | format = TheLine; | ||
23 | |||
24 | if ~((format(1:2) == 'P2') | (format(1:2) == 'P5')) | ||
25 | error('PGM file must be of type P2 or P5'); | ||
26 | end | ||
27 | |||
28 | %%% Any number of comment lines | ||
29 | TheLine = fgetl(fid); | ||
30 | while TheLine(1) == '#' | ||
31 | TheLine = fgetl(fid); | ||
32 | end | ||
33 | |||
34 | %%% dimensions | ||
35 | sz = sscanf(TheLine,'%d',2); | ||
36 | xdim = sz(1); | ||
37 | ydim = sz(2); | ||
38 | sz = xdim * ydim; | ||
39 | |||
40 | %%% Maximum pixel value | ||
41 | TheLine = fgetl(fid); | ||
42 | maxval = sscanf(TheLine, '%d',1); | ||
43 | |||
44 | %%im = zeros(dim,1); | ||
45 | if (format(2) == '2') | ||
46 | [im,count] = fscanf(fid,'%d',sz); | ||
47 | else | ||
48 | [im,count] = fread(fid,sz,'uchar'); | ||
49 | end | ||
50 | |||
51 | fclose(fid); | ||
52 | |||
53 | if (count == sz) | ||
54 | im = reshape( im, xdim, ydim )'; | ||
55 | else | ||
56 | fprintf(1,'Warning: File ended early!'); | ||
57 | im = reshape( [im ; zeros(sz-count,1)], xdim, ydim)'; | ||
58 | end | ||
59 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/pgmWrite.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/pgmWrite.m deleted file mode 100755 index 09c14c9..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/pgmWrite.m +++ /dev/null | |||
@@ -1,120 +0,0 @@ | |||
1 | % RANGE = pgmWrite(MTX, FILENAME, RANGE, TYPE, COMMENT) | ||
2 | % | ||
3 | % Write a MatLab matrix to a pgm (graylevel image) file. | ||
4 | % This format is accessible from the XV image browsing utility. | ||
5 | % | ||
6 | % RANGE (optional) is a 2-vector specifying the values that map to | ||
7 | % black and white, respectively. Passing a value of 'auto' (default) | ||
8 | % sets RANGE=[min,max] (as in MatLab's imagesc). 'auto2' sets | ||
9 | % RANGE=[mean-2*stdev, mean+2*stdev]. 'auto3' sets | ||
10 | % RANGE=[p1-(p2-p1)/8, p2+(p2-p1)/8], where p1 is the 10th percentile | ||
11 | % value of the sorted MATRIX samples, and p2 is the 90th percentile | ||
12 | % value. | ||
13 | % | ||
14 | % TYPE (optional) should be 'raw' or 'ascii'. Defaults to 'raw'. | ||
15 | |||
16 | % Hany Farid, Spring '96. Modified by Eero Simoncelli, 6/96. | ||
17 | |||
18 | function range = pgmWrite(mtx, fname, range, type, comment ); | ||
19 | |||
20 | [fid,msg] = fopen( fname, 'w' ); | ||
21 | |||
22 | if (fid == -1) | ||
23 | error(msg); | ||
24 | end | ||
25 | |||
26 | %------------------------------------------------------------ | ||
27 | %% optional ARGS: | ||
28 | |||
29 | if (exist('range') ~= 1) | ||
30 | range = 'auto'; | ||
31 | end | ||
32 | |||
33 | if (exist('type') ~= 1) | ||
34 | type = 'raw'; | ||
35 | end | ||
36 | %------------------------------------------------------------ | ||
37 | |||
38 | %% Automatic range calculation: | ||
39 | if (strcmp(range,'auto1') | strcmp(range,'auto')) | ||
40 | [mn,mx] = range2(mtx); | ||
41 | range = [mn,mx]; | ||
42 | |||
43 | elseif strcmp(range,'auto2') | ||
44 | stdev = sqrt(var2(mtx)); | ||
45 | av = mean2(mtx); | ||
46 | range = [av-2*stdev,av+2*stdev]; % MAGIC NUMBER: 2 stdevs | ||
47 | |||
48 | elseif strcmp(range, 'auto3') | ||
49 | percentile = 0.1; % MAGIC NUMBER: 0<p<0.5 | ||
50 | [N,X] = histo(mtx); | ||
51 | binsz = X(2)-X(1); | ||
52 | N = N+1e-10; % Ensure cumsum will be monotonic for call to interp1 | ||
53 | cumN = [0, cumsum(N)]/sum(N); | ||
54 | cumX = [X(1)-binsz, X] + (binsz/2); | ||
55 | ctrRange = interp1(cumN,cumX, [percentile, 1-percentile]); | ||
56 | range = mean(ctrRange) + (ctrRange-mean(ctrRange))/(1-2*percentile); | ||
57 | |||
58 | elseif isstr(range) | ||
59 | error(sprintf('Bad RANGE argument: %s',range)) | ||
60 | |||
61 | end | ||
62 | |||
63 | if ((range(2) - range(1)) <= eps) | ||
64 | range(1) = range(1) - 0.5; | ||
65 | range(2) = range(2) + 0.5; | ||
66 | end | ||
67 | |||
68 | |||
69 | %%% First line contains ID string: | ||
70 | %%% "P1" = ascii bitmap, "P2" = ascii greymap, | ||
71 | %%% "P3" = ascii pixmap, "P4" = raw bitmap, | ||
72 | %%% "P5" = raw greymap, "P6" = raw pixmap | ||
73 | if strcmp(type,'raw') | ||
74 | fprintf(fid,'P5\n'); | ||
75 | format = 5; | ||
76 | elseif strcmp(type,'ascii') | ||
77 | fprintf(fid,'P2\n'); | ||
78 | format = 2; | ||
79 | else | ||
80 | error(sprintf('PGMWRITE: Bad type argument: %s',type)); | ||
81 | end | ||
82 | |||
83 | fprintf(fid,'# MatLab PGMWRITE file, saved %s\n',date); | ||
84 | |||
85 | if (exist('comment') == 1) | ||
86 | fprintf(fid,'# %s\n', comment); | ||
87 | end | ||
88 | |||
89 | %%% dimensions | ||
90 | fprintf(fid,'%d %d\n',size(mtx,2),size(mtx,1)); | ||
91 | |||
92 | %%% Maximum pixel value | ||
93 | fprintf(fid,'255\n'); | ||
94 | |||
95 | |||
96 | %% MatLab's "fprintf" floors when writing floats, so we compute | ||
97 | %% (mtx-r1)*255/(r2-r1)+0.5 | ||
98 | mult = (255 / (range(2)-range(1))); | ||
99 | mtx = (mult * mtx) + (0.5 - mult * range(1)); | ||
100 | |||
101 | mtx = max(-0.5+eps,min(255.5-eps,mtx)); | ||
102 | |||
103 | if (format == 2) | ||
104 | count = fprintf(fid,'%d ',mtx'); | ||
105 | elseif (format == 5) | ||
106 | count = fwrite(fid,mtx','uchar'); | ||
107 | end | ||
108 | |||
109 | fclose(fid); | ||
110 | |||
111 | if (count ~= size(mtx,1)*size(mtx,2)) | ||
112 | fprintf(1,'Warning: File output terminated early!'); | ||
113 | end | ||
114 | |||
115 | %%% TEST: | ||
116 | % foo = 257*rand(100)-1; | ||
117 | % pgmWrite(foo,'foo.pgm',[0 255]); | ||
118 | % foo2=pgmRead('foo.pgm'); | ||
119 | % size(find((foo2-round(foo))~=0)) | ||
120 | % foo(find((foo2-round(foo))~=0)) | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/pixelAxes.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/pixelAxes.m deleted file mode 100755 index f88210d..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/pixelAxes.m +++ /dev/null | |||
@@ -1,70 +0,0 @@ | |||
1 | % [ZOOM] = pixelAxes(DIMS, ZOOM) | ||
2 | % | ||
3 | % Set the axes of the current plot to cover a multiple of DIMS pixels, | ||
4 | % thereby eliminating screen aliasing artifacts when displaying an | ||
5 | % image of size DIMS. | ||
6 | % | ||
7 | % ZOOM (optional, default='same') expresses the desired number of | ||
8 | % samples displayed per screen pixel. It should be a scalar, which | ||
9 | % will be rounded to the nearest integer, or 1 over an integer. It | ||
10 | % may also be the string 'same' or 'auto', in which case the value is chosen so | ||
11 | % as to produce an image closest in size to the currently displayed | ||
12 | % image. It may also be the string 'full', in which case the image is | ||
13 | % made as large as possible while still fitting in the window. | ||
14 | |||
15 | % Eero Simoncelli, 2/97. | ||
16 | |||
17 | function [zoom] = pixelAxes(dims, zoom) | ||
18 | |||
19 | %------------------------------------------------------------ | ||
20 | %% OPTIONAL ARGS: | ||
21 | |||
22 | if (exist('zoom') ~= 1) | ||
23 | zoom = 'same'; | ||
24 | end | ||
25 | |||
26 | %% Reverse dimension order, since Figure Positions reported as (x,y). | ||
27 | dims = dims(2:-1:1); | ||
28 | |||
29 | %% Use MatLab's axis function to force square pixels, etc: | ||
30 | axis('image'); | ||
31 | ax = gca; | ||
32 | |||
33 | oldunits = get(ax,'Units'); | ||
34 | |||
35 | if strcmp(zoom,'full'); | ||
36 | set(ax,'Units','normalized'); | ||
37 | set(ax,'Position',[0 0 1 1]); | ||
38 | zoom = 'same'; | ||
39 | end | ||
40 | |||
41 | set(ax,'Units','pixels'); | ||
42 | pos = get(ax,'Position'); | ||
43 | ctr = pos(1:2)+pos(3:4)/2; | ||
44 | |||
45 | if (strcmp(zoom,'same') | strcmp(zoom,'auto')) | ||
46 | %% HACK: enlarge slightly so that floor doesn't round down | ||
47 | zoom = min( pos(3:4) ./ (dims - 1) ); | ||
48 | elseif isstr(zoom) | ||
49 | error(sprintf('Bad ZOOM argument: %s',zoom)); | ||
50 | end | ||
51 | |||
52 | %% Force zoom value to be an integer, or inverse integer. | ||
53 | if (zoom < 0.75) | ||
54 | zoom = 1/ceil(1/zoom); | ||
55 | %% Round upward, subtracting 0.5 to avoid floating point errors. | ||
56 | newsz = ceil(zoom*(dims-0.5)); | ||
57 | else | ||
58 | zoom = floor(zoom + 0.001); % Avoid floating pt errors | ||
59 | if (zoom < 1.5) % zoom=1 | ||
60 | zoom = 1; | ||
61 | newsz = dims + 0.5; | ||
62 | else | ||
63 | newsz = zoom*(dims-1) + mod(zoom,2); | ||
64 | end | ||
65 | end | ||
66 | |||
67 | set(ax,'Position', [floor(ctr-newsz/2)+0.5, newsz] ) | ||
68 | |||
69 | % Restore units | ||
70 | set(ax,'Units',oldunits); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/pointOp.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/pointOp.m deleted file mode 100755 index 890e60a..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/pointOp.m +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
1 | % RES = pointOp(IM, LUT, ORIGIN, INCREMENT, WARNINGS) | ||
2 | % | ||
3 | % Apply a point operation, specified by lookup table LUT, to image IM. | ||
4 | % LUT must be a row or column vector, and is assumed to contain | ||
5 | % (equi-spaced) samples of the function. ORIGIN specifies the | ||
6 | % abscissa associated with the first sample, and INCREMENT specifies the | ||
7 | % spacing between samples. Between-sample values are estimated via | ||
8 | % linear interpolation. If WARNINGS is non-zero, the function prints | ||
9 | % a warning whenever the lookup table is extrapolated. | ||
10 | % | ||
11 | % This function is much faster than MatLab's interp1, and allows | ||
12 | % extrapolation beyond the lookup table domain. The drawbacks are | ||
13 | % that the lookup table must be equi-spaced, and the interpolation is | ||
14 | % linear. | ||
15 | |||
16 | % Eero Simoncelli, 8/96. | ||
17 | |||
18 | function res = pointOp(im, lut, origin, increment, warnings) | ||
19 | |||
20 | %% NOTE: THIS CODE IS NOT ACTUALLY USED! (MEX FILE IS CALLED INSTEAD) | ||
21 | |||
22 | fprintf(1,'WARNING: You should compile the MEX version of "pointOp.c",\n found in the MEX subdirectory of matlabPyrTools, and put it in your matlab path. It is MUCH faster.\n'); | ||
23 | |||
24 | X = origin + increment*[0:size(lut(:),1)-1]; | ||
25 | Y = lut(:); | ||
26 | |||
27 | res = reshape(interp1(X, Y, im(:), 'linear', 'extrap'),size(im)); | ||
28 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/pwd2path.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/pwd2path.m deleted file mode 100755 index 15aecf0..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/pwd2path.m +++ /dev/null | |||
@@ -1,6 +0,0 @@ | |||
1 | % PWD2PATH() | ||
2 | % | ||
3 | % add current working directory (pwd) to path. | ||
4 | |||
5 | P = path; | ||
6 | path(pwd,P); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/pyrBand.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/pyrBand.m deleted file mode 100755 index 1fb6461..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/pyrBand.m +++ /dev/null | |||
@@ -1,11 +0,0 @@ | |||
1 | % RES = pyrBand(PYR, INDICES, BAND_NUM) | ||
2 | % | ||
3 | % Access a subband from a pyramid (gaussian, laplacian, QMF/wavelet, | ||
4 | % or steerable). Subbands are numbered consecutively, from finest | ||
5 | % (highest spatial frequency) to coarsest (lowest spatial frequency). | ||
6 | |||
7 | % Eero Simoncelli, 6/96. | ||
8 | |||
9 | function res = pyrBand(pyr, pind, band) | ||
10 | |||
11 | res = reshape( pyr(pyrBandIndices(pind,band)), pind(band,1), pind(band,2) ); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/pyrBandIndices.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/pyrBandIndices.m deleted file mode 100755 index f94c217..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/pyrBandIndices.m +++ /dev/null | |||
@@ -1,24 +0,0 @@ | |||
1 | % RES = pyrBandIndices(INDICES, BAND_NUM) | ||
2 | % | ||
3 | % Return indices for accessing a subband from a pyramid | ||
4 | % (gaussian, laplacian, QMF/wavelet, steerable). | ||
5 | |||
6 | % Eero Simoncelli, 6/96. | ||
7 | |||
8 | function indices = pyrBandIndices(pind,band) | ||
9 | |||
10 | if ((band > size(pind,1)) | (band < 1)) | ||
11 | error(sprintf('BAND_NUM must be between 1 and number of pyramid bands (%d).', ... | ||
12 | size(pind,1))); | ||
13 | end | ||
14 | |||
15 | if (size(pind,2) ~= 2) | ||
16 | error('INDICES must be an Nx2 matrix indicating the size of the pyramid subbands'); | ||
17 | end | ||
18 | |||
19 | ind = 1; | ||
20 | for l=1:band-1 | ||
21 | ind = ind + prod(pind(l,:)); | ||
22 | end | ||
23 | |||
24 | indices = ind:ind+prod(pind(band,:))-1; | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/pyrLow.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/pyrLow.m deleted file mode 100755 index 290e806..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/pyrLow.m +++ /dev/null | |||
@@ -1,12 +0,0 @@ | |||
1 | % RES = pyrLow(PYR, INDICES) | ||
2 | % | ||
3 | % Access the lowpass subband from a pyramid | ||
4 | % (gaussian, laplacian, QMF/wavelet, steerable). | ||
5 | |||
6 | % Eero Simoncelli, 6/96. | ||
7 | |||
8 | function res = pyrLow(pyr,pind) | ||
9 | |||
10 | band = size(pind,1); | ||
11 | |||
12 | res = reshape( pyr(pyrBandIndices(pind,band)), pind(band,1), pind(band,2) ); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/range2.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/range2.m deleted file mode 100755 index 1709a0e..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/range2.m +++ /dev/null | |||
@@ -1,18 +0,0 @@ | |||
1 | % [MIN, MAX] = range2(MTX) | ||
2 | % | ||
3 | % Compute minimum and maximum values of MTX, returning them as a 2-vector. | ||
4 | |||
5 | % Eero Simoncelli, 3/97. | ||
6 | |||
7 | function [mn, mx] = range2(mtx) | ||
8 | |||
9 | %% NOTE: THIS CODE IS NOT ACTUALLY USED! (MEX FILE IS CALLED INSTEAD) | ||
10 | |||
11 | fprintf(1,'WARNING: You should compile the MEX version of "range2.c",\n found in the MEX subdirectory of matlabPyrTools, and put it in your matlab path. It is MUCH faster.\n'); | ||
12 | |||
13 | if (~isreal(mtx)) | ||
14 | error('MTX must be real-valued'); | ||
15 | end | ||
16 | |||
17 | mn = min(min(mtx)); | ||
18 | mx = max(max(mtx)); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/rconv2.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/rconv2.m deleted file mode 100755 index 0c12490..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/rconv2.m +++ /dev/null | |||
@@ -1,50 +0,0 @@ | |||
1 | % RES = RCONV2(MTX1, MTX2, CTR) | ||
2 | % | ||
3 | % Convolution of two matrices, with boundaries handled via reflection | ||
4 | % about the edge pixels. Result will be of size of LARGER matrix. | ||
5 | % | ||
6 | % The origin of the smaller matrix is assumed to be its center. | ||
7 | % For even dimensions, the origin is determined by the CTR (optional) | ||
8 | % argument: | ||
9 | % CTR origin | ||
10 | % 0 DIM/2 (default) | ||
11 | % 1 (DIM/2)+1 | ||
12 | |||
13 | % Eero Simoncelli, 6/96. | ||
14 | |||
15 | function c = rconv2(a,b,ctr) | ||
16 | |||
17 | if (exist('ctr') ~= 1) | ||
18 | ctr = 0; | ||
19 | end | ||
20 | |||
21 | if (( size(a,1) >= size(b,1) ) & ( size(a,2) >= size(b,2) )) | ||
22 | large = a; small = b; | ||
23 | elseif (( size(a,1) <= size(b,1) ) & ( size(a,2) <= size(b,2) )) | ||
24 | large = b; small = a; | ||
25 | else | ||
26 | error('one arg must be larger than the other in both dimensions!'); | ||
27 | end | ||
28 | |||
29 | ly = size(large,1); | ||
30 | lx = size(large,2); | ||
31 | sy = size(small,1); | ||
32 | sx = size(small,2); | ||
33 | |||
34 | %% These values are one less than the index of the small mtx that falls on | ||
35 | %% the border pixel of the large matrix when computing the first | ||
36 | %% convolution response sample: | ||
37 | sy2 = floor((sy+ctr-1)/2); | ||
38 | sx2 = floor((sx+ctr-1)/2); | ||
39 | |||
40 | % pad with reflected copies | ||
41 | clarge = [ | ||
42 | large(sy-sy2:-1:2,sx-sx2:-1:2), large(sy-sy2:-1:2,:), ... | ||
43 | large(sy-sy2:-1:2,lx-1:-1:lx-sx2); ... | ||
44 | large(:,sx-sx2:-1:2), large, large(:,lx-1:-1:lx-sx2); ... | ||
45 | large(ly-1:-1:ly-sy2,sx-sx2:-1:2), ... | ||
46 | large(ly-1:-1:ly-sy2,:), ... | ||
47 | large(ly-1:-1:ly-sy2,lx-1:-1:lx-sx2) ]; | ||
48 | |||
49 | c = conv2(clarge,small,'valid'); | ||
50 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/rcosFn.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/rcosFn.m deleted file mode 100755 index 5dac344..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/rcosFn.m +++ /dev/null | |||
@@ -1,45 +0,0 @@ | |||
1 | % [X, Y] = rcosFn(WIDTH, POSITION, VALUES) | ||
2 | % | ||
3 | % Return a lookup table (suitable for use by INTERP1) | ||
4 | % containing a "raised cosine" soft threshold function: | ||
5 | % | ||
6 | % Y = VALUES(1) + (VALUES(2)-VALUES(1)) * | ||
7 | % cos^2( PI/2 * (X - POSITION + WIDTH)/WIDTH ) | ||
8 | % | ||
9 | % WIDTH is the width of the region over which the transition occurs | ||
10 | % (default = 1). POSITION is the location of the center of the | ||
11 | % threshold (default = 0). VALUES (default = [0,1]) specifies the | ||
12 | % values to the left and right of the transition. | ||
13 | |||
14 | % Eero Simoncelli, 7/96. | ||
15 | |||
16 | function [X, Y] = rcosFn(width,position,values) | ||
17 | |||
18 | %------------------------------------------------------------ | ||
19 | % OPTIONAL ARGS: | ||
20 | |||
21 | if (exist('width') ~= 1) | ||
22 | width = 1; | ||
23 | end | ||
24 | |||
25 | if (exist('position') ~= 1) | ||
26 | position = 0; | ||
27 | end | ||
28 | |||
29 | if (exist('values') ~= 1) | ||
30 | values = [0,1]; | ||
31 | end | ||
32 | |||
33 | %------------------------------------------------------------ | ||
34 | |||
35 | sz = 256; %% arbitrary! | ||
36 | |||
37 | X = pi * [-sz-1:1] / (2*sz); | ||
38 | |||
39 | Y = values(1) + (values(2)-values(1)) * cos(X).^2; | ||
40 | |||
41 | % Make sure end values are repeated, for extrapolation... | ||
42 | Y(1) = Y(2); | ||
43 | Y(sz+3) = Y(sz+2); | ||
44 | |||
45 | X = position + (2*width/pi) * (X + pi/4); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/reconLpyr.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/reconLpyr.m deleted file mode 100755 index cddcc12..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/reconLpyr.m +++ /dev/null | |||
@@ -1,83 +0,0 @@ | |||
1 | % RES = reconLpyr(PYR, INDICES, LEVS, FILT2, EDGES) | ||
2 | % | ||
3 | % Reconstruct image from Laplacian pyramid, as created by buildLpyr. | ||
4 | % | ||
5 | % PYR is a vector containing the N pyramid subbands, ordered from fine | ||
6 | % to coarse. INDICES is an Nx2 matrix containing the sizes of | ||
7 | % each subband. This is compatible with the MatLab Wavelet toolbox. | ||
8 | % | ||
9 | % LEVS (optional) should be a list of levels to include, or the string | ||
10 | % 'all' (default). The finest scale is number 1. The lowpass band | ||
11 | % corresponds to lpyrHt(INDICES)+1. | ||
12 | % | ||
13 | % FILT2 (optional) can be a string naming a standard filter (see | ||
14 | % namedFilter), or a vector which will be used for (separable) | ||
15 | % convolution. Default = 'binom5'. EDGES specifies edge-handling, | ||
16 | % and defaults to 'reflect1' (see corrDn). | ||
17 | |||
18 | % Eero Simoncelli, 6/96 | ||
19 | |||
20 | function res = reconLpyr(pyr, ind, levs, filt2, edges) | ||
21 | |||
22 | if (nargin < 2) | ||
23 | error('First two arguments (PYR, INDICES) are required'); | ||
24 | end | ||
25 | |||
26 | %%------------------------------------------------------------ | ||
27 | %% DEFAULTS: | ||
28 | |||
29 | if (exist('levs') ~= 1) | ||
30 | levs = 'all'; | ||
31 | end | ||
32 | |||
33 | if (exist('filt2') ~= 1) | ||
34 | filt2 = 'binom5'; | ||
35 | end | ||
36 | |||
37 | if (exist('edges') ~= 1) | ||
38 | edges= 'reflect1'; | ||
39 | end | ||
40 | %%------------------------------------------------------------ | ||
41 | |||
42 | maxLev = 1+lpyrHt(ind); | ||
43 | if strcmp(levs,'all') | ||
44 | levs = [1:maxLev]'; | ||
45 | else | ||
46 | if (any(levs > maxLev)) | ||
47 | error(sprintf('Level numbers must be in the range [1, %d].', maxLev)); | ||
48 | end | ||
49 | levs = levs(:); | ||
50 | end | ||
51 | |||
52 | if isstr(filt2) | ||
53 | filt2 = namedFilter(filt2); | ||
54 | end | ||
55 | |||
56 | filt2 = filt2(:); | ||
57 | res_sz = ind(1,:); | ||
58 | |||
59 | if any(levs > 1) | ||
60 | |||
61 | int_sz = [ind(1,1), ind(2,2)]; | ||
62 | |||
63 | nres = reconLpyr( pyr(prod(res_sz)+1:size(pyr,1)), ... | ||
64 | ind(2:size(ind,1),:), levs-1, filt2, edges); | ||
65 | |||
66 | if (res_sz(1) == 1) | ||
67 | res = upConv(nres, filt2', edges, [1 2], [1 1], res_sz); | ||
68 | elseif (res_sz(2) == 1) | ||
69 | res = upConv(nres, filt2, edges, [2 1], [1 1], res_sz); | ||
70 | else | ||
71 | hi = upConv(nres, filt2, edges, [2 1], [1 1], int_sz); | ||
72 | res = upConv(hi, filt2', edges, [1 2], [1 1], res_sz); | ||
73 | end | ||
74 | |||
75 | else | ||
76 | |||
77 | res = zeros(res_sz); | ||
78 | |||
79 | end | ||
80 | |||
81 | if any(levs == 1) | ||
82 | res = res + pyrBand(pyr,ind,1); | ||
83 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/reconSCFpyr.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/reconSCFpyr.m deleted file mode 100755 index a86f03d..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/reconSCFpyr.m +++ /dev/null | |||
@@ -1,87 +0,0 @@ | |||
1 | % RES = reconSCFpyr(PYR, INDICES, LEVS, BANDS, TWIDTH) | ||
2 | % | ||
3 | % The inverse of buildSCFpyr: Reconstruct image from its complex steerable pyramid representation, | ||
4 | % in the Fourier domain. | ||
5 | % | ||
6 | % The image is reconstructed by forcing the complex subbands to be analytic | ||
7 | % (zero on half of the 2D Fourier plane, as they are supossed to be unless | ||
8 | % they have being modified), and reconstructing from the real part of those | ||
9 | % analytic subbands. That is equivalent to compute the Hilbert transforms of | ||
10 | % the imaginary parts of the subbands, average them with their real | ||
11 | % counterparts, and then reconstructing from the resulting real subbands. | ||
12 | % | ||
13 | % PYR is a vector containing the N pyramid subbands, ordered from fine | ||
14 | % to coarse. INDICES is an Nx2 matrix containing the sizes of | ||
15 | % each subband. This is compatible with the MatLab Wavelet toolbox. | ||
16 | % | ||
17 | % LEVS (optional) should be a list of levels to include, or the string | ||
18 | % 'all' (default). 0 corresonds to the residual highpass subband. | ||
19 | % 1 corresponds to the finest oriented scale. The lowpass band | ||
20 | % corresponds to number spyrHt(INDICES)+1. | ||
21 | % | ||
22 | % BANDS (optional) should be a list of bands to include, or the string | ||
23 | % 'all' (default). 1 = vertical, rest proceeding anti-clockwise. | ||
24 | % | ||
25 | % TWIDTH is the width of the transition region of the radial lowpass | ||
26 | % function, in octaves (default = 1, which gives a raised cosine for | ||
27 | % the bandpass filters). | ||
28 | |||
29 | % Javier Portilla, 7/04, basing on Eero Simoncelli's Matlab Pyrtools code | ||
30 | % and our common code on texture synthesis (textureSynthesis.m). | ||
31 | |||
32 | function res = reconSCFpyr(pyr, indices, levs, bands, twidth) | ||
33 | |||
34 | %%------------------------------------------------------------ | ||
35 | %% DEFAULTS: | ||
36 | |||
37 | if ~exist('levs'), | ||
38 | levs = 'all'; | ||
39 | end | ||
40 | |||
41 | if ~exist('bands') | ||
42 | bands = 'all'; | ||
43 | end | ||
44 | |||
45 | if ~exist('twidth'), | ||
46 | twidth = 1; | ||
47 | elseif (twidth <= 0) | ||
48 | fprintf(1,'Warning: TWIDTH must be positive. Setting to 1.\n'); | ||
49 | twidth = 1; | ||
50 | end | ||
51 | |||
52 | %%------------------------------------------------------------ | ||
53 | |||
54 | |||
55 | pind = indices; | ||
56 | Nsc = log2(pind(1,1)/pind(end,1)); | ||
57 | Nor = (size(pind,1)-2)/Nsc; | ||
58 | |||
59 | for nsc = 1:Nsc, | ||
60 | firstBnum = (nsc-1)*Nor+2; | ||
61 | |||
62 | %% Re-create analytic subbands | ||
63 | dims = pind(firstBnum,:); | ||
64 | ctr = ceil((dims+0.5)/2); | ||
65 | ang = mkAngle(dims, 0, ctr); | ||
66 | ang(ctr(1),ctr(2)) = -pi/2; | ||
67 | for nor = 1:Nor, | ||
68 | nband = (nsc-1)*Nor+nor+1; | ||
69 | ind = pyrBandIndices(pind,nband); | ||
70 | ch = pyrBand(pyr, pind, nband); | ||
71 | ang0 = pi*(nor-1)/Nor; | ||
72 | xang = mod(ang-ang0+pi, 2*pi) - pi; | ||
73 | amask = 2*(abs(xang) < pi/2) + (abs(xang) == pi/2); | ||
74 | amask(ctr(1),ctr(2)) = 1; | ||
75 | amask(:,1) = 1; | ||
76 | amask(1,:) = 1; | ||
77 | amask = fftshift(amask); | ||
78 | ch = ifft2(amask.*fft2(ch)); % "Analytic" version | ||
79 | %f = 1.000008; % With this factor the reconstruction SNR goes up around 6 dB! | ||
80 | f = 1; | ||
81 | ch = f*0.5*real(ch); % real part | ||
82 | pyr(ind) = ch; | ||
83 | end % nor | ||
84 | end % nsc | ||
85 | |||
86 | res = reconSFpyr(pyr, indices, levs, bands, twidth); | ||
87 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/reconSFpyr.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/reconSFpyr.m deleted file mode 100755 index 0e3109e..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/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))); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/reconSFpyrLevs.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/reconSFpyrLevs.m deleted file mode 100755 index 420f278..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/reconSFpyrLevs.m +++ /dev/null | |||
@@ -1,69 +0,0 @@ | |||
1 | % RESDFT = reconSFpyrLevs(PYR,INDICES,LOGRAD,XRCOS,YRCOS,ANGLE,NBANDS,LEVS,BANDS) | ||
2 | % | ||
3 | % Recursive function for reconstructing levels of a steerable pyramid | ||
4 | % representation. This is called by reconSFpyr, and is not usually | ||
5 | % called directly. | ||
6 | |||
7 | % Eero Simoncelli, 5/97. | ||
8 | |||
9 | function resdft = reconSFpyrLevs(pyr,pind,log_rad,Xrcos,Yrcos,angle,nbands,levs,bands); | ||
10 | |||
11 | lo_ind = nbands+1; | ||
12 | dims = pind(1,:); | ||
13 | ctr = ceil((dims+0.5)/2); | ||
14 | |||
15 | % log_rad = log_rad + 1; | ||
16 | Xrcos = Xrcos - log2(2); % shift origin of lut by 1 octave. | ||
17 | |||
18 | if any(levs > 1) | ||
19 | |||
20 | lodims = ceil((dims-0.5)/2); | ||
21 | loctr = ceil((lodims+0.5)/2); | ||
22 | lostart = ctr-loctr+1; | ||
23 | loend = lostart+lodims-1; | ||
24 | nlog_rad = log_rad(lostart(1):loend(1),lostart(2):loend(2)); | ||
25 | nangle = angle(lostart(1):loend(1),lostart(2):loend(2)); | ||
26 | |||
27 | if (size(pind,1) > lo_ind) | ||
28 | nresdft = reconSFpyrLevs( pyr(1+sum(prod(pind(1:lo_ind-1,:)')):size(pyr,1)),... | ||
29 | pind(lo_ind:size(pind,1),:), ... | ||
30 | nlog_rad, Xrcos, Yrcos, nangle, nbands,levs-1, bands); | ||
31 | else | ||
32 | nresdft = fftshift(fft2(pyrBand(pyr,pind,lo_ind))); | ||
33 | end | ||
34 | |||
35 | YIrcos = sqrt(abs(1.0 - Yrcos.^2)); | ||
36 | lomask = pointOp(nlog_rad, YIrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); | ||
37 | |||
38 | resdft = zeros(dims); | ||
39 | resdft(lostart(1):loend(1),lostart(2):loend(2)) = nresdft .* lomask; | ||
40 | |||
41 | else | ||
42 | |||
43 | resdft = zeros(dims); | ||
44 | |||
45 | end | ||
46 | |||
47 | |||
48 | if any(levs == 1) | ||
49 | |||
50 | lutsize = 1024; | ||
51 | Xcosn = pi*[-(2*lutsize+1):(lutsize+1)]/lutsize; % [-2*pi:pi] | ||
52 | order = nbands-1; | ||
53 | %% divide by sqrt(sum_(n=0)^(N-1) cos(pi*n/N)^(2(N-1)) ) | ||
54 | const = (2^(2*order))*(factorial(order)^2)/(nbands*factorial(2*order)); | ||
55 | Ycosn = sqrt(const) * (cos(Xcosn)).^order; | ||
56 | himask = pointOp(log_rad, Yrcos, Xrcos(1), Xrcos(2)-Xrcos(1),0); | ||
57 | |||
58 | ind = 1; | ||
59 | for b = 1:nbands | ||
60 | if any(bands == b) | ||
61 | anglemask = pointOp(angle,Ycosn,Xcosn(1)+pi*(b-1)/nbands,Xcosn(2)-Xcosn(1)); | ||
62 | band = reshape(pyr(ind:ind+prod(dims)-1), dims(1), dims(2)); | ||
63 | banddft = fftshift(fft2(band)); | ||
64 | resdft = resdft + (sqrt(-1))^(nbands-1) * banddft.*anglemask.*himask; | ||
65 | end | ||
66 | ind = ind + prod(dims); | ||
67 | end | ||
68 | end | ||
69 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/reconSpyr.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/reconSpyr.m deleted file mode 100755 index 270009d..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/reconSpyr.m +++ /dev/null | |||
@@ -1,96 +0,0 @@ | |||
1 | % RES = reconSpyr(PYR, INDICES, FILTFILE, EDGES, LEVS, BANDS) | ||
2 | % | ||
3 | % Reconstruct image from its steerable pyramid representation, as created | ||
4 | % by buildSpyr. | ||
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 | % FILTFILE (optional) should be a string referring to an m-file that returns | ||
11 | % the rfilters. examples: sp0Filters, sp1Filters, sp3Filters | ||
12 | % (default = 'sp1Filters'). | ||
13 | % EDGES specifies edge-handling, and defaults to 'reflect1' (see | ||
14 | % corrDn). | ||
15 | % | ||
16 | % LEVS (optional) should be a list of levels to include, or the string | ||
17 | % 'all' (default). 0 corresonds to the residual highpass subband. | ||
18 | % 1 corresponds to the finest oriented scale. The lowpass band | ||
19 | % corresponds to number spyrHt(INDICES)+1. | ||
20 | % | ||
21 | % BANDS (optional) should be a list of bands to include, or the string | ||
22 | % 'all' (default). 1 = vertical, rest proceeding anti-clockwise. | ||
23 | |||
24 | % Eero Simoncelli, 6/96. | ||
25 | |||
26 | function res = reconSpyr(pyr, pind, filtfile, edges, levs, bands) | ||
27 | |||
28 | %%------------------------------------------------------------ | ||
29 | %% DEFAULTS: | ||
30 | |||
31 | if (exist('filtfile') ~= 1) | ||
32 | filtfile = 'sp1Filters'; | ||
33 | end | ||
34 | |||
35 | if (exist('edges') ~= 1) | ||
36 | edges= 'reflect1'; | ||
37 | end | ||
38 | |||
39 | if (exist('levs') ~= 1) | ||
40 | levs = 'all'; | ||
41 | end | ||
42 | |||
43 | if (exist('bands') ~= 1) | ||
44 | bands = 'all'; | ||
45 | end | ||
46 | |||
47 | %%------------------------------------------------------------ | ||
48 | |||
49 | if (isstr(filtfile) & (exist(filtfile) == 2)) | ||
50 | [lo0filt,hi0filt,lofilt,bfilts,steermtx,harmonics] = eval(filtfile); | ||
51 | nbands = spyrNumBands(pind); | ||
52 | if ((nbands > 0) & (size(bfilts,2) ~= nbands)) | ||
53 | error('Number of pyramid bands is inconsistent with filter file'); | ||
54 | end | ||
55 | else | ||
56 | error('filtfile argument must be the name of an M-file containing SPYR filters.'); | ||
57 | end | ||
58 | |||
59 | maxLev = 1+spyrHt(pind); | ||
60 | if strcmp(levs,'all') | ||
61 | levs = [0:maxLev]'; | ||
62 | else | ||
63 | if (any(levs > maxLev) | any(levs < 0)) | ||
64 | error(sprintf('Level numbers must be in the range [0, %d].', maxLev)); | ||
65 | end | ||
66 | levs = levs(:); | ||
67 | end | ||
68 | |||
69 | if strcmp(bands,'all') | ||
70 | bands = [1:nbands]'; | ||
71 | else | ||
72 | if (any(bands < 1) | any(bands > nbands)) | ||
73 | error(sprintf('Band numbers must be in the range [1,3].', nbands)); | ||
74 | end | ||
75 | bands = bands(:); | ||
76 | end | ||
77 | |||
78 | if (spyrHt(pind) == 0) | ||
79 | if (any(levs==1)) | ||
80 | res1 = pyrBand(pyr,pind,2); | ||
81 | else | ||
82 | res1 = zeros(pind(2,:)); | ||
83 | end | ||
84 | else | ||
85 | res1 = reconSpyrLevs(pyr(1+prod(pind(1,:)):size(pyr,1)), ... | ||
86 | pind(2:size(pind,1),:), ... | ||
87 | lofilt, bfilts, edges, levs, bands); | ||
88 | end | ||
89 | |||
90 | res = upConv(res1, lo0filt, edges); | ||
91 | |||
92 | %% residual highpass subband | ||
93 | if any(levs == 0) | ||
94 | upConv( subMtx(pyr, pind(1,:)), hi0filt, edges, [1 1], [1 1], size(res), res); | ||
95 | end | ||
96 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/reconSpyrLevs.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/reconSpyrLevs.m deleted file mode 100755 index f8e456c..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/reconSpyrLevs.m +++ /dev/null | |||
@@ -1,46 +0,0 @@ | |||
1 | % RES = reconSpyrLevs(PYR,INDICES,LOFILT,BFILTS,EDGES,LEVS,BANDS) | ||
2 | % | ||
3 | % Recursive function for reconstructing levels of a steerable pyramid | ||
4 | % representation. This is called by reconSpyr, and is not usually | ||
5 | % called directly. | ||
6 | |||
7 | % Eero Simoncelli, 6/96. | ||
8 | |||
9 | function res = reconSpyrLevs(pyr,pind,lofilt,bfilts,edges,levs,bands); | ||
10 | |||
11 | nbands = size(bfilts,2); | ||
12 | lo_ind = nbands+1; | ||
13 | res_sz = pind(1,:); | ||
14 | |||
15 | % Assume square filters: | ||
16 | bfiltsz = round(sqrt(size(bfilts,1))); | ||
17 | |||
18 | if any(levs > 1) | ||
19 | |||
20 | if (size(pind,1) > lo_ind) | ||
21 | nres = reconSpyrLevs( pyr(1+sum(prod(pind(1:lo_ind-1,:)')):size(pyr,1)), ... | ||
22 | pind(lo_ind:size(pind,1),:), ... | ||
23 | lofilt, bfilts, edges, levs-1, bands); | ||
24 | else | ||
25 | nres = pyrBand(pyr,pind,lo_ind); % lowpass subband | ||
26 | end | ||
27 | |||
28 | res = upConv(nres, lofilt, edges, [2 2], [1 1], res_sz); | ||
29 | |||
30 | else | ||
31 | |||
32 | res = zeros(res_sz); | ||
33 | |||
34 | end | ||
35 | |||
36 | if any(levs == 1) | ||
37 | ind = 1; | ||
38 | for b = 1:nbands | ||
39 | if any(bands == b) | ||
40 | bfilt = reshape(bfilts(:,b), bfiltsz, bfiltsz); | ||
41 | upConv(reshape(pyr(ind:ind+prod(res_sz)-1), res_sz(1), res_sz(2)), ... | ||
42 | bfilt, edges, [1 1], [1 1], res_sz, res); | ||
43 | end | ||
44 | ind = ind + prod(res_sz); | ||
45 | end | ||
46 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/reconWpyr.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/reconWpyr.m deleted file mode 100755 index fc31226..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/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 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/setPyrBand.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/setPyrBand.m deleted file mode 100755 index baa9f77..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/setPyrBand.m +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | % NEWPYR = setPyrBand(PYR, INDICES, BAND, BAND_NUM) | ||
2 | % | ||
3 | % Insert an image (BAND) into a pyramid (gaussian, laplacian, QMF/wavelet, | ||
4 | % or steerable). Subbands are numbered consecutively, from finest | ||
5 | % (highest spatial frequency) to coarsest (lowest spatial frequency). | ||
6 | |||
7 | % Eero Simoncelli, 1/03. | ||
8 | |||
9 | function pyr = pyrBand(pyr, pind, band, bandNum) | ||
10 | |||
11 | %% Check: PIND a valid index matrix? | ||
12 | if ( ~(ndims(pind) == 2) | ~(size(pind,2) == 2) | ~all(pind==round(pind)) ) | ||
13 | pind | ||
14 | error('pyrTools:badArg',... | ||
15 | 'PIND argument is not an Nbands X 2 matrix of integers'); | ||
16 | end | ||
17 | |||
18 | %% Check: PIND consistent with size of PYR? | ||
19 | if ( length(pyr) ~= sum(prod(pind,2)) ) | ||
20 | error('pyrTools:badPyr',... | ||
21 | 'Pyramid data vector length is inconsistent with index matrix PIND'); | ||
22 | end | ||
23 | |||
24 | %% Check: size of BAND consistent with desired BANDNUM? | ||
25 | if (~all(size(band) == pind(bandNum,:))) | ||
26 | size(band) | ||
27 | pind(bandNum,:) | ||
28 | error('pyrTools:badArg',... | ||
29 | 'size of BAND to be inserted is inconsistent with BAND_NUM'); | ||
30 | end | ||
31 | |||
32 | pyr(pyrBandIndices(pind,bandNum)) = vectify(band); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/shift.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/shift.m deleted file mode 100755 index 497297e..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/shift.m +++ /dev/null | |||
@@ -1,15 +0,0 @@ | |||
1 | % [RES] = shift(MTX, OFFSET) | ||
2 | % | ||
3 | % Circular shift 2D matrix samples by OFFSET (a [Y,X] 2-vector), | ||
4 | % such that RES(POS) = MTX(POS-OFFSET). | ||
5 | |||
6 | function res = shift(mtx, offset) | ||
7 | |||
8 | dims = size(mtx); | ||
9 | |||
10 | offset = mod(-offset,dims); | ||
11 | |||
12 | res = [ mtx(offset(1)+1:dims(1), offset(2)+1:dims(2)), ... | ||
13 | mtx(offset(1)+1:dims(1), 1:offset(2)); ... | ||
14 | mtx(1:offset(1), offset(2)+1:dims(2)), ... | ||
15 | mtx(1:offset(1), 1:offset(2)) ]; | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/showIm.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/showIm.m deleted file mode 100755 index a9e2bd1..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/showIm.m +++ /dev/null | |||
@@ -1,221 +0,0 @@ | |||
1 | % RANGE = showIm (MATRIX, RANGE, ZOOM, LABEL, NSHADES ) | ||
2 | % | ||
3 | % Display a MatLab MATRIX as a grayscale image in the current figure, | ||
4 | % inside the current axes. If MATRIX is complex, the real and imaginary | ||
5 | % parts are shown side-by-side, with the same grayscale mapping. | ||
6 | % | ||
7 | % If MATRIX is a string, it should be the name of a variable bound to a | ||
8 | % MATRIX in the base (global) environment. This matrix is displayed as an | ||
9 | % image, with the title set to the string. | ||
10 | % | ||
11 | % RANGE (optional) is a 2-vector specifying the values that map to | ||
12 | % black and white, respectively. Passing a value of 'auto' (default) | ||
13 | % sets RANGE=[min,max] (as in MatLab's imagesc). 'auto2' sets | ||
14 | % RANGE=[mean-2*stdev, mean+2*stdev]. 'auto3' sets | ||
15 | % RANGE=[p1-(p2-p1)/8, p2+(p2-p1)/8], where p1 is the 10th percentile | ||
16 | % value of the sorted MATRIX samples, and p2 is the 90th percentile | ||
17 | % value. | ||
18 | % | ||
19 | % ZOOM specifies the number of matrix samples per screen pixel. It | ||
20 | % will be rounded to an integer, or 1 divided by an integer. A value | ||
21 | % of 'same' or 'auto' (default) causes the zoom value to be chosen | ||
22 | % automatically to fit the image into the current axes. A value of | ||
23 | % 'full' fills the axis region (leaving no room for labels). See | ||
24 | % pixelAxes.m. | ||
25 | % | ||
26 | % If LABEL (optional, default = 1, unless zoom='full') is non-zero, the range | ||
27 | % of values that are mapped into the gray colormap and the dimensions | ||
28 | % (size) of the matrix and zoom factor are printed below the image. If label | ||
29 | % is a string, it is used as a title. | ||
30 | % | ||
31 | % NSHADES (optional) specifies the number of gray shades, and defaults | ||
32 | % to the size of the current colormap. | ||
33 | |||
34 | % Eero Simoncelli, 6/96. | ||
35 | |||
36 | %%TODO: should use "newplot" | ||
37 | |||
38 | function range = showIm( im, range, zoom, label, nshades ); | ||
39 | |||
40 | %------------------------------------------------------------ | ||
41 | %% OPTIONAL ARGS: | ||
42 | |||
43 | if (nargin < 1) | ||
44 | error('Requires at least one input argument.'); | ||
45 | end | ||
46 | |||
47 | MLv = version; | ||
48 | |||
49 | if isstr(im) | ||
50 | if (strcmp(MLv(1),'4')) | ||
51 | error('Cannot pass string arg for MATRIX in MatLab version 4.x'); | ||
52 | end | ||
53 | label = im; | ||
54 | im = evalin('base',im); | ||
55 | end | ||
56 | |||
57 | if (exist('range') ~= 1) | ||
58 | range = 'auto1'; | ||
59 | end | ||
60 | |||
61 | if (exist('nshades') ~= 1) | ||
62 | nshades = size(colormap,1); | ||
63 | end | ||
64 | nshades = max( nshades, 2 ); | ||
65 | |||
66 | if (exist('zoom') ~= 1) | ||
67 | zoom = 'auto'; | ||
68 | end | ||
69 | |||
70 | if (exist('label') ~= 1) | ||
71 | if strcmp(zoom,'full') | ||
72 | label = 0; % no labeling | ||
73 | else | ||
74 | label = 1; % just print grayrange & dims | ||
75 | end | ||
76 | end | ||
77 | |||
78 | %------------------------------------------------------------ | ||
79 | |||
80 | %% Automatic range calculation: | ||
81 | if (strcmp(range,'auto1') | strcmp(range,'auto')) | ||
82 | if isreal(im) | ||
83 | [mn,mx] = range2(im); | ||
84 | else | ||
85 | [mn1,mx1] = range2(real(im)); | ||
86 | [mn2,mx2] = range2(imag(im)); | ||
87 | mn = min(mn1,mn2); | ||
88 | mx = max(mx1,mx2); | ||
89 | end | ||
90 | if any(size(im)==1) | ||
91 | pad = (mx-mn)/12; % MAGIC NUMBER: graph padding | ||
92 | range = [mn-pad, mx+pad]; | ||
93 | else | ||
94 | range = [mn,mx]; | ||
95 | end | ||
96 | |||
97 | elseif strcmp(range,'auto2') | ||
98 | if isreal(im) | ||
99 | stdev = sqrt(var2(im)); | ||
100 | av = mean2(im); | ||
101 | else | ||
102 | stdev = sqrt((var2(real(im)) + var2(imag(im)))/2); | ||
103 | av = (mean2(real(im)) + mean2(imag(im)))/2; | ||
104 | end | ||
105 | range = [av-2*stdev,av+2*stdev]; % MAGIC NUMBER: 2 stdevs | ||
106 | |||
107 | elseif strcmp(range, 'auto3') | ||
108 | percentile = 0.1; % MAGIC NUMBER: 0<p<0.5 | ||
109 | [N,X] = histo(im); | ||
110 | binsz = X(2)-X(1); | ||
111 | N = N+1e-10; % Ensure cumsum will be monotonic for call to interp1 | ||
112 | cumN = [0, cumsum(N)]/sum(N); | ||
113 | cumX = [X(1)-binsz, X] + (binsz/2); | ||
114 | ctrRange = interp1(cumN,cumX, [percentile, 1-percentile]); | ||
115 | range = mean(ctrRange) + (ctrRange-mean(ctrRange))/(1-2*percentile); | ||
116 | |||
117 | elseif isstr(range) | ||
118 | error(sprintf('Bad RANGE argument: %s',range)) | ||
119 | |||
120 | end | ||
121 | |||
122 | if ((range(2) - range(1)) <= eps) | ||
123 | range(1) = range(1) - 0.5; | ||
124 | range(2) = range(2) + 0.5; | ||
125 | end | ||
126 | |||
127 | |||
128 | if isreal(im) | ||
129 | factor=1; | ||
130 | else | ||
131 | factor = 1+sqrt(-1); | ||
132 | end | ||
133 | |||
134 | xlbl_offset = 0; % default value | ||
135 | |||
136 | if (~any(size(im)==1)) | ||
137 | %% MatLab's "image" rounds when mapping to the colormap, so we compute | ||
138 | %% (im-r1)*(nshades-1)/(r2-r1) + 1.5 | ||
139 | mult = ((nshades-1) / (range(2)-range(1))); | ||
140 | d_im = (mult * im) + factor*(1.5 - range(1)*mult); | ||
141 | end | ||
142 | |||
143 | if isreal(im) | ||
144 | if (any(size(im)==1)) | ||
145 | hh = plot( im); | ||
146 | axis([1, prod(size(im)), range]); | ||
147 | else | ||
148 | hh = image( d_im ); | ||
149 | axis('off'); | ||
150 | zoom = pixelAxes(size(d_im),zoom); | ||
151 | end | ||
152 | else | ||
153 | if (any(size(im)==1)) | ||
154 | subplot(2,1,1); | ||
155 | hh = plot(real(im)); | ||
156 | axis([1, prod(size(im)), range]); | ||
157 | subplot(2,1,2); | ||
158 | hh = plot(imag(im)); | ||
159 | axis([1, prod(size(im)), range]); | ||
160 | else | ||
161 | subplot(1,2,1); | ||
162 | hh = image(real(d_im)); | ||
163 | axis('off'); zoom = pixelAxes(size(d_im),zoom); | ||
164 | ax = gca; orig_units = get(ax,'Units'); | ||
165 | set(ax,'Units','points'); | ||
166 | pos1 = get(ax,'Position'); | ||
167 | set(ax,'Units',orig_units); | ||
168 | subplot(1,2,2); | ||
169 | hh = image(imag(d_im)); | ||
170 | axis('off'); zoom = pixelAxes(size(d_im),zoom); | ||
171 | ax = gca; orig_units = get(ax,'Units'); | ||
172 | set(ax,'Units','points'); | ||
173 | pos2 = get(ax,'Position'); | ||
174 | set(ax,'Units',orig_units); | ||
175 | xlbl_offset = (pos1(1)-pos2(1))/2; | ||
176 | end | ||
177 | end | ||
178 | |||
179 | if ~any(size(im)==1) | ||
180 | colormap(gray(nshades)); | ||
181 | end | ||
182 | |||
183 | if ((label ~= 0)) | ||
184 | if isstr(label) | ||
185 | title(label); | ||
186 | h = get(gca,'Title'); | ||
187 | orig_units = get(h,'Units'); | ||
188 | set(h,'Units','points'); | ||
189 | pos = get(h,'Position'); | ||
190 | pos(1:2) = pos(1:2) + [xlbl_offset, -3]; % MAGIC NUMBER: y pixel offset | ||
191 | set(h,'Position',pos); | ||
192 | set(h,'Units',orig_units); | ||
193 | end | ||
194 | |||
195 | if (~any(size(im)==1)) | ||
196 | if (zoom > 1) | ||
197 | zformat = sprintf('* %d',round(zoom)); | ||
198 | else | ||
199 | zformat = sprintf('/ %d',round(1/zoom)); | ||
200 | end | ||
201 | if isreal(im) | ||
202 | format=[' Range: [%.3g, %.3g] \n Dims: [%d, %d] ', zformat]; | ||
203 | else | ||
204 | format=['Range: [%.3g, %.3g] ---- Dims: [%d, %d]', zformat]; | ||
205 | end | ||
206 | xlabel(sprintf(format, range(1), range(2), size(im,1), size(im,2))); | ||
207 | h = get(gca,'Xlabel'); | ||
208 | set(h,'FontSize', 9); % MAGIC NUMBER: font size!!! | ||
209 | |||
210 | orig_units = get(h,'Units'); | ||
211 | set(h,'Units','points'); | ||
212 | pos = get(h,'Position'); | ||
213 | pos(1:2) = pos(1:2) + [xlbl_offset, 10]; % MAGIC NUMBER: y offset in points | ||
214 | set(h,'Position',pos); | ||
215 | set(h,'Units',orig_units); | ||
216 | |||
217 | set(h,'Visible','on'); % axis('image') turned the xlabel off... | ||
218 | end | ||
219 | end | ||
220 | |||
221 | return; | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/showLpyr.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/showLpyr.m deleted file mode 100755 index 0d85f9d..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/showLpyr.m +++ /dev/null | |||
@@ -1,202 +0,0 @@ | |||
1 | % RANGE = showLpyr (PYR, INDICES, RANGE, GAP, LEVEL_SCALE_FACTOR) | ||
2 | % | ||
3 | % Display a Laplacian (or Gaussian) pyramid, specified by PYR and | ||
4 | % INDICES (see buildLpyr), 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-normalalized 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] = showLpyr(pyr, pind, range, gap, scale); | ||
30 | |||
31 | % Determine 1D or 2D pyramid: | ||
32 | if ((pind(1,1) == 1) | (pind(1,2) ==1)) | ||
33 | oned = 1; | ||
34 | else | ||
35 | oned = 0; | ||
36 | end | ||
37 | |||
38 | %------------------------------------------------------------ | ||
39 | %% OPTIONAL ARGS: | ||
40 | |||
41 | if (exist('range') ~= 1) | ||
42 | if (oned==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 (oned == 1) | ||
55 | scale = sqrt(2); | ||
56 | else | ||
57 | scale = 2; | ||
58 | end | ||
59 | end | ||
60 | |||
61 | %------------------------------------------------------------ | ||
62 | |||
63 | nind = size(pind,1); | ||
64 | |||
65 | %% Auto range calculations: | ||
66 | if strcmp(range,'auto1') | ||
67 | range = zeros(nind,1); | ||
68 | mn = 0.0; mx = 0.0; | ||
69 | for bnum = 1:(nind-1) | ||
70 | band = pyrBand(pyr,pind,bnum)/(scale^(bnum-1)); | ||
71 | range(bnum) = scale^(bnum-1); | ||
72 | [bmn,bmx] = range2(band); | ||
73 | mn = min(mn, bmn); mx = max(mx, bmx); | ||
74 | end | ||
75 | if (oned == 1) | ||
76 | pad = (mx-mn)/12; % *** MAGIC NUMBER!! | ||
77 | mn = mn-pad; mx = mx+pad; | ||
78 | end | ||
79 | range = range * [mn mx]; % outer product | ||
80 | band = pyrLow(pyr,pind); | ||
81 | [mn,mx] = range2(band); | ||
82 | if (oned == 1) | ||
83 | pad = (mx-mn)/12; % *** MAGIC NUMBER!! | ||
84 | mn = mn-pad; mx = mx+pad; | ||
85 | end | ||
86 | range(nind,:) = [mn, mx]; | ||
87 | |||
88 | elseif strcmp(range,'indep1') | ||
89 | range = zeros(nind,2); | ||
90 | for bnum = 1:nind | ||
91 | band = pyrBand(pyr,pind,bnum); | ||
92 | [mn,mx] = range2(band); | ||
93 | if (oned == 1) | ||
94 | pad = (mx-mn)/12; % *** MAGIC NUMBER!! | ||
95 | mn = mn-pad; mx = mx+pad; | ||
96 | end | ||
97 | range(bnum,:) = [mn mx]; | ||
98 | end | ||
99 | |||
100 | elseif strcmp(range,'auto2') | ||
101 | range = zeros(nind,1); | ||
102 | sqsum = 0; numpixels = 0; | ||
103 | for bnum = 1:(nind-1) | ||
104 | band = pyrBand(pyr,pind,bnum)/(scale^(bnum-1)); | ||
105 | sqsum = sqsum + sum(sum(band.^2)); | ||
106 | numpixels = numpixels + prod(size(band)); | ||
107 | range(bnum) = scale^(bnum-1); | ||
108 | end | ||
109 | stdev = sqrt(sqsum/(numpixels-1)); | ||
110 | range = range * [ -3*stdev 3*stdev ]; % outer product | ||
111 | band = pyrLow(pyr,pind); | ||
112 | av = mean2(band); stdev = sqrt(var2(band)); | ||
113 | range(nind,:) = [av-2*stdev,av+2*stdev]; | ||
114 | |||
115 | elseif strcmp(range,'indep2') | ||
116 | range = zeros(nind,2); | ||
117 | for bnum = 1:(nind-1) | ||
118 | band = pyrBand(pyr,pind,bnum); | ||
119 | stdev = sqrt(var2(band)); | ||
120 | range(bnum,:) = [ -3*stdev 3*stdev ]; | ||
121 | end | ||
122 | band = pyrLow(pyr,pind); | ||
123 | av = mean2(band); stdev = sqrt(var2(band)); | ||
124 | range(nind,:) = [av-2*stdev,av+2*stdev]; | ||
125 | |||
126 | elseif isstr(range) | ||
127 | error(sprintf('Bad RANGE argument: %s',range)) | ||
128 | |||
129 | elseif ((size(range,1) == 1) & (size(range,2) == 2)) | ||
130 | scales = scale.^[0:nind-1]; | ||
131 | range = scales(:) * range; % outer product | ||
132 | band = pyrLow(pyr,pind); | ||
133 | range(nind,:) = range(nind,:) + mean2(band) - mean(range(nind,:)); | ||
134 | |||
135 | end | ||
136 | |||
137 | %% Clear Figure | ||
138 | clf; | ||
139 | |||
140 | if (oned == 1) | ||
141 | |||
142 | %%%%% 1D signal: | ||
143 | for bnum=1:nind | ||
144 | band = pyrBand(pyr,pind,bnum); | ||
145 | subplot(nind,1,nind-bnum+1); | ||
146 | plot(band); | ||
147 | axis([1, prod(size(band)), range(bnum,:)]); | ||
148 | end | ||
149 | |||
150 | else | ||
151 | |||
152 | %%%%% 2D signal: | ||
153 | colormap(gray); | ||
154 | cmap = get(gcf,'Colormap'); | ||
155 | nshades = size(cmap,1); | ||
156 | |||
157 | % Find background color index: | ||
158 | clr = get(gcf,'Color'); | ||
159 | bg = 1; | ||
160 | dist = norm(cmap(bg,:)-clr); | ||
161 | for n = 1:nshades | ||
162 | ndist = norm(cmap(n,:)-clr); | ||
163 | if (ndist < dist) | ||
164 | dist = ndist; | ||
165 | bg = n; | ||
166 | end | ||
167 | end | ||
168 | |||
169 | %% Compute positions of subbands: | ||
170 | llpos = ones(nind,2); | ||
171 | dir = [-1 -1]; | ||
172 | ctr = [pind(1,1)+1+gap 1]; | ||
173 | sz = [0 0]; | ||
174 | for bnum = 1:nind | ||
175 | prevsz = sz; | ||
176 | sz = pind(bnum,:); | ||
177 | |||
178 | % Determine center position of new band: | ||
179 | ctr = ctr + gap*dir/2 + dir.* floor((prevsz+(dir>0))/2); | ||
180 | dir = dir * [0 -1; 1 0]; % ccw rotation | ||
181 | ctr = ctr + gap*dir/2 + dir.* floor((sz+(dir<0))/2); | ||
182 | llpos(bnum,:) = ctr - floor(sz./2); | ||
183 | end | ||
184 | |||
185 | %% Make position list positive, and allocate appropriate image: | ||
186 | llpos = llpos - ones(nind,1)*min(llpos) + 1; | ||
187 | urpos = llpos + pind - 1; | ||
188 | d_im = bg + zeros(max(urpos)); | ||
189 | |||
190 | %% Paste bands into image, (im-r1)*(nshades-1)/(r2-r1) + 1.5 | ||
191 | for bnum=1:nind | ||
192 | mult = (nshades-1) / (range(bnum,2)-range(bnum,1)); | ||
193 | d_im(llpos(bnum,1):urpos(bnum,1), llpos(bnum,2):urpos(bnum,2)) = ... | ||
194 | mult*pyrBand(pyr,pind,bnum) + (1.5-mult*range(bnum,1)); | ||
195 | end | ||
196 | |||
197 | hh = image(d_im); | ||
198 | axis('off'); | ||
199 | pixelAxes(size(d_im),'full'); | ||
200 | set(hh,'UserData',range); | ||
201 | |||
202 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/showSpyr.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/showSpyr.m deleted file mode 100755 index da85715..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/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 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/showWpyr.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/showWpyr.m deleted file mode 100755 index 510e395..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/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; | ||
190 | d_im = bg + zeros(max(urpos)); | ||
191 | |||
192 | %% Paste bands into image, (im-r1)*(nshades-1)/(r2-r1) + 1.5 | ||
193 | for bnum=1:nind | ||
194 | mult = (nshades-1) / (range(bnum,2)-range(bnum,1)); | ||
195 | d_im(llpos(bnum,1):urpos(bnum,1), llpos(bnum,2):urpos(bnum,2)) = ... | ||
196 | mult*pyrBand(pyr,pind,bnum) + (1.5-mult*range(bnum,1)); | ||
197 | end | ||
198 | |||
199 | hh = image(d_im); | ||
200 | axis('off'); | ||
201 | pixelAxes(size(d_im),'full'); | ||
202 | set(hh,'UserData',range); | ||
203 | |||
204 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/skew2.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/skew2.m deleted file mode 100755 index 623d6ca..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/skew2.m +++ /dev/null | |||
@@ -1,21 +0,0 @@ | |||
1 | % S = SKEW2(MTX,MEAN,VAR) | ||
2 | % | ||
3 | % Sample skew (third moment divided by variance^3/2) of a matrix. | ||
4 | % MEAN (optional) and VAR (optional) make the computation faster. | ||
5 | |||
6 | function res = skew2(mtx, mn, v) | ||
7 | |||
8 | if (exist('mn') ~= 1) | ||
9 | mn = mean2(mtx); | ||
10 | end | ||
11 | |||
12 | if (exist('v') ~= 1) | ||
13 | v = var2(mtx,mn); | ||
14 | end | ||
15 | |||
16 | if (isreal(mtx)) | ||
17 | res = mean(mean((mtx-mn).^3)) / (v^(3/2)); | ||
18 | else | ||
19 | res = mean(mean(real(mtx-mn).^3)) / (real(v)^(3/2)) + ... | ||
20 | i * mean(mean(imag(mtx-mn).^3)) / (imag(v)^(3/2)); | ||
21 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/sp0Filters.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/sp0Filters.m deleted file mode 100755 index 6b25e36..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/sp0Filters.m +++ /dev/null | |||
@@ -1,72 +0,0 @@ | |||
1 | % Steerable pyramid filters. Transform described in: | ||
2 | % | ||
3 | % @INPROCEEDINGS{Simoncelli95b, | ||
4 | % TITLE = "The Steerable Pyramid: A Flexible Architecture for | ||
5 | % Multi-Scale Derivative Computation", | ||
6 | % AUTHOR = "E P Simoncelli and W T Freeman", | ||
7 | % BOOKTITLE = "Second Int'l Conf on Image Processing", | ||
8 | % ADDRESS = "Washington, DC", MONTH = "October", YEAR = 1995 } | ||
9 | % | ||
10 | % Filter kernel design described in: | ||
11 | % | ||
12 | %@INPROCEEDINGS{Karasaridis96, | ||
13 | % TITLE = "A Filter Design Technique for | ||
14 | % Steerable Pyramid Image Transforms", | ||
15 | % AUTHOR = "A Karasaridis and E P Simoncelli", | ||
16 | % BOOKTITLE = "ICASSP", ADDRESS = "Atlanta, GA", | ||
17 | % MONTH = "May", YEAR = 1996 } | ||
18 | |||
19 | % Eero Simoncelli, 6/96. | ||
20 | |||
21 | function [lo0filt,hi0filt,lofilt,bfilts,mtx,harmonics] = sp0Filters(); | ||
22 | |||
23 | harmonics = [ 0 ]; | ||
24 | |||
25 | lo0filt = [ ... | ||
26 | -4.514000e-04 -1.137100e-04 -3.725800e-04 -3.743860e-03 -3.725800e-04 -1.137100e-04 -4.514000e-04 | ||
27 | -1.137100e-04 -6.119520e-03 -1.344160e-02 -7.563200e-03 -1.344160e-02 -6.119520e-03 -1.137100e-04 | ||
28 | -3.725800e-04 -1.344160e-02 6.441488e-02 1.524935e-01 6.441488e-02 -1.344160e-02 -3.725800e-04 | ||
29 | -3.743860e-03 -7.563200e-03 1.524935e-01 3.153017e-01 1.524935e-01 -7.563200e-03 -3.743860e-03 | ||
30 | -3.725800e-04 -1.344160e-02 6.441488e-02 1.524935e-01 6.441488e-02 -1.344160e-02 -3.725800e-04 | ||
31 | -1.137100e-04 -6.119520e-03 -1.344160e-02 -7.563200e-03 -1.344160e-02 -6.119520e-03 -1.137100e-04 | ||
32 | -4.514000e-04 -1.137100e-04 -3.725800e-04 -3.743860e-03 -3.725800e-04 -1.137100e-04 -4.514000e-04]; | ||
33 | |||
34 | lofilt = [ ... | ||
35 | -2.257000e-04 -8.064400e-04 -5.686000e-05 8.741400e-04 -1.862800e-04 -1.031640e-03 -1.871920e-03 -1.031640e-03 -1.862800e-04 8.741400e-04 -5.686000e-05 -8.064400e-04 -2.257000e-04 | ||
36 | -8.064400e-04 1.417620e-03 -1.903800e-04 -2.449060e-03 -4.596420e-03 -7.006740e-03 -6.948900e-03 -7.006740e-03 -4.596420e-03 -2.449060e-03 -1.903800e-04 1.417620e-03 -8.064400e-04 | ||
37 | -5.686000e-05 -1.903800e-04 -3.059760e-03 -6.401000e-03 -6.720800e-03 -5.236180e-03 -3.781600e-03 -5.236180e-03 -6.720800e-03 -6.401000e-03 -3.059760e-03 -1.903800e-04 -5.686000e-05 | ||
38 | 8.741400e-04 -2.449060e-03 -6.401000e-03 -5.260020e-03 3.938620e-03 1.722078e-02 2.449600e-02 1.722078e-02 3.938620e-03 -5.260020e-03 -6.401000e-03 -2.449060e-03 8.741400e-04 | ||
39 | -1.862800e-04 -4.596420e-03 -6.720800e-03 3.938620e-03 3.220744e-02 6.306262e-02 7.624674e-02 6.306262e-02 3.220744e-02 3.938620e-03 -6.720800e-03 -4.596420e-03 -1.862800e-04 | ||
40 | -1.031640e-03 -7.006740e-03 -5.236180e-03 1.722078e-02 6.306262e-02 1.116388e-01 1.348999e-01 1.116388e-01 6.306262e-02 1.722078e-02 -5.236180e-03 -7.006740e-03 -1.031640e-03 | ||
41 | -1.871920e-03 -6.948900e-03 -3.781600e-03 2.449600e-02 7.624674e-02 1.348999e-01 1.576508e-01 1.348999e-01 7.624674e-02 2.449600e-02 -3.781600e-03 -6.948900e-03 -1.871920e-03 | ||
42 | -1.031640e-03 -7.006740e-03 -5.236180e-03 1.722078e-02 6.306262e-02 1.116388e-01 1.348999e-01 1.116388e-01 6.306262e-02 1.722078e-02 -5.236180e-03 -7.006740e-03 -1.031640e-03 | ||
43 | -1.862800e-04 -4.596420e-03 -6.720800e-03 3.938620e-03 3.220744e-02 6.306262e-02 7.624674e-02 6.306262e-02 3.220744e-02 3.938620e-03 -6.720800e-03 -4.596420e-03 -1.862800e-04 | ||
44 | 8.741400e-04 -2.449060e-03 -6.401000e-03 -5.260020e-03 3.938620e-03 1.722078e-02 2.449600e-02 1.722078e-02 3.938620e-03 -5.260020e-03 -6.401000e-03 -2.449060e-03 8.741400e-04 | ||
45 | -5.686000e-05 -1.903800e-04 -3.059760e-03 -6.401000e-03 -6.720800e-03 -5.236180e-03 -3.781600e-03 -5.236180e-03 -6.720800e-03 -6.401000e-03 -3.059760e-03 -1.903800e-04 -5.686000e-05 | ||
46 | -8.064400e-04 1.417620e-03 -1.903800e-04 -2.449060e-03 -4.596420e-03 -7.006740e-03 -6.948900e-03 -7.006740e-03 -4.596420e-03 -2.449060e-03 -1.903800e-04 1.417620e-03 -8.064400e-04 | ||
47 | -2.257000e-04 -8.064400e-04 -5.686000e-05 8.741400e-04 -1.862800e-04 -1.031640e-03 -1.871920e-03 -1.031640e-03 -1.862800e-04 8.741400e-04 -5.686000e-05 -8.064400e-04 -2.257000e-04]; | ||
48 | |||
49 | mtx = [ 1.000000 ]; | ||
50 | |||
51 | hi0filt = [... | ||
52 | 5.997200e-04 -6.068000e-05 -3.324900e-04 -3.325600e-04 -2.406600e-04 -3.325600e-04 -3.324900e-04 -6.068000e-05 5.997200e-04 | ||
53 | -6.068000e-05 1.263100e-04 4.927100e-04 1.459700e-04 -3.732100e-04 1.459700e-04 4.927100e-04 1.263100e-04 -6.068000e-05 | ||
54 | -3.324900e-04 4.927100e-04 -1.616650e-03 -1.437358e-02 -2.420138e-02 -1.437358e-02 -1.616650e-03 4.927100e-04 -3.324900e-04 | ||
55 | -3.325600e-04 1.459700e-04 -1.437358e-02 -6.300923e-02 -9.623594e-02 -6.300923e-02 -1.437358e-02 1.459700e-04 -3.325600e-04 | ||
56 | -2.406600e-04 -3.732100e-04 -2.420138e-02 -9.623594e-02 8.554893e-01 -9.623594e-02 -2.420138e-02 -3.732100e-04 -2.406600e-04 | ||
57 | -3.325600e-04 1.459700e-04 -1.437358e-02 -6.300923e-02 -9.623594e-02 -6.300923e-02 -1.437358e-02 1.459700e-04 -3.325600e-04 | ||
58 | -3.324900e-04 4.927100e-04 -1.616650e-03 -1.437358e-02 -2.420138e-02 -1.437358e-02 -1.616650e-03 4.927100e-04 -3.324900e-04 | ||
59 | -6.068000e-05 1.263100e-04 4.927100e-04 1.459700e-04 -3.732100e-04 1.459700e-04 4.927100e-04 1.263100e-04 -6.068000e-05 | ||
60 | 5.997200e-04 -6.068000e-05 -3.324900e-04 -3.325600e-04 -2.406600e-04 -3.325600e-04 -3.324900e-04 -6.068000e-05 5.997200e-04 ]; | ||
61 | |||
62 | bfilts = [ ... | ||
63 | -9.066000e-05 -1.738640e-03 -4.942500e-03 -7.889390e-03 -1.009473e-02 -7.889390e-03 -4.942500e-03 -1.738640e-03 -9.066000e-05 ... | ||
64 | -1.738640e-03 -4.625150e-03 -7.272540e-03 -7.623410e-03 -9.091950e-03 -7.623410e-03 -7.272540e-03 -4.625150e-03 -1.738640e-03 ... | ||
65 | -4.942500e-03 -7.272540e-03 -2.129540e-02 -2.435662e-02 -3.487008e-02 -2.435662e-02 -2.129540e-02 -7.272540e-03 -4.942500e-03 ... | ||
66 | -7.889390e-03 -7.623410e-03 -2.435662e-02 -1.730466e-02 -3.158605e-02 -1.730466e-02 -2.435662e-02 -7.623410e-03 -7.889390e-03 ... | ||
67 | -1.009473e-02 -9.091950e-03 -3.487008e-02 -3.158605e-02 9.464195e-01 -3.158605e-02 -3.487008e-02 -9.091950e-03 -1.009473e-02 ... | ||
68 | -7.889390e-03 -7.623410e-03 -2.435662e-02 -1.730466e-02 -3.158605e-02 -1.730466e-02 -2.435662e-02 -7.623410e-03 -7.889390e-03 ... | ||
69 | -4.942500e-03 -7.272540e-03 -2.129540e-02 -2.435662e-02 -3.487008e-02 -2.435662e-02 -2.129540e-02 -7.272540e-03 -4.942500e-03 ... | ||
70 | -1.738640e-03 -4.625150e-03 -7.272540e-03 -7.623410e-03 -9.091950e-03 -7.623410e-03 -7.272540e-03 -4.625150e-03 -1.738640e-03 ... | ||
71 | -9.066000e-05 -1.738640e-03 -4.942500e-03 -7.889390e-03 -1.009473e-02 -7.889390e-03 -4.942500e-03 -1.738640e-03 -9.066000e-05 ]'; | ||
72 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/sp1Filters.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/sp1Filters.m deleted file mode 100755 index 215e651..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/sp1Filters.m +++ /dev/null | |||
@@ -1,91 +0,0 @@ | |||
1 | % Steerable pyramid filters. Transform described in: | ||
2 | % | ||
3 | % @INPROCEEDINGS{Simoncelli95b, | ||
4 | % TITLE = "The Steerable Pyramid: A Flexible Architecture for | ||
5 | % Multi-Scale Derivative Computation", | ||
6 | % AUTHOR = "E P Simoncelli and W T Freeman", | ||
7 | % BOOKTITLE = "Second Int'l Conf on Image Processing", | ||
8 | % ADDRESS = "Washington, DC", MONTH = "October", YEAR = 1995 } | ||
9 | % | ||
10 | % Filter kernel design described in: | ||
11 | % | ||
12 | %@INPROCEEDINGS{Karasaridis96, | ||
13 | % TITLE = "A Filter Design Technique for | ||
14 | % Steerable Pyramid Image Transforms", | ||
15 | % AUTHOR = "A Karasaridis and E P Simoncelli", | ||
16 | % BOOKTITLE = "ICASSP", ADDRESS = "Atlanta, GA", | ||
17 | % MONTH = "May", YEAR = 1996 } | ||
18 | |||
19 | % Eero Simoncelli, 6/96. | ||
20 | |||
21 | function [lo0filt,hi0filt,lofilt,bfilts,mtx,harmonics] = sp1Filters(); | ||
22 | |||
23 | harmonics = [ 1 ]; | ||
24 | |||
25 | %% filters only contain first harmonic. | ||
26 | mtx = eye(2); | ||
27 | |||
28 | lo0filt = [ ... | ||
29 | -8.701000e-05 -1.354280e-03 -1.601260e-03 -5.033700e-04 2.524010e-03 -5.033700e-04 -1.601260e-03 -1.354280e-03 -8.701000e-05 | ||
30 | -1.354280e-03 2.921580e-03 7.522720e-03 8.224420e-03 1.107620e-03 8.224420e-03 7.522720e-03 2.921580e-03 -1.354280e-03 | ||
31 | -1.601260e-03 7.522720e-03 -7.061290e-03 -3.769487e-02 -3.297137e-02 -3.769487e-02 -7.061290e-03 7.522720e-03 -1.601260e-03 | ||
32 | -5.033700e-04 8.224420e-03 -3.769487e-02 4.381320e-02 1.811603e-01 4.381320e-02 -3.769487e-02 8.224420e-03 -5.033700e-04 | ||
33 | 2.524010e-03 1.107620e-03 -3.297137e-02 1.811603e-01 4.376250e-01 1.811603e-01 -3.297137e-02 1.107620e-03 2.524010e-03 | ||
34 | -5.033700e-04 8.224420e-03 -3.769487e-02 4.381320e-02 1.811603e-01 4.381320e-02 -3.769487e-02 8.224420e-03 -5.033700e-04 | ||
35 | -1.601260e-03 7.522720e-03 -7.061290e-03 -3.769487e-02 -3.297137e-02 -3.769487e-02 -7.061290e-03 7.522720e-03 -1.601260e-03 | ||
36 | -1.354280e-03 2.921580e-03 7.522720e-03 8.224420e-03 1.107620e-03 8.224420e-03 7.522720e-03 2.921580e-03 -1.354280e-03 | ||
37 | -8.701000e-05 -1.354280e-03 -1.601260e-03 -5.033700e-04 2.524010e-03 -5.033700e-04 -1.601260e-03 -1.354280e-03 -8.701000e-05 | ||
38 | ]; | ||
39 | |||
40 | lofilt = [ ... | ||
41 | -4.350000e-05 1.207800e-04 -6.771400e-04 -1.243400e-04 -8.006400e-04 -1.597040e-03 -2.516800e-04 -4.202000e-04 1.262000e-03 -4.202000e-04 -2.516800e-04 -1.597040e-03 -8.006400e-04 -1.243400e-04 -6.771400e-04 1.207800e-04 -4.350000e-05 ; ... | ||
42 | 1.207800e-04 4.460600e-04 -5.814600e-04 5.621600e-04 -1.368800e-04 2.325540e-03 2.889860e-03 4.287280e-03 5.589400e-03 4.287280e-03 2.889860e-03 2.325540e-03 -1.368800e-04 5.621600e-04 -5.814600e-04 4.460600e-04 1.207800e-04 ; ... | ||
43 | -6.771400e-04 -5.814600e-04 1.460780e-03 2.160540e-03 3.761360e-03 3.080980e-03 4.112200e-03 2.221220e-03 5.538200e-04 2.221220e-03 4.112200e-03 3.080980e-03 3.761360e-03 2.160540e-03 1.460780e-03 -5.814600e-04 -6.771400e-04 ; ... | ||
44 | -1.243400e-04 5.621600e-04 2.160540e-03 3.175780e-03 3.184680e-03 -1.777480e-03 -7.431700e-03 -9.056920e-03 -9.637220e-03 -9.056920e-03 -7.431700e-03 -1.777480e-03 3.184680e-03 3.175780e-03 2.160540e-03 5.621600e-04 -1.243400e-04 ; ... | ||
45 | -8.006400e-04 -1.368800e-04 3.761360e-03 3.184680e-03 -3.530640e-03 -1.260420e-02 -1.884744e-02 -1.750818e-02 -1.648568e-02 -1.750818e-02 -1.884744e-02 -1.260420e-02 -3.530640e-03 3.184680e-03 3.761360e-03 -1.368800e-04 -8.006400e-04 ; ... | ||
46 | -1.597040e-03 2.325540e-03 3.080980e-03 -1.777480e-03 -1.260420e-02 -2.022938e-02 -1.109170e-02 3.955660e-03 1.438512e-02 3.955660e-03 -1.109170e-02 -2.022938e-02 -1.260420e-02 -1.777480e-03 3.080980e-03 2.325540e-03 -1.597040e-03 ; ... | ||
47 | -2.516800e-04 2.889860e-03 4.112200e-03 -7.431700e-03 -1.884744e-02 -1.109170e-02 2.190660e-02 6.806584e-02 9.058014e-02 6.806584e-02 2.190660e-02 -1.109170e-02 -1.884744e-02 -7.431700e-03 4.112200e-03 2.889860e-03 -2.516800e-04 ; ... | ||
48 | -4.202000e-04 4.287280e-03 2.221220e-03 -9.056920e-03 -1.750818e-02 3.955660e-03 6.806584e-02 1.445500e-01 1.773651e-01 1.445500e-01 6.806584e-02 3.955660e-03 -1.750818e-02 -9.056920e-03 2.221220e-03 4.287280e-03 -4.202000e-04 ; ... | ||
49 | 1.262000e-03 5.589400e-03 5.538200e-04 -9.637220e-03 -1.648568e-02 1.438512e-02 9.058014e-02 1.773651e-01 2.120374e-01 1.773651e-01 9.058014e-02 1.438512e-02 -1.648568e-02 -9.637220e-03 5.538200e-04 5.589400e-03 1.262000e-03 ; ... | ||
50 | -4.202000e-04 4.287280e-03 2.221220e-03 -9.056920e-03 -1.750818e-02 3.955660e-03 6.806584e-02 1.445500e-01 1.773651e-01 1.445500e-01 6.806584e-02 3.955660e-03 -1.750818e-02 -9.056920e-03 2.221220e-03 4.287280e-03 -4.202000e-04 ; ... | ||
51 | -2.516800e-04 2.889860e-03 4.112200e-03 -7.431700e-03 -1.884744e-02 -1.109170e-02 2.190660e-02 6.806584e-02 9.058014e-02 6.806584e-02 2.190660e-02 -1.109170e-02 -1.884744e-02 -7.431700e-03 4.112200e-03 2.889860e-03 -2.516800e-04 ; ... | ||
52 | -1.597040e-03 2.325540e-03 3.080980e-03 -1.777480e-03 -1.260420e-02 -2.022938e-02 -1.109170e-02 3.955660e-03 1.438512e-02 3.955660e-03 -1.109170e-02 -2.022938e-02 -1.260420e-02 -1.777480e-03 3.080980e-03 2.325540e-03 -1.597040e-03 ; ... | ||
53 | -8.006400e-04 -1.368800e-04 3.761360e-03 3.184680e-03 -3.530640e-03 -1.260420e-02 -1.884744e-02 -1.750818e-02 -1.648568e-02 -1.750818e-02 -1.884744e-02 -1.260420e-02 -3.530640e-03 3.184680e-03 3.761360e-03 -1.368800e-04 -8.006400e-04 ; ... | ||
54 | -1.243400e-04 5.621600e-04 2.160540e-03 3.175780e-03 3.184680e-03 -1.777480e-03 -7.431700e-03 -9.056920e-03 -9.637220e-03 -9.056920e-03 -7.431700e-03 -1.777480e-03 3.184680e-03 3.175780e-03 2.160540e-03 5.621600e-04 -1.243400e-04 ; ... | ||
55 | -6.771400e-04 -5.814600e-04 1.460780e-03 2.160540e-03 3.761360e-03 3.080980e-03 4.112200e-03 2.221220e-03 5.538200e-04 2.221220e-03 4.112200e-03 3.080980e-03 3.761360e-03 2.160540e-03 1.460780e-03 -5.814600e-04 -6.771400e-04 ; ... | ||
56 | 1.207800e-04 4.460600e-04 -5.814600e-04 5.621600e-04 -1.368800e-04 2.325540e-03 2.889860e-03 4.287280e-03 5.589400e-03 4.287280e-03 2.889860e-03 2.325540e-03 -1.368800e-04 5.621600e-04 -5.814600e-04 4.460600e-04 1.207800e-04 ; ... | ||
57 | -4.350000e-05 1.207800e-04 -6.771400e-04 -1.243400e-04 -8.006400e-04 -1.597040e-03 -2.516800e-04 -4.202000e-04 1.262000e-03 -4.202000e-04 -2.516800e-04 -1.597040e-03 -8.006400e-04 -1.243400e-04 -6.771400e-04 1.207800e-04 -4.350000e-05 ]; | ||
58 | |||
59 | hi0filt = [... | ||
60 | -9.570000e-04 -2.424100e-04 -1.424720e-03 -8.742600e-04 -1.166810e-03 -8.742600e-04 -1.424720e-03 -2.424100e-04 -9.570000e-04 ; ... | ||
61 | -2.424100e-04 -4.317530e-03 8.998600e-04 9.156420e-03 1.098012e-02 9.156420e-03 8.998600e-04 -4.317530e-03 -2.424100e-04 ; ... | ||
62 | -1.424720e-03 8.998600e-04 1.706347e-02 1.094866e-02 -5.897780e-03 1.094866e-02 1.706347e-02 8.998600e-04 -1.424720e-03 ; ... | ||
63 | -8.742600e-04 9.156420e-03 1.094866e-02 -7.841370e-02 -1.562827e-01 -7.841370e-02 1.094866e-02 9.156420e-03 -8.742600e-04 ; ... | ||
64 | -1.166810e-03 1.098012e-02 -5.897780e-03 -1.562827e-01 7.282593e-01 -1.562827e-01 -5.897780e-03 1.098012e-02 -1.166810e-03 ; ... | ||
65 | -8.742600e-04 9.156420e-03 1.094866e-02 -7.841370e-02 -1.562827e-01 -7.841370e-02 1.094866e-02 9.156420e-03 -8.742600e-04 ; ... | ||
66 | -1.424720e-03 8.998600e-04 1.706347e-02 1.094866e-02 -5.897780e-03 1.094866e-02 1.706347e-02 8.998600e-04 -1.424720e-03 ; ... | ||
67 | -2.424100e-04 -4.317530e-03 8.998600e-04 9.156420e-03 1.098012e-02 9.156420e-03 8.998600e-04 -4.317530e-03 -2.424100e-04 ; ... | ||
68 | -9.570000e-04 -2.424100e-04 -1.424720e-03 -8.742600e-04 -1.166810e-03 -8.742600e-04 -1.424720e-03 -2.424100e-04 -9.570000e-04 ]; | ||
69 | |||
70 | bfilts = -[ ... | ||
71 | 6.125880e-03 -8.052600e-03 -2.103714e-02 -1.536890e-02 -1.851466e-02 -1.536890e-02 -2.103714e-02 -8.052600e-03 6.125880e-03 ... | ||
72 | -1.287416e-02 -9.611520e-03 1.023569e-02 6.009450e-03 1.872620e-03 6.009450e-03 1.023569e-02 -9.611520e-03 -1.287416e-02 ... | ||
73 | -5.641530e-03 4.168400e-03 -2.382180e-02 -5.375324e-02 -2.076086e-02 -5.375324e-02 -2.382180e-02 4.168400e-03 -5.641530e-03 ... | ||
74 | -8.957260e-03 -1.751170e-03 -1.836909e-02 1.265655e-01 2.996168e-01 1.265655e-01 -1.836909e-02 -1.751170e-03 -8.957260e-03 ... | ||
75 | 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 ... | ||
76 | 8.957260e-03 1.751170e-03 1.836909e-02 -1.265655e-01 -2.996168e-01 -1.265655e-01 1.836909e-02 1.751170e-03 8.957260e-03 ... | ||
77 | 5.641530e-03 -4.168400e-03 2.382180e-02 5.375324e-02 2.076086e-02 5.375324e-02 2.382180e-02 -4.168400e-03 5.641530e-03 ... | ||
78 | 1.287416e-02 9.611520e-03 -1.023569e-02 -6.009450e-03 -1.872620e-03 -6.009450e-03 -1.023569e-02 9.611520e-03 1.287416e-02 ... | ||
79 | -6.125880e-03 8.052600e-03 2.103714e-02 1.536890e-02 1.851466e-02 1.536890e-02 2.103714e-02 8.052600e-03 -6.125880e-03; ... | ||
80 | ... | ||
81 | -6.125880e-03 1.287416e-02 5.641530e-03 8.957260e-03 0.000000e+00 -8.957260e-03 -5.641530e-03 -1.287416e-02 6.125880e-03 ... | ||
82 | 8.052600e-03 9.611520e-03 -4.168400e-03 1.751170e-03 0.000000e+00 -1.751170e-03 4.168400e-03 -9.611520e-03 -8.052600e-03 ... | ||
83 | 2.103714e-02 -1.023569e-02 2.382180e-02 1.836909e-02 0.000000e+00 -1.836909e-02 -2.382180e-02 1.023569e-02 -2.103714e-02 ... | ||
84 | 1.536890e-02 -6.009450e-03 5.375324e-02 -1.265655e-01 0.000000e+00 1.265655e-01 -5.375324e-02 6.009450e-03 -1.536890e-02 ... | ||
85 | 1.851466e-02 -1.872620e-03 2.076086e-02 -2.996168e-01 0.000000e+00 2.996168e-01 -2.076086e-02 1.872620e-03 -1.851466e-02 ... | ||
86 | 1.536890e-02 -6.009450e-03 5.375324e-02 -1.265655e-01 0.000000e+00 1.265655e-01 -5.375324e-02 6.009450e-03 -1.536890e-02 ... | ||
87 | 2.103714e-02 -1.023569e-02 2.382180e-02 1.836909e-02 0.000000e+00 -1.836909e-02 -2.382180e-02 1.023569e-02 -2.103714e-02 ... | ||
88 | 8.052600e-03 9.611520e-03 -4.168400e-03 1.751170e-03 0.000000e+00 -1.751170e-03 4.168400e-03 -9.611520e-03 -8.052600e-03 ... | ||
89 | -6.125880e-03 1.287416e-02 5.641530e-03 8.957260e-03 0.000000e+00 -8.957260e-03 -5.641530e-03 -1.287416e-02 6.125880e-03 ... | ||
90 | ]'; | ||
91 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/sp3Filters.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/sp3Filters.m deleted file mode 100755 index c9cfaaf..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/sp3Filters.m +++ /dev/null | |||
@@ -1,121 +0,0 @@ | |||
1 | % Steerable pyramid filters. Transform described in: | ||
2 | % | ||
3 | % @INPROCEEDINGS{Simoncelli95b, | ||
4 | % TITLE = "The Steerable Pyramid: A Flexible Architecture for | ||
5 | % Multi-Scale Derivative Computation", | ||
6 | % AUTHOR = "E P Simoncelli and W T Freeman", | ||
7 | % BOOKTITLE = "Second Int'l Conf on Image Processing", | ||
8 | % ADDRESS = "Washington, DC", MONTH = "October", YEAR = 1995 } | ||
9 | % | ||
10 | % Filter kernel design described in: | ||
11 | % | ||
12 | %@INPROCEEDINGS{Karasaridis96, | ||
13 | % TITLE = "A Filter Design Technique for | ||
14 | % Steerable Pyramid Image Transforms", | ||
15 | % AUTHOR = "A Karasaridis and E P Simoncelli", | ||
16 | % BOOKTITLE = "ICASSP", ADDRESS = "Atlanta, GA", | ||
17 | % MONTH = "May", YEAR = 1996 } | ||
18 | |||
19 | % Eero Simoncelli, 6/96. | ||
20 | |||
21 | function [lo0filt,hi0filt,lofilt,bfilts,mtx,harmonics] = sp3Filters(); | ||
22 | |||
23 | harmonics = [1 3]; | ||
24 | |||
25 | mtx = [ ... | ||
26 | 0.5000 0.3536 0 -0.3536 | ||
27 | -0.0000 0.3536 0.5000 0.3536 | ||
28 | 0.5000 -0.3536 0 0.3536 | ||
29 | -0.0000 0.3536 -0.5000 0.3536]; | ||
30 | |||
31 | hi0filt = [ | ||
32 | -4.0483998600E-4 -6.2596000498E-4 -3.7829999201E-5 8.8387000142E-4 1.5450799838E-3 1.9235999789E-3 2.0687500946E-3 2.0898699295E-3 2.0687500946E-3 1.9235999789E-3 1.5450799838E-3 8.8387000142E-4 -3.7829999201E-5 -6.2596000498E-4 -4.0483998600E-4 | ||
33 | -6.2596000498E-4 -3.2734998967E-4 7.7435001731E-4 1.5874400269E-3 2.1750701126E-3 2.5626500137E-3 2.2892199922E-3 1.9755100366E-3 2.2892199922E-3 2.5626500137E-3 2.1750701126E-3 1.5874400269E-3 7.7435001731E-4 -3.2734998967E-4 -6.2596000498E-4 | ||
34 | -3.7829999201E-5 7.7435001731E-4 1.1793200392E-3 1.4050999889E-3 2.2253401112E-3 2.1145299543E-3 3.3578000148E-4 -8.3368999185E-4 3.3578000148E-4 2.1145299543E-3 2.2253401112E-3 1.4050999889E-3 1.1793200392E-3 7.7435001731E-4 -3.7829999201E-5 | ||
35 | 8.8387000142E-4 1.5874400269E-3 1.4050999889E-3 1.2960999738E-3 -4.9274001503E-4 -3.1295299996E-3 -4.5751798898E-3 -5.1014497876E-3 -4.5751798898E-3 -3.1295299996E-3 -4.9274001503E-4 1.2960999738E-3 1.4050999889E-3 1.5874400269E-3 8.8387000142E-4 | ||
36 | 1.5450799838E-3 2.1750701126E-3 2.2253401112E-3 -4.9274001503E-4 -6.3222697936E-3 -2.7556000277E-3 5.3632198833E-3 7.3032598011E-3 5.3632198833E-3 -2.7556000277E-3 -6.3222697936E-3 -4.9274001503E-4 2.2253401112E-3 2.1750701126E-3 1.5450799838E-3 | ||
37 | 1.9235999789E-3 2.5626500137E-3 2.1145299543E-3 -3.1295299996E-3 -2.7556000277E-3 1.3962360099E-2 7.8046298586E-3 -9.3812197447E-3 7.8046298586E-3 1.3962360099E-2 -2.7556000277E-3 -3.1295299996E-3 2.1145299543E-3 2.5626500137E-3 1.9235999789E-3 | ||
38 | 2.0687500946E-3 2.2892199922E-3 3.3578000148E-4 -4.5751798898E-3 5.3632198833E-3 7.8046298586E-3 -7.9501636326E-2 -0.1554141641 -7.9501636326E-2 7.8046298586E-3 5.3632198833E-3 -4.5751798898E-3 3.3578000148E-4 2.2892199922E-3 2.0687500946E-3 | ||
39 | 2.0898699295E-3 1.9755100366E-3 -8.3368999185E-4 -5.1014497876E-3 7.3032598011E-3 -9.3812197447E-3 -0.1554141641 0.7303866148 -0.1554141641 -9.3812197447E-3 7.3032598011E-3 -5.1014497876E-3 -8.3368999185E-4 1.9755100366E-3 2.0898699295E-3 | ||
40 | 2.0687500946E-3 2.2892199922E-3 3.3578000148E-4 -4.5751798898E-3 5.3632198833E-3 7.8046298586E-3 -7.9501636326E-2 -0.1554141641 -7.9501636326E-2 7.8046298586E-3 5.3632198833E-3 -4.5751798898E-3 3.3578000148E-4 2.2892199922E-3 2.0687500946E-3 | ||
41 | 1.9235999789E-3 2.5626500137E-3 2.1145299543E-3 -3.1295299996E-3 -2.7556000277E-3 1.3962360099E-2 7.8046298586E-3 -9.3812197447E-3 7.8046298586E-3 1.3962360099E-2 -2.7556000277E-3 -3.1295299996E-3 2.1145299543E-3 2.5626500137E-3 1.9235999789E-3 | ||
42 | 1.5450799838E-3 2.1750701126E-3 2.2253401112E-3 -4.9274001503E-4 -6.3222697936E-3 -2.7556000277E-3 5.3632198833E-3 7.3032598011E-3 5.3632198833E-3 -2.7556000277E-3 -6.3222697936E-3 -4.9274001503E-4 2.2253401112E-3 2.1750701126E-3 1.5450799838E-3 | ||
43 | 8.8387000142E-4 1.5874400269E-3 1.4050999889E-3 1.2960999738E-3 -4.9274001503E-4 -3.1295299996E-3 -4.5751798898E-3 -5.1014497876E-3 -4.5751798898E-3 -3.1295299996E-3 -4.9274001503E-4 1.2960999738E-3 1.4050999889E-3 1.5874400269E-3 8.8387000142E-4 | ||
44 | -3.7829999201E-5 7.7435001731E-4 1.1793200392E-3 1.4050999889E-3 2.2253401112E-3 2.1145299543E-3 3.3578000148E-4 -8.3368999185E-4 3.3578000148E-4 2.1145299543E-3 2.2253401112E-3 1.4050999889E-3 1.1793200392E-3 7.7435001731E-4 -3.7829999201E-5 | ||
45 | -6.2596000498E-4 -3.2734998967E-4 7.7435001731E-4 1.5874400269E-3 2.1750701126E-3 2.5626500137E-3 2.2892199922E-3 1.9755100366E-3 2.2892199922E-3 2.5626500137E-3 2.1750701126E-3 1.5874400269E-3 7.7435001731E-4 -3.2734998967E-4 -6.2596000498E-4 | ||
46 | -4.0483998600E-4 -6.2596000498E-4 -3.7829999201E-5 8.8387000142E-4 1.5450799838E-3 1.9235999789E-3 2.0687500946E-3 2.0898699295E-3 2.0687500946E-3 1.9235999789E-3 1.5450799838E-3 8.8387000142E-4 -3.7829999201E-5 -6.2596000498E-4 -4.0483998600E-4 | ||
47 | ]; | ||
48 | |||
49 | lo0filt = [ | ||
50 | -8.7009997515E-5 -1.3542800443E-3 -1.6012600390E-3 -5.0337001448E-4 2.5240099058E-3 -5.0337001448E-4 -1.6012600390E-3 -1.3542800443E-3 -8.7009997515E-5 | ||
51 | -1.3542800443E-3 2.9215801042E-3 7.5227199122E-3 8.2244202495E-3 1.1076199589E-3 8.2244202495E-3 7.5227199122E-3 2.9215801042E-3 -1.3542800443E-3 | ||
52 | -1.6012600390E-3 7.5227199122E-3 -7.0612900890E-3 -3.7694871426E-2 -3.2971370965E-2 -3.7694871426E-2 -7.0612900890E-3 7.5227199122E-3 -1.6012600390E-3 | ||
53 | -5.0337001448E-4 8.2244202495E-3 -3.7694871426E-2 4.3813198805E-2 0.1811603010 4.3813198805E-2 -3.7694871426E-2 8.2244202495E-3 -5.0337001448E-4 | ||
54 | 2.5240099058E-3 1.1076199589E-3 -3.2971370965E-2 0.1811603010 0.4376249909 0.1811603010 -3.2971370965E-2 1.1076199589E-3 2.5240099058E-3 | ||
55 | -5.0337001448E-4 8.2244202495E-3 -3.7694871426E-2 4.3813198805E-2 0.1811603010 4.3813198805E-2 -3.7694871426E-2 8.2244202495E-3 -5.0337001448E-4 | ||
56 | -1.6012600390E-3 7.5227199122E-3 -7.0612900890E-3 -3.7694871426E-2 -3.2971370965E-2 -3.7694871426E-2 -7.0612900890E-3 7.5227199122E-3 -1.6012600390E-3 | ||
57 | -1.3542800443E-3 2.9215801042E-3 7.5227199122E-3 8.2244202495E-3 1.1076199589E-3 8.2244202495E-3 7.5227199122E-3 2.9215801042E-3 -1.3542800443E-3 | ||
58 | -8.7009997515E-5 -1.3542800443E-3 -1.6012600390E-3 -5.0337001448E-4 2.5240099058E-3 -5.0337001448E-4 -1.6012600390E-3 -1.3542800443E-3 -8.7009997515E-5 | ||
59 | ]; | ||
60 | |||
61 | lofilt = [ | ||
62 | -4.3500000174E-5 1.2078000145E-4 -6.7714002216E-4 -1.2434000382E-4 -8.0063997302E-4 -1.5970399836E-3 -2.5168000138E-4 -4.2019999819E-4 1.2619999470E-3 -4.2019999819E-4 -2.5168000138E-4 -1.5970399836E-3 -8.0063997302E-4 -1.2434000382E-4 -6.7714002216E-4 1.2078000145E-4 -4.3500000174E-5 | ||
63 | 1.2078000145E-4 4.4606000301E-4 -5.8146001538E-4 5.6215998484E-4 -1.3688000035E-4 2.3255399428E-3 2.8898599558E-3 4.2872801423E-3 5.5893999524E-3 4.2872801423E-3 2.8898599558E-3 2.3255399428E-3 -1.3688000035E-4 5.6215998484E-4 -5.8146001538E-4 4.4606000301E-4 1.2078000145E-4 | ||
64 | -6.7714002216E-4 -5.8146001538E-4 1.4607800404E-3 2.1605400834E-3 3.7613599561E-3 3.0809799209E-3 4.1121998802E-3 2.2212199401E-3 5.5381999118E-4 2.2212199401E-3 4.1121998802E-3 3.0809799209E-3 3.7613599561E-3 2.1605400834E-3 1.4607800404E-3 -5.8146001538E-4 -6.7714002216E-4 | ||
65 | -1.2434000382E-4 5.6215998484E-4 2.1605400834E-3 3.1757799443E-3 3.1846798956E-3 -1.7774800071E-3 -7.4316998944E-3 -9.0569201857E-3 -9.6372198313E-3 -9.0569201857E-3 -7.4316998944E-3 -1.7774800071E-3 3.1846798956E-3 3.1757799443E-3 2.1605400834E-3 5.6215998484E-4 -1.2434000382E-4 | ||
66 | -8.0063997302E-4 -1.3688000035E-4 3.7613599561E-3 3.1846798956E-3 -3.5306399222E-3 -1.2604200281E-2 -1.8847439438E-2 -1.7508180812E-2 -1.6485679895E-2 -1.7508180812E-2 -1.8847439438E-2 -1.2604200281E-2 -3.5306399222E-3 3.1846798956E-3 3.7613599561E-3 -1.3688000035E-4 -8.0063997302E-4 | ||
67 | -1.5970399836E-3 2.3255399428E-3 3.0809799209E-3 -1.7774800071E-3 -1.2604200281E-2 -2.0229380578E-2 -1.1091699824E-2 3.9556599222E-3 1.4385120012E-2 3.9556599222E-3 -1.1091699824E-2 -2.0229380578E-2 -1.2604200281E-2 -1.7774800071E-3 3.0809799209E-3 2.3255399428E-3 -1.5970399836E-3 | ||
68 | -2.5168000138E-4 2.8898599558E-3 4.1121998802E-3 -7.4316998944E-3 -1.8847439438E-2 -1.1091699824E-2 2.1906599402E-2 6.8065837026E-2 9.0580143034E-2 6.8065837026E-2 2.1906599402E-2 -1.1091699824E-2 -1.8847439438E-2 -7.4316998944E-3 4.1121998802E-3 2.8898599558E-3 -2.5168000138E-4 | ||
69 | -4.2019999819E-4 4.2872801423E-3 2.2212199401E-3 -9.0569201857E-3 -1.7508180812E-2 3.9556599222E-3 6.8065837026E-2 0.1445499808 0.1773651242 0.1445499808 6.8065837026E-2 3.9556599222E-3 -1.7508180812E-2 -9.0569201857E-3 2.2212199401E-3 4.2872801423E-3 -4.2019999819E-4 | ||
70 | 1.2619999470E-3 5.5893999524E-3 5.5381999118E-4 -9.6372198313E-3 -1.6485679895E-2 1.4385120012E-2 9.0580143034E-2 0.1773651242 0.2120374441 0.1773651242 9.0580143034E-2 1.4385120012E-2 -1.6485679895E-2 -9.6372198313E-3 5.5381999118E-4 5.5893999524E-3 1.2619999470E-3 | ||
71 | -4.2019999819E-4 4.2872801423E-3 2.2212199401E-3 -9.0569201857E-3 -1.7508180812E-2 3.9556599222E-3 6.8065837026E-2 0.1445499808 0.1773651242 0.1445499808 6.8065837026E-2 3.9556599222E-3 -1.7508180812E-2 -9.0569201857E-3 2.2212199401E-3 4.2872801423E-3 -4.2019999819E-4 | ||
72 | -2.5168000138E-4 2.8898599558E-3 4.1121998802E-3 -7.4316998944E-3 -1.8847439438E-2 -1.1091699824E-2 2.1906599402E-2 6.8065837026E-2 9.0580143034E-2 6.8065837026E-2 2.1906599402E-2 -1.1091699824E-2 -1.8847439438E-2 -7.4316998944E-3 4.1121998802E-3 2.8898599558E-3 -2.5168000138E-4 | ||
73 | -1.5970399836E-3 2.3255399428E-3 3.0809799209E-3 -1.7774800071E-3 -1.2604200281E-2 -2.0229380578E-2 -1.1091699824E-2 3.9556599222E-3 1.4385120012E-2 3.9556599222E-3 -1.1091699824E-2 -2.0229380578E-2 -1.2604200281E-2 -1.7774800071E-3 3.0809799209E-3 2.3255399428E-3 -1.5970399836E-3 | ||
74 | -8.0063997302E-4 -1.3688000035E-4 3.7613599561E-3 3.1846798956E-3 -3.5306399222E-3 -1.2604200281E-2 -1.8847439438E-2 -1.7508180812E-2 -1.6485679895E-2 -1.7508180812E-2 -1.8847439438E-2 -1.2604200281E-2 -3.5306399222E-3 3.1846798956E-3 3.7613599561E-3 -1.3688000035E-4 -8.0063997302E-4 | ||
75 | -1.2434000382E-4 5.6215998484E-4 2.1605400834E-3 3.1757799443E-3 3.1846798956E-3 -1.7774800071E-3 -7.4316998944E-3 -9.0569201857E-3 -9.6372198313E-3 -9.0569201857E-3 -7.4316998944E-3 -1.7774800071E-3 3.1846798956E-3 3.1757799443E-3 2.1605400834E-3 5.6215998484E-4 -1.2434000382E-4 | ||
76 | -6.7714002216E-4 -5.8146001538E-4 1.4607800404E-3 2.1605400834E-3 3.7613599561E-3 3.0809799209E-3 4.1121998802E-3 2.2212199401E-3 5.5381999118E-4 2.2212199401E-3 4.1121998802E-3 3.0809799209E-3 3.7613599561E-3 2.1605400834E-3 1.4607800404E-3 -5.8146001538E-4 -6.7714002216E-4 | ||
77 | 1.2078000145E-4 4.4606000301E-4 -5.8146001538E-4 5.6215998484E-4 -1.3688000035E-4 2.3255399428E-3 2.8898599558E-3 4.2872801423E-3 5.5893999524E-3 4.2872801423E-3 2.8898599558E-3 2.3255399428E-3 -1.3688000035E-4 5.6215998484E-4 -5.8146001538E-4 4.4606000301E-4 1.2078000145E-4 | ||
78 | -4.3500000174E-5 1.2078000145E-4 -6.7714002216E-4 -1.2434000382E-4 -8.0063997302E-4 -1.5970399836E-3 -2.5168000138E-4 -4.2019999819E-4 1.2619999470E-3 -4.2019999819E-4 -2.5168000138E-4 -1.5970399836E-3 -8.0063997302E-4 -1.2434000382E-4 -6.7714002216E-4 1.2078000145E-4 -4.3500000174E-5 | ||
79 | ]; | ||
80 | |||
81 | bfilts = [... | ||
82 | -8.1125000725E-4 4.4451598078E-3 1.2316980399E-2 1.3955879956E-2 1.4179450460E-2 1.3955879956E-2 1.2316980399E-2 4.4451598078E-3 -8.1125000725E-4 ... | ||
83 | 3.9103501476E-3 4.4565401040E-3 -5.8724298142E-3 -2.8760801069E-3 8.5267601535E-3 -2.8760801069E-3 -5.8724298142E-3 4.4565401040E-3 3.9103501476E-3 ... | ||
84 | 1.3462699717E-3 -3.7740699481E-3 8.2581602037E-3 3.9442278445E-2 5.3605638444E-2 3.9442278445E-2 8.2581602037E-3 -3.7740699481E-3 1.3462699717E-3 ... | ||
85 | 7.4700999539E-4 -3.6522001028E-4 -2.2522680461E-2 -0.1105690673 -0.1768419296 -0.1105690673 -2.2522680461E-2 -3.6522001028E-4 7.4700999539E-4 ... | ||
86 | 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 ... | ||
87 | -7.4700999539E-4 3.6522001028E-4 2.2522680461E-2 0.1105690673 0.1768419296 0.1105690673 2.2522680461E-2 3.6522001028E-4 -7.4700999539E-4 ... | ||
88 | -1.3462699717E-3 3.7740699481E-3 -8.2581602037E-3 -3.9442278445E-2 -5.3605638444E-2 -3.9442278445E-2 -8.2581602037E-3 3.7740699481E-3 -1.3462699717E-3 ... | ||
89 | -3.9103501476E-3 -4.4565401040E-3 5.8724298142E-3 2.8760801069E-3 -8.5267601535E-3 2.8760801069E-3 5.8724298142E-3 -4.4565401040E-3 -3.9103501476E-3 ... | ||
90 | 8.1125000725E-4 -4.4451598078E-3 -1.2316980399E-2 -1.3955879956E-2 -1.4179450460E-2 -1.3955879956E-2 -1.2316980399E-2 -4.4451598078E-3 8.1125000725E-4; ... | ||
91 | ... | ||
92 | 0.0000000000 -8.2846998703E-4 -5.7109999034E-5 4.0110000555E-5 4.6670897864E-3 8.0871898681E-3 1.4807609841E-2 8.6204400286E-3 -3.1221499667E-3 ... | ||
93 | 8.2846998703E-4 0.0000000000 -9.7479997203E-4 -6.9718998857E-3 -2.0865600090E-3 2.3298799060E-3 -4.4814897701E-3 1.4917500317E-2 8.6204400286E-3 ... | ||
94 | 5.7109999034E-5 9.7479997203E-4 0.0000000000 -1.2145539746E-2 -2.4427289143E-2 5.0797060132E-2 3.2785870135E-2 -4.4814897701E-3 1.4807609841E-2 ... | ||
95 | -4.0110000555E-5 6.9718998857E-3 1.2145539746E-2 0.0000000000 -0.1510555595 -8.2495503128E-2 5.0797060132E-2 2.3298799060E-3 8.0871898681E-3 ... | ||
96 | -4.6670897864E-3 2.0865600090E-3 2.4427289143E-2 0.1510555595 0.0000000000 -0.1510555595 -2.4427289143E-2 -2.0865600090E-3 4.6670897864E-3 ... | ||
97 | -8.0871898681E-3 -2.3298799060E-3 -5.0797060132E-2 8.2495503128E-2 0.1510555595 0.0000000000 -1.2145539746E-2 -6.9718998857E-3 4.0110000555E-5 ... | ||
98 | -1.4807609841E-2 4.4814897701E-3 -3.2785870135E-2 -5.0797060132E-2 2.4427289143E-2 1.2145539746E-2 0.0000000000 -9.7479997203E-4 -5.7109999034E-5 ... | ||
99 | -8.6204400286E-3 -1.4917500317E-2 4.4814897701E-3 -2.3298799060E-3 2.0865600090E-3 6.9718998857E-3 9.7479997203E-4 0.0000000000 -8.2846998703E-4 ... | ||
100 | 3.1221499667E-3 -8.6204400286E-3 -1.4807609841E-2 -8.0871898681E-3 -4.6670897864E-3 -4.0110000555E-5 5.7109999034E-5 8.2846998703E-4 0.0000000000; ... | ||
101 | ... | ||
102 | 8.1125000725E-4 -3.9103501476E-3 -1.3462699717E-3 -7.4700999539E-4 0.0000000000 7.4700999539E-4 1.3462699717E-3 3.9103501476E-3 -8.1125000725E-4 ... | ||
103 | -4.4451598078E-3 -4.4565401040E-3 3.7740699481E-3 3.6522001028E-4 0.0000000000 -3.6522001028E-4 -3.7740699481E-3 4.4565401040E-3 4.4451598078E-3 ... | ||
104 | -1.2316980399E-2 5.8724298142E-3 -8.2581602037E-3 2.2522680461E-2 0.0000000000 -2.2522680461E-2 8.2581602037E-3 -5.8724298142E-3 1.2316980399E-2 ... | ||
105 | -1.3955879956E-2 2.8760801069E-3 -3.9442278445E-2 0.1105690673 0.0000000000 -0.1105690673 3.9442278445E-2 -2.8760801069E-3 1.3955879956E-2 ... | ||
106 | -1.4179450460E-2 -8.5267601535E-3 -5.3605638444E-2 0.1768419296 0.0000000000 -0.1768419296 5.3605638444E-2 8.5267601535E-3 1.4179450460E-2 ... | ||
107 | -1.3955879956E-2 2.8760801069E-3 -3.9442278445E-2 0.1105690673 0.0000000000 -0.1105690673 3.9442278445E-2 -2.8760801069E-3 1.3955879956E-2 ... | ||
108 | -1.2316980399E-2 5.8724298142E-3 -8.2581602037E-3 2.2522680461E-2 0.0000000000 -2.2522680461E-2 8.2581602037E-3 -5.8724298142E-3 1.2316980399E-2 ... | ||
109 | -4.4451598078E-3 -4.4565401040E-3 3.7740699481E-3 3.6522001028E-4 0.0000000000 -3.6522001028E-4 -3.7740699481E-3 4.4565401040E-3 4.4451598078E-3 ... | ||
110 | 8.1125000725E-4 -3.9103501476E-3 -1.3462699717E-3 -7.4700999539E-4 0.0000000000 7.4700999539E-4 1.3462699717E-3 3.9103501476E-3 -8.1125000725E-4; ... | ||
111 | ... | ||
112 | 3.1221499667E-3 -8.6204400286E-3 -1.4807609841E-2 -8.0871898681E-3 -4.6670897864E-3 -4.0110000555E-5 5.7109999034E-5 8.2846998703E-4 0.0000000000 ... | ||
113 | -8.6204400286E-3 -1.4917500317E-2 4.4814897701E-3 -2.3298799060E-3 2.0865600090E-3 6.9718998857E-3 9.7479997203E-4 -0.0000000000 -8.2846998703E-4 ... | ||
114 | -1.4807609841E-2 4.4814897701E-3 -3.2785870135E-2 -5.0797060132E-2 2.4427289143E-2 1.2145539746E-2 0.0000000000 -9.7479997203E-4 -5.7109999034E-5 ... | ||
115 | -8.0871898681E-3 -2.3298799060E-3 -5.0797060132E-2 8.2495503128E-2 0.1510555595 -0.0000000000 -1.2145539746E-2 -6.9718998857E-3 4.0110000555E-5 ... | ||
116 | -4.6670897864E-3 2.0865600090E-3 2.4427289143E-2 0.1510555595 0.0000000000 -0.1510555595 -2.4427289143E-2 -2.0865600090E-3 4.6670897864E-3 ... | ||
117 | -4.0110000555E-5 6.9718998857E-3 1.2145539746E-2 0.0000000000 -0.1510555595 -8.2495503128E-2 5.0797060132E-2 2.3298799060E-3 8.0871898681E-3 ... | ||
118 | 5.7109999034E-5 9.7479997203E-4 -0.0000000000 -1.2145539746E-2 -2.4427289143E-2 5.0797060132E-2 3.2785870135E-2 -4.4814897701E-3 1.4807609841E-2 ... | ||
119 | 8.2846998703E-4 -0.0000000000 -9.7479997203E-4 -6.9718998857E-3 -2.0865600090E-3 2.3298799060E-3 -4.4814897701E-3 1.4917500317E-2 8.6204400286E-3 ... | ||
120 | 0.0000000000 -8.2846998703E-4 -5.7109999034E-5 4.0110000555E-5 4.6670897864E-3 8.0871898681E-3 1.4807609841E-2 8.6204400286E-3 -3.1221499667E-3 ... | ||
121 | ]'; | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/sp5Filters.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/sp5Filters.m deleted file mode 100755 index 4cddcfd..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/sp5Filters.m +++ /dev/null | |||
@@ -1,110 +0,0 @@ | |||
1 | % Steerable pyramid filters. Transform described in: | ||
2 | % | ||
3 | % @INPROCEEDINGS{Simoncelli95b, | ||
4 | % TITLE = "The Steerable Pyramid: A Flexible Architecture for | ||
5 | % Multi-Scale Derivative Computation", | ||
6 | % AUTHOR = "E P Simoncelli and W T Freeman", | ||
7 | % BOOKTITLE = "Second Int'l Conf on Image Processing", | ||
8 | % ADDRESS = "Washington, DC", MONTH = "October", YEAR = 1995 } | ||
9 | % | ||
10 | % Filter kernel design described in: | ||
11 | % | ||
12 | %@INPROCEEDINGS{Karasaridis96, | ||
13 | % TITLE = "A Filter Design Technique for | ||
14 | % Steerable Pyramid Image Transforms", | ||
15 | % AUTHOR = "A Karasaridis and E P Simoncelli", | ||
16 | % BOOKTITLE = "ICASSP", ADDRESS = "Atlanta, GA", | ||
17 | % MONTH = "May", YEAR = 1996 } | ||
18 | |||
19 | % Eero Simoncelli, 6/96. | ||
20 | |||
21 | function [lo0filt,hi0filt,lofilt,bfilts,mtx,harmonics] = sp5Filters(); | ||
22 | |||
23 | harmonics = [1 3 5]; | ||
24 | |||
25 | mtx = [ ... | ||
26 | 0.3333 0.2887 0.1667 0.0000 -0.1667 -0.2887 | ||
27 | 0.0000 0.1667 0.2887 0.3333 0.2887 0.1667 | ||
28 | 0.3333 -0.0000 -0.3333 -0.0000 0.3333 -0.0000 | ||
29 | 0.0000 0.3333 0.0000 -0.3333 0.0000 0.3333 | ||
30 | 0.3333 -0.2887 0.1667 -0.0000 -0.1667 0.2887 | ||
31 | -0.0000 0.1667 -0.2887 0.3333 -0.2887 0.1667]; | ||
32 | |||
33 | hi0filt = [ | ||
34 | -0.00033429 -0.00113093 -0.00171484 -0.00133542 -0.00080639 -0.00133542 -0.00171484 -0.00113093 -0.00033429 | ||
35 | -0.00113093 -0.00350017 -0.00243812 0.00631653 0.01261227 0.00631653 -0.00243812 -0.00350017 -0.00113093 | ||
36 | -0.00171484 -0.00243812 -0.00290081 -0.00673482 -0.00981051 -0.00673482 -0.00290081 -0.00243812 -0.00171484 | ||
37 | -0.00133542 0.00631653 -0.00673482 -0.07027679 -0.11435863 -0.07027679 -0.00673482 0.00631653 -0.00133542 | ||
38 | -0.00080639 0.01261227 -0.00981051 -0.11435863 0.81380200 -0.11435863 -0.00981051 0.01261227 -0.00080639 | ||
39 | -0.00133542 0.00631653 -0.00673482 -0.07027679 -0.11435863 -0.07027679 -0.00673482 0.00631653 -0.00133542 | ||
40 | -0.00171484 -0.00243812 -0.00290081 -0.00673482 -0.00981051 -0.00673482 -0.00290081 -0.00243812 -0.00171484 | ||
41 | -0.00113093 -0.00350017 -0.00243812 0.00631653 0.01261227 0.00631653 -0.00243812 -0.00350017 -0.00113093 | ||
42 | -0.00033429 -0.00113093 -0.00171484 -0.00133542 -0.00080639 -0.00133542 -0.00171484 -0.00113093 -0.00033429]; | ||
43 | |||
44 | |||
45 | lo0filt = [ | ||
46 | 0.00341614 -0.01551246 -0.03848215 -0.01551246 0.00341614 | ||
47 | -0.01551246 0.05586982 0.15925570 0.05586982 -0.01551246 | ||
48 | -0.03848215 0.15925570 0.40304148 0.15925570 -0.03848215 | ||
49 | -0.01551246 0.05586982 0.15925570 0.05586982 -0.01551246 | ||
50 | 0.00341614 -0.01551246 -0.03848215 -0.01551246 0.00341614]; | ||
51 | |||
52 | lofilt = 2*[ | ||
53 | 0.00085404 -0.00244917 -0.00387812 -0.00944432 -0.00962054 -0.00944432 -0.00387812 -0.00244917 0.00085404 | ||
54 | -0.00244917 -0.00523281 -0.00661117 0.00410600 0.01002988 0.00410600 -0.00661117 -0.00523281 -0.00244917 | ||
55 | -0.00387812 -0.00661117 0.01396746 0.03277038 0.03981393 0.03277038 0.01396746 -0.00661117 -0.00387812 | ||
56 | -0.00944432 0.00410600 0.03277038 0.06426333 0.08169618 0.06426333 0.03277038 0.00410600 -0.00944432 | ||
57 | -0.00962054 0.01002988 0.03981393 0.08169618 0.10096540 0.08169618 0.03981393 0.01002988 -0.00962054 | ||
58 | -0.00944432 0.00410600 0.03277038 0.06426333 0.08169618 0.06426333 0.03277038 0.00410600 -0.00944432 | ||
59 | -0.00387812 -0.00661117 0.01396746 0.03277038 0.03981393 0.03277038 0.01396746 -0.00661117 -0.00387812 | ||
60 | -0.00244917 -0.00523281 -0.00661117 0.00410600 0.01002988 0.00410600 -0.00661117 -0.00523281 -0.00244917 | ||
61 | 0.00085404 -0.00244917 -0.00387812 -0.00944432 -0.00962054 -0.00944432 -0.00387812 -0.00244917 0.00085404]; | ||
62 | |||
63 | bfilts = [... | ||
64 | 0.00277643 0.00496194 0.01026699 0.01455399 0.01026699 0.00496194 0.00277643 ... | ||
65 | -0.00986904 -0.00893064 0.01189859 0.02755155 0.01189859 -0.00893064 -0.00986904 ... | ||
66 | -0.01021852 -0.03075356 -0.08226445 -0.11732297 -0.08226445 -0.03075356 -0.01021852 ... | ||
67 | 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 ... | ||
68 | 0.01021852 0.03075356 0.08226445 0.11732297 0.08226445 0.03075356 0.01021852 ... | ||
69 | 0.00986904 0.00893064 -0.01189859 -0.02755155 -0.01189859 0.00893064 0.00986904 ... | ||
70 | -0.00277643 -0.00496194 -0.01026699 -0.01455399 -0.01026699 -0.00496194 -0.00277643; | ||
71 | ... | ||
72 | -0.00343249 -0.00640815 -0.00073141 0.01124321 0.00182078 0.00285723 0.01166982 ... | ||
73 | -0.00358461 -0.01977507 -0.04084211 -0.00228219 0.03930573 0.01161195 0.00128000 ... | ||
74 | 0.01047717 0.01486305 -0.04819057 -0.12227230 -0.05394139 0.00853965 -0.00459034 ... | ||
75 | 0.00790407 0.04435647 0.09454202 -0.00000000 -0.09454202 -0.04435647 -0.00790407 ... | ||
76 | 0.00459034 -0.00853965 0.05394139 0.12227230 0.04819057 -0.01486305 -0.01047717 ... | ||
77 | -0.00128000 -0.01161195 -0.03930573 0.00228219 0.04084211 0.01977507 0.00358461 ... | ||
78 | -0.01166982 -0.00285723 -0.00182078 -0.01124321 0.00073141 0.00640815 0.00343249; | ||
79 | ... | ||
80 | 0.00343249 0.00358461 -0.01047717 -0.00790407 -0.00459034 0.00128000 0.01166982 ... | ||
81 | 0.00640815 0.01977507 -0.01486305 -0.04435647 0.00853965 0.01161195 0.00285723 ... | ||
82 | 0.00073141 0.04084211 0.04819057 -0.09454202 -0.05394139 0.03930573 0.00182078 ... | ||
83 | -0.01124321 0.00228219 0.12227230 -0.00000000 -0.12227230 -0.00228219 0.01124321 ... | ||
84 | -0.00182078 -0.03930573 0.05394139 0.09454202 -0.04819057 -0.04084211 -0.00073141 ... | ||
85 | -0.00285723 -0.01161195 -0.00853965 0.04435647 0.01486305 -0.01977507 -0.00640815 ... | ||
86 | -0.01166982 -0.00128000 0.00459034 0.00790407 0.01047717 -0.00358461 -0.00343249; | ||
87 | ... | ||
88 | -0.00277643 0.00986904 0.01021852 -0.00000000 -0.01021852 -0.00986904 0.00277643 ... | ||
89 | -0.00496194 0.00893064 0.03075356 -0.00000000 -0.03075356 -0.00893064 0.00496194 ... | ||
90 | -0.01026699 -0.01189859 0.08226445 -0.00000000 -0.08226445 0.01189859 0.01026699 ... | ||
91 | -0.01455399 -0.02755155 0.11732297 -0.00000000 -0.11732297 0.02755155 0.01455399 ... | ||
92 | -0.01026699 -0.01189859 0.08226445 -0.00000000 -0.08226445 0.01189859 0.01026699 ... | ||
93 | -0.00496194 0.00893064 0.03075356 -0.00000000 -0.03075356 -0.00893064 0.00496194 ... | ||
94 | -0.00277643 0.00986904 0.01021852 -0.00000000 -0.01021852 -0.00986904 0.00277643; | ||
95 | ... | ||
96 | -0.01166982 -0.00128000 0.00459034 0.00790407 0.01047717 -0.00358461 -0.00343249 ... | ||
97 | -0.00285723 -0.01161195 -0.00853965 0.04435647 0.01486305 -0.01977507 -0.00640815 ... | ||
98 | -0.00182078 -0.03930573 0.05394139 0.09454202 -0.04819057 -0.04084211 -0.00073141 ... | ||
99 | -0.01124321 0.00228219 0.12227230 -0.00000000 -0.12227230 -0.00228219 0.01124321 ... | ||
100 | 0.00073141 0.04084211 0.04819057 -0.09454202 -0.05394139 0.03930573 0.00182078 ... | ||
101 | 0.00640815 0.01977507 -0.01486305 -0.04435647 0.00853965 0.01161195 0.00285723 ... | ||
102 | 0.00343249 0.00358461 -0.01047717 -0.00790407 -0.00459034 0.00128000 0.01166982; | ||
103 | ... | ||
104 | -0.01166982 -0.00285723 -0.00182078 -0.01124321 0.00073141 0.00640815 0.00343249 ... | ||
105 | -0.00128000 -0.01161195 -0.03930573 0.00228219 0.04084211 0.01977507 0.00358461 ... | ||
106 | 0.00459034 -0.00853965 0.05394139 0.12227230 0.04819057 -0.01486305 -0.01047717 ... | ||
107 | 0.00790407 0.04435647 0.09454202 -0.00000000 -0.09454202 -0.04435647 -0.00790407 ... | ||
108 | 0.01047717 0.01486305 -0.04819057 -0.12227230 -0.05394139 0.00853965 -0.00459034 ... | ||
109 | -0.00358461 -0.01977507 -0.04084211 -0.00228219 0.03930573 0.01161195 0.00128000 ... | ||
110 | -0.00343249 -0.00640815 -0.00073141 0.01124321 0.00182078 0.00285723 0.01166982]'; | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/spyrBand.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/spyrBand.m deleted file mode 100755 index 474a8dc..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/spyrBand.m +++ /dev/null | |||
@@ -1,34 +0,0 @@ | |||
1 | % [LEV,IND] = spyrBand(PYR,INDICES,LEVEL,BAND) | ||
2 | % | ||
3 | % Access a band from a steerable pyramid. | ||
4 | % | ||
5 | % LEVEL indicates the scale (finest = 1, coarsest = spyrHt(INDICES)). | ||
6 | % | ||
7 | % BAND (optional, default=1) indicates which subband | ||
8 | % (1 = vertical, rest proceeding anti-clockwise). | ||
9 | |||
10 | % Eero Simoncelli, 6/96. | ||
11 | |||
12 | function res = spyrBand(pyr,pind,level,band) | ||
13 | |||
14 | if (exist('level') ~= 1) | ||
15 | level = 1; | ||
16 | end | ||
17 | |||
18 | if (exist('band') ~= 1) | ||
19 | band = 1; | ||
20 | end | ||
21 | |||
22 | nbands = spyrNumBands(pind); | ||
23 | if ((band > nbands) | (band < 1)) | ||
24 | error(sprintf('Bad band number (%d) should be in range [1,%d].', band, nbands)); | ||
25 | end | ||
26 | |||
27 | maxLev = spyrHt(pind); | ||
28 | if ((level > maxLev) | (level < 1)) | ||
29 | error(sprintf('Bad level number (%d), should be in range [1,%d].', level, maxLev)); | ||
30 | end | ||
31 | |||
32 | firstband = 1 + band + nbands*(level-1); | ||
33 | res = pyrBand(pyr, pind, firstband); | ||
34 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/spyrHigh.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/spyrHigh.m deleted file mode 100755 index f91b466..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/spyrHigh.m +++ /dev/null | |||
@@ -1,10 +0,0 @@ | |||
1 | % RES = spyrHigh(PYR, INDICES) | ||
2 | % | ||
3 | % Access the highpass residual band from a steerable pyramid. | ||
4 | |||
5 | % Eero Simoncelli, 6/96. | ||
6 | |||
7 | function res = spyrHigh(pyr,pind) | ||
8 | |||
9 | res = pyrBand(pyr, pind, 1); | ||
10 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/spyrHt.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/spyrHt.m deleted file mode 100755 index 8706b9e..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/spyrHt.m +++ /dev/null | |||
@@ -1,16 +0,0 @@ | |||
1 | % [HEIGHT] = spyrHt(INDICES) | ||
2 | % | ||
3 | % Compute height of steerable pyramid with given index matrix. | ||
4 | |||
5 | % Eero Simoncelli, 6/96. | ||
6 | |||
7 | function [ht] = spyrHt(pind) | ||
8 | |||
9 | nbands = spyrNumBands(pind); | ||
10 | |||
11 | % Don't count lowpass, or highpass residual bands | ||
12 | if (size(pind,1) > 2) | ||
13 | ht = (size(pind,1)-2)/nbands; | ||
14 | else | ||
15 | ht = 0; | ||
16 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/spyrLev.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/spyrLev.m deleted file mode 100755 index 5cb4a85..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/spyrLev.m +++ /dev/null | |||
@@ -1,24 +0,0 @@ | |||
1 | % [LEV,IND] = spyrLev(PYR,INDICES,LEVEL) | ||
2 | % | ||
3 | % Access a level from a steerable pyramid. | ||
4 | % Return as an SxB matrix, B = number of bands, S = total size of a band. | ||
5 | % Also returns an Bx2 matrix containing dimensions of the subbands. | ||
6 | |||
7 | % Eero Simoncelli, 6/96. | ||
8 | |||
9 | function [lev,ind] = spyrLev(pyr,pind,level) | ||
10 | |||
11 | nbands = spyrNumBands(pind); | ||
12 | |||
13 | if ((level > spyrHt(pind)) | (level < 1)) | ||
14 | error(sprintf('Level number must be in the range [1, %d].', spyrHt(pind))); | ||
15 | end | ||
16 | |||
17 | firstband = 2 + nbands*(level-1); | ||
18 | firstind = 1; | ||
19 | for l=1:firstband-1 | ||
20 | firstind = firstind + prod(pind(l,:)); | ||
21 | end | ||
22 | |||
23 | ind = pind(firstband:firstband+nbands-1,:); | ||
24 | lev = pyr(firstind:firstind+sum(prod(ind'))-1); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/spyrNumBands.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/spyrNumBands.m deleted file mode 100755 index 68aec3f..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/spyrNumBands.m +++ /dev/null | |||
@@ -1,20 +0,0 @@ | |||
1 | % [NBANDS] = spyrNumBands(INDICES) | ||
2 | % | ||
3 | % Compute number of orientation bands in a steerable pyramid with | ||
4 | % given index matrix. If the pyramid contains only the highpass and | ||
5 | % lowpass bands (i.e., zero levels), returns 0. | ||
6 | |||
7 | % Eero Simoncelli, 2/97. | ||
8 | |||
9 | function [nbands] = spyrNumBands(pind) | ||
10 | |||
11 | if (size(pind,1) == 2) | ||
12 | nbands = 0; | ||
13 | else | ||
14 | % Count number of orientation bands: | ||
15 | b = 3; | ||
16 | while ((b <= size(pind,1)) & all( pind(b,:) == pind(2,:)) ) | ||
17 | b = b+1; | ||
18 | end | ||
19 | nbands = b-2; | ||
20 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/steer.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/steer.m deleted file mode 100755 index 8f9c2ac..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/steer.m +++ /dev/null | |||
@@ -1,68 +0,0 @@ | |||
1 | % RES = STEER(BASIS, ANGLE, HARMONICS, STEERMTX) | ||
2 | % | ||
3 | % Steer BASIS to the specfied ANGLE. | ||
4 | % | ||
5 | % BASIS should be a matrix whose columns are vectorized rotated copies of a | ||
6 | % steerable function, or the responses of a set of steerable filters. | ||
7 | % | ||
8 | % ANGLE can be a scalar, or a column vector the size of the basis. | ||
9 | % | ||
10 | % HARMONICS (optional, default is N even or odd low frequencies, as for | ||
11 | % derivative filters) should be a list of harmonic numbers indicating | ||
12 | % the angular harmonic content of the basis. | ||
13 | % | ||
14 | % STEERMTX (optional, default assumes cosine phase harmonic components, | ||
15 | % and filter positions at 2pi*n/N) should be a matrix which maps | ||
16 | % the filters onto Fourier series components (ordered [cos0 cos1 sin1 | ||
17 | % cos2 sin2 ... sinN]). See steer2HarmMtx.m | ||
18 | |||
19 | % Eero Simoncelli, 7/96. | ||
20 | |||
21 | function res = steer(basis,angle,harmonics,steermtx) | ||
22 | |||
23 | num = size(basis,2); | ||
24 | |||
25 | if ( any(size(angle) ~= [size(basis,1) 1]) & any(size(angle) ~= [1 1]) ) | ||
26 | error('ANGLE must be a scalar, or a column vector the size of the basis elements'); | ||
27 | end | ||
28 | |||
29 | %% If HARMONICS are not passed, assume derivatives. | ||
30 | if (exist('harmonics') ~= 1) | ||
31 | if (mod(num,2) == 0) | ||
32 | harmonics = [0:(num/2)-1]'*2 + 1; | ||
33 | else | ||
34 | harmonics = [0:(num-1)/2]'*2; | ||
35 | end | ||
36 | else | ||
37 | harmonics = harmonics(:); | ||
38 | if ((2*size(harmonics,1)-any(harmonics == 0)) ~= num) | ||
39 | error('harmonics list is incompatible with basis size'); | ||
40 | end | ||
41 | end | ||
42 | |||
43 | %% If STEERMTX not passed, assume evenly distributed cosine-phase filters: | ||
44 | if (exist('steermtx') ~= 1) | ||
45 | steermtx = steer2HarmMtx(harmonics, pi*[0:num-1]/num, 'even'); | ||
46 | end | ||
47 | |||
48 | steervect = zeros(size(angle,1),num); | ||
49 | arg = angle * harmonics(find(harmonics~=0))'; | ||
50 | if (all(harmonics)) | ||
51 | steervect(:, 1:2:num) = cos(arg); | ||
52 | steervect(:, 2:2:num) = sin(arg); | ||
53 | else | ||
54 | steervect(:, 1) = ones(size(arg,1),1); | ||
55 | steervect(:, 2:2:num) = cos(arg); | ||
56 | steervect(:, 3:2:num) = sin(arg); | ||
57 | end | ||
58 | |||
59 | steervect = steervect * steermtx; | ||
60 | |||
61 | if (size(steervect,1) > 1) | ||
62 | tmp = basis' .* steervect'; | ||
63 | res = sum(tmp)'; | ||
64 | else | ||
65 | res = basis * steervect'; | ||
66 | end | ||
67 | |||
68 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/steer2HarmMtx.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/steer2HarmMtx.m deleted file mode 100755 index 1f3e80e..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/steer2HarmMtx.m +++ /dev/null | |||
@@ -1,71 +0,0 @@ | |||
1 | % MTX = steer2HarmMtx(HARMONICS, ANGLES, REL_PHASES) | ||
2 | % | ||
3 | % Compute a steering matrix (maps a directional basis set onto the | ||
4 | % angular Fourier harmonics). HARMONICS is a vector specifying the | ||
5 | % angular harmonics contained in the steerable basis/filters. ANGLES | ||
6 | % (optional) is a vector specifying the angular position of each filter. | ||
7 | % REL_PHASES (optional, default = 'even') specifies whether the harmonics | ||
8 | % are cosine or sine phase aligned about those positions. | ||
9 | % The result matrix is suitable for passing to the function STEER. | ||
10 | |||
11 | % Eero Simoncelli, 7/96. | ||
12 | |||
13 | function mtx = steer2HarmMtx(harmonics, angles, evenorodd) | ||
14 | |||
15 | %%================================================================= | ||
16 | %%% Optional Parameters: | ||
17 | |||
18 | if (exist('evenorodd') ~= 1) | ||
19 | evenorodd = 'even'; | ||
20 | end | ||
21 | |||
22 | % Make HARMONICS a row vector | ||
23 | harmonics = harmonics(:)'; | ||
24 | |||
25 | numh = 2*size(harmonics,2) - any(harmonics == 0); | ||
26 | |||
27 | if (exist('angles') ~= 1) | ||
28 | angles = pi * [0:numh-1]'/numh; | ||
29 | else | ||
30 | angles = angles(:); | ||
31 | end | ||
32 | |||
33 | %%================================================================= | ||
34 | |||
35 | if isstr(evenorodd) | ||
36 | if strcmp(evenorodd,'even') | ||
37 | evenorodd = 0; | ||
38 | elseif strcmp(evenorodd,'odd') | ||
39 | evenorodd = 1; | ||
40 | else | ||
41 | error('EVEN_OR_ODD should be the string EVEN or ODD'); | ||
42 | end | ||
43 | end | ||
44 | |||
45 | %% Compute inverse matrix, which maps Fourier components onto | ||
46 | %% steerable basis. | ||
47 | imtx = zeros(size(angles,1),numh); | ||
48 | col = 1; | ||
49 | for h=harmonics | ||
50 | args = h*angles; | ||
51 | if (h == 0) | ||
52 | imtx(:,col) = ones(size(angles)); | ||
53 | col = col+1; | ||
54 | elseif evenorodd | ||
55 | imtx(:,col) = sin(args); | ||
56 | imtx(:,col+1) = -cos(args); | ||
57 | col = col+2; | ||
58 | else | ||
59 | imtx(:,col) = cos(args); | ||
60 | imtx(:,col+1) = sin(args); | ||
61 | col = col+2; | ||
62 | end | ||
63 | end | ||
64 | |||
65 | r = rank(imtx); | ||
66 | if (( r ~= numh ) & ( r ~= size(angles,1) )) | ||
67 | fprintf(2,'WARNING: matrix is not full rank'); | ||
68 | end | ||
69 | |||
70 | mtx = pinv(imtx); | ||
71 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/subMtx.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/subMtx.m deleted file mode 100755 index ea3c2ea..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/subMtx.m +++ /dev/null | |||
@@ -1,21 +0,0 @@ | |||
1 | % MTX = subMtx(VEC, DIMENSIONS, START_INDEX) | ||
2 | % | ||
3 | % Reshape a portion of VEC starting from START_INDEX (optional, | ||
4 | % default=1) to the given dimensions. | ||
5 | |||
6 | % Eero Simoncelli, 6/96. | ||
7 | |||
8 | function mtx = subMtx(vec, sz, offset) | ||
9 | |||
10 | if (exist('offset') ~= 1) | ||
11 | offset = 1; | ||
12 | end | ||
13 | |||
14 | vec = vec(:); | ||
15 | sz = sz(:); | ||
16 | |||
17 | if (size(sz,1) ~= 2) | ||
18 | error('DIMENSIONS must be a 2-vector.'); | ||
19 | end | ||
20 | |||
21 | mtx = reshape( vec(offset:offset+prod(sz)-1), sz(1), sz(2) ); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/upBlur.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/upBlur.m deleted file mode 100755 index 948c2e1..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/upBlur.m +++ /dev/null | |||
@@ -1,52 +0,0 @@ | |||
1 | % RES = upBlur(IM, LEVELS, FILT) | ||
2 | % | ||
3 | % Upsample and blur an image. The blurring is done with filter | ||
4 | % kernel specified by FILT (default = 'binom5'), which can be a string | ||
5 | % (to be passed to namedFilter), a vector (applied separably as a 1D | ||
6 | % convolution kernel in X and Y), or a matrix (applied as a 2D | ||
7 | % convolution kernel). The downsampling is always by 2 in each | ||
8 | % direction. | ||
9 | % | ||
10 | % The procedure is applied recursively LEVELS times (default=1). | ||
11 | |||
12 | % Eero Simoncelli, 4/97. | ||
13 | |||
14 | function res = upBlur(im, nlevs, filt) | ||
15 | |||
16 | %------------------------------------------------------------ | ||
17 | %% OPTIONAL ARGS: | ||
18 | |||
19 | if (exist('nlevs') ~= 1) | ||
20 | nlevs = 1; | ||
21 | end | ||
22 | |||
23 | if (exist('filt') ~= 1) | ||
24 | filt = 'binom5'; | ||
25 | end | ||
26 | |||
27 | %------------------------------------------------------------ | ||
28 | |||
29 | if isstr(filt) | ||
30 | filt = namedFilter(filt); | ||
31 | end | ||
32 | |||
33 | if nlevs > 1 | ||
34 | im = upBlur(im,nlevs-1,filt); | ||
35 | end | ||
36 | |||
37 | if (nlevs >= 1) | ||
38 | if (any(size(im)==1)) | ||
39 | if (size(im,1)==1) | ||
40 | filt = filt'; | ||
41 | end | ||
42 | res = upConv(im,filt,'reflect1',(size(im)~=1)+1); | ||
43 | elseif (any(size(filt)==1)) | ||
44 | filt = filt(:); | ||
45 | res = upConv(im,filt,'reflect1',[2 1]); | ||
46 | res = upConv(res,filt','reflect1',[1 2]); | ||
47 | else | ||
48 | res = upConv(im,filt,'reflect1',[2 2]); | ||
49 | end | ||
50 | else | ||
51 | res = im; | ||
52 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/upConv.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/upConv.m deleted file mode 100755 index 4d1ffd9..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/upConv.m +++ /dev/null | |||
@@ -1,80 +0,0 @@ | |||
1 | % RES = upConv(IM, FILT, EDGES, STEP, START, STOP, RES) | ||
2 | % | ||
3 | % Upsample matrix IM, followed by convolution with matrix FILT. These | ||
4 | % arguments should be 1D or 2D matrices, and IM must be larger (in | ||
5 | % both dimensions) than FILT. The origin of filt | ||
6 | % is assumed to be floor(size(filt)/2)+1. | ||
7 | % | ||
8 | % EDGES is a string determining boundary handling: | ||
9 | % 'circular' - Circular convolution | ||
10 | % 'reflect1' - Reflect about the edge pixels | ||
11 | % 'reflect2' - Reflect, doubling the edge pixels | ||
12 | % 'repeat' - Repeat the edge pixels | ||
13 | % 'zero' - Assume values of zero outside image boundary | ||
14 | % 'extend' - Reflect and invert | ||
15 | % 'dont-compute' - Zero output when filter overhangs OUTPUT boundaries | ||
16 | % | ||
17 | % Upsampling factors are determined by STEP (optional, default=[1 1]), | ||
18 | % a 2-vector [y,x]. | ||
19 | % | ||
20 | % The window over which the convolution occurs is specfied by START | ||
21 | % (optional, default=[1,1], and STOP (optional, default = | ||
22 | % step .* (size(IM) + floor((start-1)./step))). | ||
23 | % | ||
24 | % RES is an optional result matrix. The convolution result will be | ||
25 | % destructively added into this matrix. If this argument is passed, the | ||
26 | % result matrix will not be returned. DO NOT USE THIS ARGUMENT IF | ||
27 | % YOU DO NOT UNDERSTAND WHAT THIS MEANS!! | ||
28 | % | ||
29 | % NOTE: this operation corresponds to multiplication of a signal | ||
30 | % vector by a matrix whose columns contain copies of the time-reversed | ||
31 | % (or space-reversed) FILT shifted by multiples of STEP. See corrDn.m | ||
32 | % for the operation corresponding to the transpose of this matrix. | ||
33 | |||
34 | % Eero Simoncelli, 6/96. revised 2/97. | ||
35 | |||
36 | function result = upConv(im,filt,edges,step,start,stop,res) | ||
37 | |||
38 | %% THIS CODE IS NOT ACTUALLY USED! (MEX FILE IS CALLED INSTEAD) | ||
39 | |||
40 | fprintf(1,'WARNING: You should compile the MEX version of "upConv.c",\n found in the MEX subdirectory of matlabPyrTools, and put it in your matlab path. It is MUCH faster, and provides more boundary-handling options.\n'); | ||
41 | |||
42 | %------------------------------------------------------------ | ||
43 | %% OPTIONAL ARGS: | ||
44 | |||
45 | if (exist('edges') == 1) | ||
46 | if (strcmp(edges,'reflect1') ~= 1) | ||
47 | warning('Using REFLECT1 edge-handling (use MEX code for other options).'); | ||
48 | end | ||
49 | end | ||
50 | |||
51 | if (exist('step') ~= 1) | ||
52 | step = [1,1]; | ||
53 | end | ||
54 | |||
55 | if (exist('start') ~= 1) | ||
56 | start = [1,1]; | ||
57 | end | ||
58 | |||
59 | % A multiple of step | ||
60 | if (exist('stop') ~= 1) | ||
61 | stop = step .* (floor((start-ones(size(start)))./step)+size(im)) | ||
62 | end | ||
63 | |||
64 | if ( ceil((stop(1)+1-start(1)) / step(1)) ~= size(im,1) ) | ||
65 | error('Bad Y result dimension'); | ||
66 | end | ||
67 | if ( ceil((stop(2)+1-start(2)) / step(2)) ~= size(im,2) ) | ||
68 | error('Bad X result dimension'); | ||
69 | end | ||
70 | |||
71 | if (exist('res') ~= 1) | ||
72 | res = zeros(stop-start+1); | ||
73 | end | ||
74 | |||
75 | %------------------------------------------------------------ | ||
76 | |||
77 | tmp = zeros(size(res)); | ||
78 | tmp(start(1):step(1):stop(1),start(2):step(2):stop(2)) = im; | ||
79 | |||
80 | result = rconv2(tmp,filt) + res; | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/var2.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/var2.m deleted file mode 100755 index 6957eff..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/var2.m +++ /dev/null | |||
@@ -1,17 +0,0 @@ | |||
1 | % V = VAR2(MTX,MEAN) | ||
2 | % | ||
3 | % Sample variance of a matrix. | ||
4 | % Passing MEAN (optional) makes the calculation faster. | ||
5 | |||
6 | function res = var2(mtx, mn) | ||
7 | |||
8 | if (exist('mn') ~= 1) | ||
9 | mn = mean2(mtx); | ||
10 | end | ||
11 | |||
12 | if (isreal(mtx)) | ||
13 | res = sum(sum(abs(mtx-mn).^2)) / max((prod(size(mtx)) - 1),1); | ||
14 | else | ||
15 | res = sum(sum(real(mtx-mn).^2)) + i*sum(sum(imag(mtx-mn).^2)); | ||
16 | res = res / max((prod(size(mtx)) - 1),1); | ||
17 | end | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/vectify.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/vectify.m deleted file mode 100755 index 3664223..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/vectify.m +++ /dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | % [VEC] = columnize(MTX) | ||
2 | % | ||
3 | % Pack elements of MTX into a column vector. Just provides a | ||
4 | % function-call notatoin for the operation MTX(:) | ||
5 | |||
6 | function vec = columnize(mtx) | ||
7 | |||
8 | vec = mtx(:); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/wpyrBand.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/wpyrBand.m deleted file mode 100755 index c027cca..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/wpyrBand.m +++ /dev/null | |||
@@ -1,39 +0,0 @@ | |||
1 | % RES = wpyrBand(PYR, INDICES, LEVEL, BAND) | ||
2 | % | ||
3 | % Access a subband from a separable QMF/wavelet pyramid. | ||
4 | % | ||
5 | % LEVEL (optional, default=1) indicates the scale (finest = 1, | ||
6 | % coarsest = wpyrHt(INDICES)). | ||
7 | % | ||
8 | % BAND (optional, default=1) indicates which subband (1=horizontal, | ||
9 | % 2=vertical, 3=diagonal). | ||
10 | |||
11 | % Eero Simoncelli, 6/96. | ||
12 | |||
13 | function im = wpyrBand(pyr,pind,level,band) | ||
14 | |||
15 | if (exist('level') ~= 1) | ||
16 | level = 1; | ||
17 | end | ||
18 | |||
19 | if (exist('band') ~= 1) | ||
20 | band = 1; | ||
21 | end | ||
22 | |||
23 | if ((pind(1,1) == 1) | (pind(1,2) ==1)) | ||
24 | nbands = 1; | ||
25 | else | ||
26 | nbands = 3; | ||
27 | end | ||
28 | |||
29 | if ((band > nbands) | (band < 1)) | ||
30 | error(sprintf('Bad band number (%d) should be in range [1,%d].', band, nbands)); | ||
31 | end | ||
32 | |||
33 | maxLev = wpyrHt(pind); | ||
34 | if ((level > maxLev) | (level < 1)) | ||
35 | error(sprintf('Bad level number (%d), should be in range [1,%d].', level, maxLev)); | ||
36 | end | ||
37 | |||
38 | band = band + nbands*(level-1); | ||
39 | im = pyrBand(pyr,pind,band); | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/wpyrHt.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/wpyrHt.m deleted file mode 100755 index 476be83..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/wpyrHt.m +++ /dev/null | |||
@@ -1,15 +0,0 @@ | |||
1 | % [HEIGHT] = wpyrHt(INDICES) | ||
2 | % | ||
3 | % Compute height of separable QMF/wavelet pyramid with given index matrix. | ||
4 | |||
5 | % Eero Simoncelli, 6/96. | ||
6 | |||
7 | function [ht] = wpyrHt(pind) | ||
8 | |||
9 | if ((pind(1,1) == 1) | (pind(1,2) ==1)) | ||
10 | nbands = 1; | ||
11 | else | ||
12 | nbands = 3; | ||
13 | end | ||
14 | |||
15 | ht = (size(pind,1)-1)/nbands; | ||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/wpyrLev.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/wpyrLev.m deleted file mode 100755 index 18f30ae..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/wpyrLev.m +++ /dev/null | |||
@@ -1,30 +0,0 @@ | |||
1 | % [LEV,IND] = wpyrLev(PYR,INDICES,LEVEL) | ||
2 | % | ||
3 | % Access a level from a separable QMF/wavelet pyramid. | ||
4 | % Return as an SxB matrix, B = number of bands, S = total size of a band. | ||
5 | % Also returns an Bx2 matrix containing dimensions of the subbands. | ||
6 | |||
7 | % Eero Simoncelli, 6/96. | ||
8 | |||
9 | function [lev,ind] = wpyrLev(pyr,pind,level) | ||
10 | |||
11 | if ((pind(1,1) == 1) | (pind(1,2) ==1)) | ||
12 | nbands = 1; | ||
13 | else | ||
14 | nbands = 3; | ||
15 | end | ||
16 | |||
17 | if ((level > wpyrHt(pind)) | (level < 1)) | ||
18 | error(sprintf('Level number must be in the range [1, %d].', wpyrHt(pind))); | ||
19 | end | ||
20 | |||
21 | firstband = 1 + nbands*(level-1) | ||
22 | firstind = 1; | ||
23 | for l=1:firstband-1 | ||
24 | firstind = firstind + prod(pind(l,:)); | ||
25 | end | ||
26 | |||
27 | |||
28 | ind = pind(firstband:firstband+nbands-1,:); | ||
29 | lev = pyr(firstind:firstind+sum(prod(ind'))-1); | ||
30 | |||
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/zconv2.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/zconv2.m deleted file mode 100755 index f678d89..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/zconv2.m +++ /dev/null | |||
@@ -1,41 +0,0 @@ | |||
1 | % RES = ZCONV2(MTX1, MTX2, CTR) | ||
2 | % | ||
3 | % Convolution of two matrices, with boundaries handled as if the larger mtx | ||
4 | % lies in a sea of zeros. Result will be of size of LARGER vector. | ||
5 | % | ||
6 | % The origin of the smaller matrix is assumed to be its center. | ||
7 | % For even dimensions, the origin is determined by the CTR (optional) | ||
8 | % argument: | ||
9 | % CTR origin | ||
10 | % 0 DIM/2 (default) | ||
11 | % 1 (DIM/2)+1 (behaves like conv2(mtx1,mtx2,'same')) | ||
12 | |||
13 | % Eero Simoncelli, 2/97. | ||
14 | |||
15 | function c = zconv2(a,b,ctr) | ||
16 | |||
17 | if (exist('ctr') ~= 1) | ||
18 | ctr = 0; | ||
19 | end | ||
20 | |||
21 | if (( size(a,1) >= size(b,1) ) & ( size(a,2) >= size(b,2) )) | ||
22 | large = a; small = b; | ||
23 | elseif (( size(a,1) <= size(b,1) ) & ( size(a,2) <= size(b,2) )) | ||
24 | large = b; small = a; | ||
25 | else | ||
26 | error('one arg must be larger than the other in both dimensions!'); | ||
27 | end | ||
28 | |||
29 | ly = size(large,1); | ||
30 | lx = size(large,2); | ||
31 | sy = size(small,1); | ||
32 | sx = size(small,2); | ||
33 | |||
34 | %% These values are the index of the small mtx that falls on the | ||
35 | %% border pixel of the large matrix when computing the first | ||
36 | %% convolution response sample: | ||
37 | sy2 = floor((sy+ctr+1)/2); | ||
38 | sx2 = floor((sx+ctr+1)/2); | ||
39 | |||
40 | clarge = conv2(large,small); | ||
41 | c = clarge(sy2:ly+sy2-1, sx2:lx+sx2-1); | ||