Search code examples
image-processingwavelet

How to Display a decomposition wavelet in 3 level?


I want to display a decomposition wavelet in 3 level. so can any help me in give a Matlab function to display it?

[cA cH cV cD]=dwt2(a,waveletname);
out=[cA cH;cV cD];
figure;imshow(out,[]);

That only works for the first level. actually, I want to representation square mode such wavemenu in Matlab. example of the view decomposition I am fairly new to it. thanx.


Solution

  • You should use the function wavedec2(Image,numberOfLevels,'wname') with the amount of levels that you need. For more information look at http://www.mathworks.com/help/wavelet/ref/wavedec2.html

    Code for example with db1

    clear all
    im = imread('cameraman.tif');
    [c,s] = wavedec2(im,3,'db1');
    A1 = appcoef2(c,s,'db1',1);
    [H1,V1,D1] = detcoef2('all',c,s,1);
    A2 = appcoef2(c,s,'db1',2);
    [H2,V2,D2] = detcoef2('all',c,s,2);
    A3 = appcoef2(c,s,'db1',3);
    [H3,V3,D3] = detcoef2('all',c,s,3); 
    
    V1img = wcodemat(V1,255,'mat',1);
    H1img = wcodemat(H1,255,'mat',1);
    D1img = wcodemat(D1,255,'mat',1);
    A1img = wcodemat(A1,255,'mat',1);
    
    V2img = wcodemat(V2,255,'mat',1);
    H2img = wcodemat(H2,255,'mat',1);
    D2img = wcodemat(D2,255,'mat',1);
    A2img = wcodemat(A2,255,'mat',1);
    
    V3img = wcodemat(V3,255,'mat',1);
    H3img = wcodemat(H3,255,'mat',1);
    D3img = wcodemat(D3,255,'mat',1);
    A3img = wcodemat(A3,255,'mat',1);
    
    mat3 = [A3img,V3img;H3img,D3img];
    mat2 = [mat3,V2img;H2img,D2img];
    mat1 = [mat2,V1img;H1img,D1img];
    
    imshow(uint8(mat1))
    

    The final result

    enter image description here