I'm trying to write my own version of the Discrete Wavelet Transform using the bior4.4 filters.
I think my implementation is not properly working yet, because whenever I input a signal and a number of iterations to calculate, my result is always an array of 10 long.
Shouldn't the approximation coefficient (Ca) be a single number in the end?
This is my version:
function R=myDWT(sig, count)
[Lo_D, Hi_D] = wfilter_bior44();
input = sig;
while(count ~= 0) % While count not equal to 0
% Pass through filters by using convolution
Ca = conv(input, Lo_D);
Cd = conv(input, Hi_D);
% Downsample by 2
Ca = downsample(Ca, 2);
Cd = downsample(Cd, 2);
% TODO: Save Ca and Cd somewhere
count = count - 1;
input = Ca;
end
R = input;
end
The problem lies with the convolution. Standard Matlab
convfunction will usefull convolution. So the length will always be dependent on the longest of the 2 arguments. This can be resolved by using thesameparameter for convolution.So the correct code is: