Você está na página 1de 16

Pdfbdec.

m function y = pdfbdec(x, pfilt, dfilt, nlevs) % PDFBDEC Pyramidal Directional Filter Bank (or Contourlet) Decomposition % % y = pdfbdec(x, pfilt, dfilt, nlevs) % % Input: % x: input image % pfilt: filter name for the pyramidal decomposition step % dfilt: filter name for the directional decomposition step % nlevs: vector of numbers of directional filter bank decomposition levels % at each pyramidal level (from coarse to fine scale). % If the number of level is 0, a critically sampled 2-D wavelet % decomposition step is performed. % % Output: % y: a cell vector of length length(nlevs) + 1, where except y{1} is % the lowpass subband, each cell corresponds to one pyramidal % level and is a cell vector that contains bandpass directional % subbands from the DFB at that level. % % Index convention: % Suppose that nlevs = [l_J,...,l_2, l_1], and l_j >= 2. % Then for j = 1,...,J and k = 1,...,2^l_j % y{J+2-j}{k}(n_1, n_2) % is a contourlet coefficient at scale 2^j, direction k, and position % (n_1 * 2^(j+l_j-2), n_2 * 2^j) for k <= 2^(l_j-1), % (n_1 * 2^j, n_2 * 2^(j+l_j-2)) for k > 2^(l_j-1). % As k increases from 1 to 2^l_j, direction k rotates clockwise from % the angle 135 degree with uniform increment in cotan, from -1 to 1 for % k <= 2^(l_j-1), and then uniform decrement in tan, from 1 to -1 for % k > 2^(l_j-1). % % See also: PFILTERS, DFILTERS, PDFBREC if length(nlevs) == 0 y = {x}; else % Get the pyramidal filters from the filter name [h, g] = pfilters(pfilt); if nlevs(end) ~= 0 % Laplacian decomposition [xlo, xhi] = lpdec(x, h, g); % DFB on the bandpass image switch dfilt % Decide the method based on the filter name case {'pkva6', 'pkva8', 'pkva12', 'pkva'} % Use the ladder structure (whihc is much more efficient) xhi_dir = dfbdec_l(xhi, dfilt, nlevs(end)); otherwise % General case xhi_dir = dfbdec(xhi, dfilt, nlevs(end)); 1

end else % Special case: nlevs(end) == 0 % Perform one-level 2-D critically sampled wavelet filter bank [xlo, xLH, xHL, xHH] = wfb2dec(x, h, g); xhi_dir = {xLH, xHL, xHH}; end % Recursive call on the low band ylo = pdfbdec(xlo, pfilt, dfilt, nlevs(1:end-1)); % Add bandpass directional subbands to the final output y = {ylo{:}, xhi_dir}; end

pfilters.m function [h, g] = pfilters(fname) % PFILTERS Generate filters for the Laplacian pyramid % % [h, g] = pfilters(fname) % % Input: % fname: Name of the filters, including the famous '9-7' filters % and all other available from WFILTERS in Wavelet toolbox % % Output: % h, g: 1D filters (lowpass for analysis and synthesis, respectively) % for seperable pyramid switch fname case {'9-7', '9/7'} h = [.037828455506995 -.023849465019380 -.11062440441842 ... .37740285561265]; h = [h, .85269867900940, fliplr(h)]; g = [-.064538882628938 -.040689417609558 .41809227322221]; g = [g, .78848561640566, fliplr(g)]; case {'5-3', '5/3'} h = [-1, 2, 6, 2, -1] / (4 * sqrt(2)); g = [1, 2, 1] / (2 * sqrt(2)); case {'Burt'} h = [0.6, 0.25, -0.05]; h = sqrt(2) * [h(end:-1:2), h]; g = [17/28, 73/280, -3/56, -3/280]; g = sqrt(2) * [g(end:-1:2), g]; case {'pkva'} % filters from the ladder structure % Allpass filter for the ladder structure network beta = ldfilter(fname);

lf = length(beta); n = lf / 2; if n ~= floor(n) error('The input allpass filter must be even length'); end % beta(z^2) beta2 = zeros(1, 2*lf-1); beta2(1:2:end) = beta; % H(z) h = beta2; h(2*n) = h(2*n) + 1; h = h / 2; % G(z) g = -conv(beta2, h); g(4*n-1) = g(4*n-1) + 1; g(2:2:end) = -g(2:2:end); % Normalize h = h * sqrt(2); g = g * sqrt(2); otherwise [h, g] = wfilters(fname, 'l'); End ldfilter.m function f = ldfilter(fname) % LDFILTER Generate filter for the ladder structure network % % f = ldfilter(fname) % % Input: % fname: Available 'fname' are: % 'pkvaN': length N filter from Phoong, Kim, Vaidyanathan and Ansari switch fname case {'pkva12', 'pkva'} v = [0.6300 -0.1930 0.0972 -0.0526 0.0272 -0.0144]; case {'pkva8'} v = [0.6302 -0.1924 0.0930 -0.0403]; case {'pkva6'} v = [0.6261 -0.1794 0.0688]; otherwise error('Unrecognized ladder structure filter name'); end % Symmetric impulse response f = [v(end:-1:1), v]; 3

wfilters.m function varargout = wfilters(wname,o) %WFILTERS Wavelet filters. % [LO_D,HI_D,LO_R,HI_R] = WFILTERS('wname') computes four % filters associated with the orthogonal or biorthogonal % wavelet named in the string 'wname'. % The four output filters are: % LO_D, the decomposition low-pass filter % HI_D, the decomposition high-pass filter % LO_R, the reconstruction low-pass filter % HI_R, the reconstruction high-pass filter % Available wavelet names 'wname' are: % Daubechies: 'db1' or 'haar', 'db2', ... ,'db45' % Coiflets : 'coif1', ... , 'coif5' % Symlets : 'sym2' , ... , 'sym8', ... ,'sym45' % Discrete Meyer wavelet: 'dmey' % Biorthogonal: % 'bior1.1', 'bior1.3' , 'bior1.5' % 'bior2.2', 'bior2.4' , 'bior2.6', 'bior2.8' % 'bior3.1', 'bior3.3' , 'bior3.5', 'bior3.7' % 'bior3.9', 'bior4.4' , 'bior5.5', 'bior6.8'. % Reverse Biorthogonal: % 'rbio1.1', 'rbio1.3' , 'rbio1.5' % 'rbio2.2', 'rbio2.4' , 'rbio2.6', 'rbio2.8' % 'rbio3.1', 'rbio3.3' , 'rbio3.5', 'rbio3.7' % 'rbio3.9', 'rbio4.4' , 'rbio5.5', 'rbio6.8'. % % [F1,F2] = WFILTERS('wname','type') returns the following % filters: % LO_D and HI_D if 'type' = 'd' (Decomposition filters) % LO_R and HI_R if 'type' = 'r' (Reconstruction filters) % LO_D and LO_R if 'type' = 'l' (Low-pass filters) % HI_D and HI_R if 'type' = 'h' (High-pass filters) % % See also BIORFILT, ORTHFILT, WAVEINFO. % M. Misiti, Y. Misiti, G. Oppenheim, J.M. Poggi 12-Mar-96. % Last Revision: 22-May-2003. % Copyright 1995-2004 The MathWorks, Inc. % $Revision: 1.12.4.2 $ % Check arguments. nbIn = nargin; if nbIn < 1 error('Not enough input arguments.'); end nbOut = nargout; if ~any([0 1 2 4 8]==nbOut) error('Invalid number of output arguments.'); end if errargt(mfilename,wname,'str') , error('*'), end wname = deblankl(wname); [wtype,fname] = wavemngr('fields',wname,'type','file'); mat_f = findstr('.mat',fname); 4

if mat_f try load(fname,'-mat'); catch msg = sprintf('Invalid wavelet file : %s', fname); errargt(mfilename,msg,'msg'); error(msg); end end if wtype==1 % orth. wavelet if ~isempty(mat_f) F = eval(wname); else F = feval(fname,wname); end [Lo_D,Hi_D,Lo_R,Hi_R] = orthfilt(F); elseif wtype==2 % biorth. wavelet if isempty(mat_f) [Rf,Df] = feval(fname,wname); else if exist('Rf')~=1 | exist('Df')~=1 msg = sprintf('invalid biorthogonal wavelet file : %s', fname); errargt(mfilename,msg,'msg'); error('*'); end end [Lo_D,Hi_D1,Lo_R1,Hi_R,Lo_D2,Hi_D,Lo_R,Hi_R2] = biorfilt(Df,Rf,1); if (nbOut>4) && (nbIn<2) varargout(5:8) = {Lo_D2,Hi_D1,Lo_R1,Hi_R2}; end else msg = sprintf('The wavelet %s is not valid!',wname); errargt(mfilename,msg,'msg'); error('*'); return; end if nbIn==1 varargout(1:4) = {Lo_D,Hi_D,Lo_R,Hi_R}; else o = lower(o(1)); switch o case 'd' , varargout = {Lo_D,Hi_D}; case 'r' , varargout = {Lo_R,Hi_R}; case 'l' , varargout = {Lo_D,Lo_R}; case 'h' , varargout = {Hi_D,Hi_R}; otherwise errargt(mfilename,'invalid argument value','msg'); error('*'); end end

lpdec.m function [c, d] = lpdec(x, h, g) % LPDEC Laplacian Pyramid Decomposition % % [c, d] = lpdec(x, h, g) % % Input: % x: input image % h, g: two lowpass filters for the Laplacian pyramid % % Output: % c: coarse image at half size % d: detail image at full size % % See also: LPREC, PDFBDEC % Lowpass filter and downsample xlo = sefilter2(x, h, h, 'per'); c = xlo(1:2:end, 1:2:end); % Compute the residual (bandpass) image by upsample, filter, and subtract % Even size filter needs to be adjusted to obtain perfect reconstruction adjust = mod(length(g) + 1, 2); xlo = zeros(size(x)); xlo(1:2:end, 1:2:end) = c; d = x - sefilter2(xlo, g, g, 'per', adjust * [1, 1]); sefilter2.m function y = sefilter2(x, f1, f2, extmod, shift) % SEFILTER2 2D seperable filtering with extension handling % % y = sefilter2(x, f1, f2, [extmod], [shift]) % % Input: % x: input image % f1, f2: 1-D filters in each dimension that make up a 2D seperable filter % extmod: [optional] extension mode (default is 'per') % shift: [optional] specify the window over which the % convolution occurs. By default shift = [0; 0]. % % Output: % y: filtered image of the same size as the input image: % Y(z1,z2) = X(z1,z2)*F1(z1)*F2(z2)*z1^shift(1)*z2^shift(2) % % Note: % The origin of the filter f is assumed to be floor(size(f)/2) + 1. % Amount of shift should be no more than floor((size(f)-1)/2). % The output image has the same size with the input image. % % See also: EXTEND2, EFILTER2 if ~exist('extmod', 'var') extmod = 'per'; end 6

if ~exist('shift', 'var') shift = [0; 0]; end % Make sure filter in a row vector f1 = f1(:)'; f2 = f2(:)'; % Periodized extension lf1 = (length(f1) - 1) / 2; lf2 = (length(f2) - 1) / 2; y = extend2(x, floor(lf1) + shift(1), ceil(lf1) - shift(1), ... floor(lf2) + shift(2), ceil(lf2) - shift(2), extmod); % Seperable filter y = conv2(f1, f2, y, 'valid'); dfbdec_l.m function y = dfbdec_l(x, f, n) % DFBDEC_L Directional Filterbank Decomposition using Ladder Structure % % y = dfbdec_l(x, f, n) % % Input: % x: input image % f: filter in the ladder network structure, % can be a string naming a standard filter (see LDFILTER) % n: number of decomposition tree levels % % Output: % y: subband images in a cell array (of size 2^n x 1) if (n ~= round(n)) | (n < 0) error('Number of decomposition levels must be a non-negative integer'); end if n == 0 % No decomposition, simply copy input to output y{1} = x; return; end % Ladder filter if isstr(f) f = ldfilter(f); end % Tree-structured filter banks if n == 1 % Simplest case, one level [y{1}, y{2}] = fbdec_l(x, f, 'q', '1r', 'qper_col'); else 7

% For the cases that n >= 2 % First level [x0, x1] = fbdec_l(x, f, 'q', '1r', 'qper_col'); % Second level y = cell(1, 4); [y{2}, y{1}] = fbdec_l(x0, f, 'q', '2c', 'per'); [y{4}, y{3}] = fbdec_l(x1, f, 'q', '2c', 'per'); % Now expand the rest of the tree for l = 3:n % Allocate space for the new subband outputs y_old = y; y = cell(1, 2^l); % The first half channels use R1 and R2 for k = 1:2^(l-2) i = mod(k-1, 2) + 1; [y{2*k}, y{2*k-1}] = fbdec_l(y_old{k}, f, 'p', i, 'per'); end % The second half channels use R3 and R4 for k = 2^(l-2)+1:2^(l-1) i = mod(k-1, 2) + 3; [y{2*k}, y{2*k-1}] = fbdec_l(y_old{k}, f, 'p', i, 'per'); end end end % Backsampling y = backsamp(y); % Flip the order of the second half channels y(2^(n-1)+1:end) = fliplr(y(2^(n-1)+1:end));

fbdec_l.m function [y0, y1] = fbdec_l(x, f, type1, type2, extmod) % FBDEC_L Two-channel 2D Filterbank Decomposition using Ladder Structure % % [y0, y1] = fbdec_l(x, f, type1, type2, [extmod]) % % Input: % x: input image % f: filter in the ladder network structure % type1: 'q' or 'p' for selecting quincunx or parallelogram % downsampling matrix % type2: second parameter for selecting the filterbank type % If type1 == 'q' then type2 is one of {'1r', '1c', '2r', '2c'} % ({2, 3, 1, 4} can also be used as equivalent) % If type1 == 'p' then type2 is one of {1, 2, 3, 4} % Those are specified in QPDEC and PPDEC % extmod: [optional] extension mode (default is 'per') % This refers to polyphase components. % 8

% Output: % y0, y1: two result subband images % % Note: This is also called the lifting scheme % % See also: FBDEC, FBREC_L % Modulate f f(1:2:end) = -f(1:2:end); if min(size(x)) == 1 error('Input is a vector, unpredicted output!'); end if ~exist('extmod', 'var') extmod = 'per'; end % Polyphase decomposition of the input image switch lower(type1(1)) case 'q' % Quincunx polyphase decomposition [p0, p1] = qpdec(x, type2); case 'p' % Parallelogram polyphase decomposition [p0, p1] = ppdec(x, type2); otherwise error('Invalid argument type1'); end % Ladder network structure y0 = (1 / sqrt(2)) * (p0 - sefilter2(p1, f, f, extmod, [1, 1])); y1 = (-sqrt(2) * p1) - sefilter2(y0, f, f, extmod); qpdec.m function [p0, p1] = qpdec(x, type) % QPDEC Quincunx Polyphase Decomposition % % [p0, p1] = qpdec(x, [type]) % % Input: % x: input image % type: [optional] one of {'1r', '1c', '2r', '2c'} default is '1r' % '1' and '2' for selecting the quincunx matrices: % Q1 = [1, -1; 1, 1] or Q2 = [1, 1; -1, 1] % 'r' and 'c' for suppresing row or column % % Output: % p0, p1: two qunincunx polyphase components of the image if ~exist('type', 'var') type = '1r'; end

% Quincunx downsampling using the Smith decomposition: % Q1 = R2 * D1 * R3 % = R3 * D2 * R2 % and, % Q2 = R1 * D1 * R4 % = R4 * D2 * R1 % % where D1 = [2, 0; 0, 1] and D2 = [1, 0; 0, 2]. % See RESAMP for the definition of the resampling matrices R's switch type case {'1r'} % Q1 = R2 * D1 * R3 y = resamp(x, 2); p0 = resamp(y(1:2:end, :), 3); % inv(R2) * [0; 1] = [1; 1] p1 = resamp(y(2:2:end, [2:end, 1]), 3); case {'1c'} % Q1 = R3 * D2 * R2 y = resamp(x, 3); p0 = resamp(y(:, 1:2:end), 2); % inv(R3) * [0; 1] = [0; 1] p1 = resamp(y(:, 2:2:end), 2); case {'2r'} % Q2 = R1 * D1 * R4 y = resamp(x, 1); p0 = resamp(y(1:2:end, :), 4); % inv(R1) * [1; 0] = [1; 0] p1 = resamp(y(2:2:end, :), 4); case {'2c'} % Q2 = R4 * D2 * R1 y = resamp(x, 4); p0 = resamp(y(:, 1:2:end), 1); % inv(R4) * [1; 0] = [1; 1] p1 = resamp(y([2:end, 1], 2:2:end), 1); otherwise error('Invalid argument type'); end resamp.m function y = resamp(x, type, shift, extmod) % RESAMP Resampling in 2D filterbank % % y = resamp(x, type, [shift, extmod]) % % Input: % x: input image 10

% type: one of {1, 2, 3, 4} (see note) % shift: [optional] amount of shift (default is 1) % extmod: [optional] extension mode (default is 'per'). % Other options are: % % Output: % y: resampled image. % % Note: % The resampling matrices are: % R1 = [1, 1; 0, 1]; % R2 = [1, -1; 0, 1]; % R3 = [1, 0; 1, 1]; % R4 = [1, 0; -1, 1]; % % For type 1 and type 2, the input image is extended (for example % periodically) along the vertical direction; % while for type 3 and type 4 the image is extended along the % horizontal direction. % % Calling resamp(x, type, n) which n is positive integer is equivalent % to repeatly calling resamp(x, type) n times. % % Input shift can be negative so that resamp(x, 1, -1) is the same % with resamp(x, 2, 1) if ~exist('shift', 'var') shift = 1; end if ~exist('extmod', 'var') extmod = 'per'; end switch type case {1, 2} y = resampc(x, type, shift, extmod); case {3, 4} y = resampc(x.', type - 2, shift, extmod).'; otherwise error('The second input (type) must be one of {1, 2, 3, 4}'); end ppdec.m function [p0, p1] = ppdec(x, type) % PPDEC Parallelogram Polyphase Decomposition % % [p0, p1] = ppdec(x, type) % % Input: % x: input image % type: one of {1, 2, 3, 4} for selecting sampling matrices: % P1 = [2, 0; 1, 1] % P2 = [2, 0; -1, 1] 11

% P3 = [1, 1; 0, 2] % P4 = [1, -1; 0, 2] % % Output: % p0, p1: two parallelogram polyphase components of the image % % Note: % These sampling matrices appear in the directional filterbank: % P1 = R1 * Q1 % P2 = R2 * Q2 % P3 = R3 * Q2 % P4 = R4 * Q1 % where R's are resampling matrices and Q's are quincunx matrices % % See also: QPDEC % Parallelogram polyphase decomposition by simplifying sampling matrices % using the Smith decomposition of the quincunx matrices switch type case 1 % P1 = R1 * Q1 = D1 * R3 p0 = resamp(x(1:2:end, :), 3); % R1 * [0; 1] = [1; 1] p1 = resamp(x(2:2:end, [2:end, 1]), 3); case 2 % P2 = R2 * Q2 = D1 * R4 p0 = resamp(x(1:2:end, :), 4); % R2 * [1; 0] = [1; 0] p1 = resamp(x(2:2:end, :), 4); case 3 % P3 = R3 * Q2 = D2 * R1 p0 = resamp(x(:, 1:2:end), 1); % R3 * [1; 0] = [1; 1] p1 = resamp(x([2:end, 1], 2:2:end), 1); case 4 % P4 = R4 * Q1 = D2 * R2 p0 = resamp(x(:, 1:2:end), 2); % R4 * [0; 1] = [0; 1] p1 = resamp(x(:, 2:2:end), 2); otherwise error('Invalid argument type'); end

backsamp.m function y = backsamp(y) % BACKSAMP Backsampling the subband images of the directional filter bank % % y = backsamp(y) % 12

% Input and output are cell vector of dyadic length % % This function is called at the end of the DFBDEC to obtain subband images % with overall sampling as diagonal matrices % % See also: DFBDEC % Number of decomposition tree levels n = log2(length(y)); if (n ~= round(n)) | (n < 1) error('Input must be a cell vector of dyadic length'); end if n == 1 % One level, the decomposition filterbank shoud be Q1r % Undo the last resampling (Q1r = R2 * D1 * R3) for k = 1:2 y{k} = resamp(y{k}, 4); y{k}(:, 1:2:end) = resamp(y{k}(:, 1:2:end), 1); y{k}(:, 2:2:end) = resamp(y{k}(:, 2:2:end), 1); end elseif n > 2 N = 2^(n-1); for k = 1:2^(n-2) shift = 2*k - (2^(n-2) + 1); % The first half channels y{2*k-1} = resamp(y{2*k-1}, 3, shift); y{2*k} = resamp(y{2*k}, 3, shift); % The second half channels y{2*k-1+N} = resamp(y{2*k-1+N}, 1, shift); y{2*k+N} = resamp(y{2*k+N}, 1, shift); end end

dfbdec.m function y = dfbdec(x, fname, n) % DFBDEC Directional Filterbank Decomposition % % y = dfbdec(x, fname, n) % % Input: % x: input image % fname: filter name to be called by DFILTERS % n: number of decomposition tree levels % % Output: % y: subband images in a cell vector of length 2^n % % Note: % This is the general version that works with any FIR filters 13

% % See also: DFBREC, FBDEC, DFILTERS if (n ~= round(n)) | (n < 0) error('Number of decomposition levels must be a non-negative integer'); end if n == 0 % No decomposition, simply copy input to output y{1} = x; return; end % Get the diamond-shaped filters [h0, h1] = dfilters(fname, 'd'); % Fan filters for the first two levels % k0: filters the first dimension (row) % k1: filters the second dimension (column) k0 = modulate2(h0, 'c'); k1 = modulate2(h1, 'c'); % Tree-structured filter banks if n == 1 % Simplest case, one level [y{1}, y{2}] = fbdec(x, k0, k1, 'q', '1r', 'per'); else % For the cases that n >= 2 % First level [x0, x1] = fbdec(x, k0, k1, 'q', '1r', 'per'); % Second level y = cell(1, 4); [y{1}, y{2}] = fbdec(x0, k0, k1, 'q', '2c', 'qper_col'); [y{3}, y{4}] = fbdec(x1, k0, k1, 'q', '2c', 'qper_col'); % Fan filters from diamond filters [f0, f1] = ffilters(h0, h1); % Now expand the rest of the tree for l = 3:n % Allocate space for the new subband outputs y_old = y; y = cell(1, 2^l); % The first half channels use R1 and R2 for k = 1:2^(l-2) i = mod(k-1, 2) + 1; [y{2*k-1}, y{2*k}] = fbdec(y_old{k}, f0{i}, f1{i}, 'pq', i, 'per'); end % The second half channels use R3 and R4 for k = 2^(l-2)+1:2^(l-1) i = mod(k-1, 2) + 3; [y{2*k-1}, y{2*k}] = fbdec(y_old{k}, f0{i}, f1{i}, 'pq', i, 'per'); 14

end end end % Back sampling (so that the overal sampling is separable) % to enhance visualization y = backsamp(y); % Flip the order of the second half channels y(2^(n-1)+1:end) = fliplr(y(2^(n-1)+1:end)); ld2quin.m function [h0, h1] = ld2quin(beta) % LD2QUIN Quincunx filters from the ladder network structure % % Construct the quincunx filters from an allpass filter (beta) using the % ladder network structure % % Ref: Phong et al., IEEE Trans. on SP, March 1995 if all(size(beta) ~= 1) error('The input must be an 1-D fitler'); end % Make sure beta is a row vector beta = beta(:)'; lf = length(beta); n = lf / 2; if n ~= floor(n) error('The input allpass filter must be even length'); end % beta(z1) * beta(z2) sp = beta' * beta; % beta(z1*z2^{-1}) * beta(z1*z2) % Obtained by quincunx upsampling type 1 (with zero padded) h = qupz(sp, 1); % Lowpass quincunx filter h0 = h; h0(2*n, 2*n) = h0(2*n, 2*n) + 1; h0 = h0 / 2; % Highpass quincunx filter h1 = -conv2(h, h0); h1(4*n-1, 4*n-1) = h1(4*n-1, 4*n-1) + 1; qupz.m function y = qupz(x, type) % QUPZ Quincunx Upsampling (with zero-pad and matrix extending) % % y = qup(x, [type]) % 15

% Input: % x: input image % type: [optional] 1 or 2 for selecting the quincunx matrices: % Q1 = [1, -1; 1, 1] or Q2 = [1, 1; -1, 1] % Output: % y: qunincunx upsampled image % % This resampling operation does NOT involve periodicity, thus it % zero-pad and extend the matrix if ~exist('type', 'var') type = '1'; end % Quincunx downsampling using the Smith decomposition: % Q1 = R2 * [2, 0; 0, 1] * R3 % and, % Q2 = R1 * [2, 0; 0, 1] * R4 % % See RESAMP for the definition of those resampling matrices % % Note that R1 * R2 = R3 * R4 = I so for example, % upsample by R1 is the same with down sample by R2. % Also the order of upsampling operations is in the reserved order % with the one of matrix multiplication. switch type case 1 x1 = resampz(x, 4); [m, n] = size(x1); x2 = zeros(2*m-1, n); x2(1:2:end, :) = x1; y = resampz(x2, 1); case 2 x1 = resampz(x, 3); [m, n] = size(x1); x2 = zeros(2*m-1, n); x2(1:2:end, :) = x1; y = resampz(x2, 2); otherwise error('Invalid argument type'); end

16

Você também pode gostar