diff options
Diffstat (limited to 'SD-VBS/benchmarks/texture_synthesis/src/matlab/buildLpyr.m')
| -rwxr-xr-x | SD-VBS/benchmarks/texture_synthesis/src/matlab/buildLpyr.m | 109 |
1 files changed, 0 insertions, 109 deletions
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 | |||
