Wednesday, 18 December 2013

How to apply DWT (Discrete Wavelet Transform) to Image?


Discrete time wavelet transforms (DWT), which produces multi-scale image decomposition. By employing filtering and sub-sampling, a result in the form of the decomposition image (for classical dyadic approach) is produced, very effectively revealing data redundancy in several scales. A coding principle is then applied in order to compress the data. It superior to Fourier and DCT. It has Discrete Wavelet Transform (DWT) provides a multi resolution image representation and has become one of the most important tools in image analysis and coding over the last two decades.
Image compression algorithms based on DWT provide high coding efficiency for natural (smooth) images. As dyadic DWT does not adapt to the various space-frequency properties of images, the energy compaction it achieves is generally not optimal. It has been widely applied and developed in image processing and compression.

There exist two ways how to implement the computation of the discrete-time wavelet transform. The first approach uses convolution (filtering) with appropriate boundary handling, the second is a fast lifting  approach, a refined  system  of  very  short  filters  which  are  applied  in a way that produces the same result as the first approach, introducing significant computational and memory savings .Lifting  scheme  is  derived  from  a  polyphase  matrix  representation  of  the  wavelet  filters,  a representation  that  is  distinguishing  between  even  and  odd  samples.  Using  the  algorithm  of  filter factoring,  we  split  the  original  filter  into  a  series  of  shorter  filters  (typically  Laurent  polynomials  of first  degree).  Those filters are designed as lifting steps; each step one group of coefficients are lifted(altered) with the help of the other one  (classical dyadic transform always leads to two groups of coefficients, low-pass and high-pass).  

Since images are two-dimensional signals, we have to extend the scheme to 2D space by applying the transform row and column-wise,respectively(taking separability of the transform  into account).

Fig. 3 level image decomposition
As a consequence four subbands arise from one level of the transform    one low-pass subband containing the coarse approximation of the source image called LL  subband, and three high-pass subbands that exploit image details across different directions – HL for horizontally for vertical and HH for diagonal details. IN the next level of the transform, we use the LL band for further decomposition and replace it with respective four subbands. This forms the decomposition image.



Advantages:
1. DWT has excellent energy compaction capabilities and hence the coding technique must be well-designed to achieve significant image compression. 

 2. At low bit rate, DWT avoid the blocking artifacts of DCT.
3. It presents better coding performance.

Fig. 2D Analysis Filter Bank


Fig. 2D Synthesis Filter Bank
 
Syntax:
[cA,cH,cV,cD] = dwt2(X,'wname')
computes the approximation coefficients matrix cA and details coefficients matrices cH, cV, and cD (horizontal, vertical, and diagonal, respectively), obtained by wavelet decomposition of the input matrix X. The 'wname' string contains the wavelet name.

[cA,cH,cV,cD] = dwt2(X,Lo_D,Hi_D)
 computes the two-dimensional wavelet decomposition as above, based on wavelet decomposition filters that you specify.
Lo_D is the decomposition low-pass filter.
Hi_D is the decomposition high-pass filter.
Lo_D and Hi_D must be the same length.

Program & Output:
clc
[file path]=uigetfile('*.*');
a=imread(file);
figure;imshow(a)
[ca ch cv cd]=dwt2(a,'haar');
figure;imshow([(ca/512),ch;cv,cd])
figure;
subplot(2,2,1);imshow(ca/512);title('Approximation')
subplot(2,2,2);imshow(ch);title('Horizontal')
subplot(2,2,3);imshow(cv);title('Vertical')
subplot(2,2,4);imshow(cd);title('Diagonal')
 

Barbara Original Image

Separate Subbands

 Combined Subbands

10 comments:

  1. good one..can you please explain more about feature extraction using DWT??

    ReplyDelete
    Replies
    1. Thanks you very mush sis....i will explain it in next blogpost...

      Delete
  2. Can you please explain more about combined image?

    ReplyDelete
  3. can u send me program of dct and dwt compression to compare PSNR?
    (khushbudarji@rocketmail.com)

    ReplyDelete
  4. i want matlab code for DWT Image Compression

    ReplyDelete
  5. how to apply this code for dwt level-2 and level-3

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. If any one want matlab code for dct and dwt ,
    Mail : shinnychinni24@gmail.com

    ReplyDelete