



fwt2.m
Fast 2D wavelet transform.
Usage: w = fwt(x, h0, h1, J, sym);
x - mxn input image (min(m,n) must be divisible by 2^J)
h0 - lowpass decomposition filter
h1 - highpass decomposition filter
h0 and h1 should be zero padded appropriately so that they have the
same length, and this length is even.
J - number of levels in the filter bank.
Right now, it must be chosen so that n*2^(-J) >= length(h0)
sym - How to extend the input.
sym=0: periodization
sym=1: type-I symmetric extension ( [... x(2) x(1) x(2) x(3) ...])
The wavelet filters must have type-I even symmetry
(e.g. daub79)
sym=2: type-II symmetric extension ( [... x(2) x(1) x(1) x(2) x(3) ...])
The lowpass filter must have type-II even symmetry,
The highpass filter must have type-II odd symmetry.
(e.g. daub1018)

0001 % fwt2.m 0002 % 0003 % Fast 2D wavelet transform. 0004 % 0005 % Usage: w = fwt(x, h0, h1, J, sym); 0006 % x - mxn input image (min(m,n) must be divisible by 2^J) 0007 % h0 - lowpass decomposition filter 0008 % h1 - highpass decomposition filter 0009 % h0 and h1 should be zero padded appropriately so that they have the 0010 % same length, and this length is even. 0011 % J - number of levels in the filter bank. 0012 % Right now, it must be chosen so that n*2^(-J) >= length(h0) 0013 % sym - How to extend the input. 0014 % sym=0: periodization 0015 % sym=1: type-I symmetric extension ( [... x(2) x(1) x(2) x(3) ...]) 0016 % The wavelet filters must have type-I even symmetry 0017 % (e.g. daub79) 0018 % sym=2: type-II symmetric extension ( [... x(2) x(1) x(1) x(2) x(3) ...]) 0019 % The lowpass filter must have type-II even symmetry, 0020 % The highpass filter must have type-II odd symmetry. 0021 % (e.g. daub1018) 0022 % 0023 0024 % 2D Example's output and explanation: 0025 % 0026 % The coefficients in w are arranged as follows. 0027 % 0028 % .------------------. 0029 % | | | 0030 % | 0 | 1 | 0031 % | | | 0032 % | L,L | H,L | 0033 % | | | 0034 % -------------------- 0035 % | | | 0036 % | 2 | 3 | 0037 % | | | 0038 % | L,H | H,H | 0039 % | | | 0040 % `------------------' 0041 % 0042 % where 0043 % 0 : Low pass vertically and Low pass horizontally 0044 % (scaling coefficients) 0045 % 1 : Low pass vertically and high pass horizontally 0046 % 2 : High pass vertically and low pass horizontally 0047 % 3 : High pass vertically and high pass horizontally 0048 % 0049 % 0050 % Written by: Justin Romberg 0051 % Created: April 2007 0052 0053 % Modified by: Salman Asif 0054 % December 2011 0055 % Added the ability to work with non-square images. 0056 % The only requirement is that min(ROW,COL) should be dyadic upto the 0057 % chosen scale J