1

I am a novice to wavelet transform. I am trying to use wavelet transform to decompose the images and then modify the co-efficients,such that only the first 15 co-efficients are retained in the final image,say for image compression( never mind the quality for now).

I need help to proceed further on this. My code so far looks like this -

% gray_image is my inout image%
[C,S] = wavedec2(gray_image,2,'haar');
A1 = appcoef2(C,S,'haar',1);
A2 = appcoef2(C,S,'haar',2);
[H1,V1,D1] = detcoef2('all',C,S,1);
[H2,V2,D2] = detcoef2('all',C,S,2);

I have the approx image for level 1 and 2, and the detail components of levels 1 and 2. If i need to retain the first 15 co-efficients of both approx and detail and then recombine them using waverec2(), how do I go about it?

Any help is appreciated.

Thanks in advance.

ashkan
  • 476
  • 6
  • 14
Ashwini
  • 73
  • 6
  • The "first 15" is ambiguous. The Wavelet transform for 2D images has two degrees of freedom - horizontal and vertical. Which 15 coefficients do you want to retain? a 5 x 3 or 3 x 5 grid in the top left corner? The centre? Be more specific. – rayryeng Jun 30 '16 at 15:09
  • rayryeng -Thank you for the response. I wish to retain the top 15% of the approx and detail image sets. – Ashwini Jun 30 '16 at 15:33
  • What is your definition of "the top"? The largest coefficients? – rayryeng Jun 30 '16 at 15:37
  • Yes. I am sorry for being so ambiguous. Yes, i want to extract the largest 15% of coefficients. – Ashwini Jun 30 '16 at 21:59

1 Answers1

0

First of all, you should know that when you perform a two level decomposition, your coefficients are: {A2, H2, V2, D2, H1, V1, D1}. Therefore, it is not reasonable to modify "A1". This is because "A1" is the result of combining A2, H2, V2, and D2.

Now, assuming that you want to modify one of those mentioned coefficients, you need to be familiar with the usage of wavedec2. This function puts all coefficients one after the other in one row.

Here is my post about working with MATLAB's wavelet toolbox. "Example 5" demonstrates how wavedec2 stores coefficients. Once, you know the storage mechanism, it will be very simple to modify coefficients and use waverec2 for recovery.

Note that there is also a more intuitive and simpler way of extracting coefficients, manipulating them, and preforming recovery: You can use (dwt2,idwt2) functions instead of (wavedec2,waverec2). See here for more information.

ashkan
  • 476
  • 6
  • 14