From: anant on
Hi, I am doing an image compression project where in I need to find the wavelet coefficients of an image in the beginning. I need not only the wavelet decomposition but also the coefficient values after the decomposition. I searched the MATLAB help files found that by applying wavedec2 to an image and then finding the approximate and actual coefficients its possible. But I am not able to follow the procedure. So i would like to know if there is any easier method to this approach.
From: Rune Allnor on
On 25 Jan, 06:47, "anant " <anan...(a)gmail.com> wrote:
> Hi, I am doing an image compression project where in I need to find the wavelet coefficients of an image in the beginning. I need not only the wavelet decomposition but also the coefficient values after the decomposition. I searched the MATLAB help files found that by applying wavedec2 to an image and then finding the approximate and actual coefficients its possible. But I am not able to follow the procedure. So i would like to know if there is any easier method to this approach.

Sure there is. Buy a piece of software that does the
compression for you. A lot easier for you, but your
boss or supervisor might not be too amused. Depending
on the context of your project, that kind of approach
might have a severe impact on your paycheck or grades.

Nah, read up on the basics. Find a textbook and learn
what wavelets are all about. Then look up the docs of
whatever fuction you tried to use, and find out what
you did wrong.

Rune
From: Wayne King on
"anant " <anantvu(a)gmail.com> wrote in message <hjjb8n$q80$1(a)fred.mathworks.com>...
> Hi, I am doing an image compression project where in I need to find the wavelet coefficients of an image in the beginning. I need not only the wavelet decomposition but also the coefficient values after the decomposition. I searched the MATLAB help files found that by applying wavedec2 to an image and then finding the approximate and actual coefficients its possible. But I am not able to follow the procedure. So i would like to know if there is any easier method to this approach.

Anant, I think you will need to clarify what you mean by "But I am not able to follow the procedure." Do you mean that you are not able to follow the procedure because you do not have the Wavelet Toolbox, or that you are not able to understand how the function works from the help documentation.

Wayne
From: anant on
HI Wayne, what i mean is that I am not able to understand the function which is given in help files. So it would be nice if i could write a simpler function by myself for this purpose.
From: Wayne King on
"anant " <anantvu(a)gmail.com> wrote in message <hjkqr8$md9$1(a)fred.mathworks.com>...
> HI Wayne, what i mean is that I am not able to understand the function which is given in help files. So it would be nice if i could write a simpler function by myself for this purpose.

Hi Anant, just to give you an illustration for a simple wavelet filter, the Haar, let:

x = [ 1 4 1 1; 1 1 1 1; 1 1 1 1; 1 1 1 1];
% First compute level-1 2D-DWT using the Haar in Matlab
[cA,cH,cV,cD] = dwt2(x,'haar');
% Next let
H = [1/sqrt(2) 1/sqrt(2) 0 0; 0 0 1/sqrt(2) 1/sqrt(2)];
G = [1/sqrt(2) -1/sqrt(2) 0 0; 0 0 1/sqrt(2) -1/sqrt(2)];
% Now look at
ApproxCoeffs = H*x*H';
% compare the above to cA. Next compute
VerticalDetails = H*x*G';
% compare the above to cV. Next compute
HorizDetails = G*x*H';
%compare the above to cH. Finally, compute
DiagDetails = G*x*G';


If you divide the matrix x into 2x2 block matrices

C{1}=[1 4; 1 1]; C{2}=[1 1; 1 1]; C{3}=[1 1; 1 1]; C{4}= [1 1; 1 1];

You'll see that ApproxCoeffs is 2x2 matrix where the (1,1) element is proportional to the average of all the elements in C{1} and so on for the other blocks.

Then look at VerticalDetails. The (1,1) element is proportional to the difference between the two columns of C{1} and so on for the other blocks.

HorizDetails is the same as above except the differences are between the rows. DiagDetails-- the same as above except the differences are between elements on the diagonals.

Hope that helps,
Wayne