From: ad ad on

Hi,
I'm looking for a way to build the dwt matrix to compute the dwt transforme.

Is there function already build or documentation to make it?

i hop something like :
(matrix) lena = load('lena');
(matrix) dwt = dwt_builder( size(lena) , wavelet ) % wavelet : 'haar' by example

(matrix) lena_dwt = dwt*lena;
(matrix) lena_f = dwt'*lena;
From: Wayne King on
"ad ad" <matlab.1c(a)0sg.net> wrote in message <hvpv2h$of6$1(a)fred.mathworks.com>...
>
> Hi,
> I'm looking for a way to build the dwt matrix to compute the dwt transforme.
>
> Is there function already build or documentation to make it?
>
> i hop something like :
> (matrix) lena = load('lena');
> (matrix) dwt = dwt_builder( size(lena) , wavelet ) % wavelet : 'haar' by example
>
> (matrix) lena_dwt = dwt*lena;
> (matrix) lena_f = dwt'*lena;

Hi, It looks like you are interested in the 2D wavelet transform. Matlab does not have any routine that simply returns the matrix representation of the DWT, but if you have the Wavelet Toolbox, there are a lot of tools for 1D,2D, and 3D wavelet transforms.

If you need to, you can construct the matrices yourself. I'll show you a simple example for the case where the input is a 4x4 matrix.

x = [ 1 4 1 1; 1 1 1 1; 1 1 1 1; 1 1 1 1]; %image
% First compute level-1 2D-DWT using the Haar in Matlab (requires Wavelet Toolbox)
[cA,cH,cV,cD] = dwt2(x,'haar');
% Construct the matrix representations of the Haar wavelet
% Low pass filter matrix
H = [1/sqrt(2) 1/sqrt(2) 0 0; 0 0 1/sqrt(2) 1/sqrt(2)];
% High pass filter matrix
G = [1/sqrt(2) -1/sqrt(2) 0 0; 0 0 1/sqrt(2) -1/sqrt(2)];
% Level 1 approximation coefficients
ApproxCoeffs = H*x*H';
% compare the above to cA.
% Next compute level 1 vertical details
VerticalDetails = H*x*G';
% compare the above to cV.
% Next compute level 1 horizontal details
HorizDetails = G*x*H';
%compare the above to cH.
% Finally, compute level one diagonal details
DiagDetails = G*x*G';

Obviously, you have to adjust H and G for your image size.

Hope that helps,
Wayne
From: ad ad on
"Wayne King" <wmkingty(a)gmail.com> wrote in message
> Hi, It looks like you are interested in the 2D wavelet transform. Matlab does not have any routine that simply returns the matrix representation of the DWT, but if you have the Wavelet Toolbox, there are a lot of tools for 1D,2D, and 3D wavelet transforms.
>
> If you need to, you can construct the matrices yourself. I'll show you a simple example for the case where the input is a 4x4 matrix.
>
> x = [ 1 4 1 1; 1 1 1 1; 1 1 1 1; 1 1 1 1]; %image
> % First compute level-1 2D-DWT using the Haar in Matlab (requires Wavelet Toolbox)
> [cA,cH,cV,cD] = dwt2(x,'haar');
> % Construct the matrix representations of the Haar wavelet
> % Low pass filter matrix
> H = [1/sqrt(2) 1/sqrt(2) 0 0; 0 0 1/sqrt(2) 1/sqrt(2)];
> % High pass filter matrix
> G = [1/sqrt(2) -1/sqrt(2) 0 0; 0 0 1/sqrt(2) -1/sqrt(2)];
> % Level 1 approximation coefficients
> ApproxCoeffs = H*x*H';
> % compare the above to cA.
> % Next compute level 1 vertical details
> VerticalDetails = H*x*G';
> % compare the above to cV.
> % Next compute level 1 horizontal details
> HorizDetails = G*x*H';
> %compare the above to cH.
> % Finally, compute level one diagonal details
> DiagDetails = G*x*G';
>
> Obviously, you have to adjust H and G for your image size.
>
> Hope that helps,
> Wayne

thanks,
i don't have the wavelet toolbox but i'm working with the wawelab it works almost the same.

i'have already found the 4x4 matrix but how do i generalize it to bigger size?
I guess there is no way to compute the different details(hg,gh and gg) all in one matrix?

I want to apply the dwt to compressed sensing. And if I have just one matrix to do the work it will be easy to adapt the work i have done with the Fourier transform else I don't know how i will adapt my program.