The Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: image compression using haar wavelet transform
Replies: 1   Last Post: Oct 28, 2013 3:08 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Karbala'a Unvi. Science

Posts: 6
Registered: 10/24/13
Re: image compression using haar wavelet transform
Posted: Oct 28, 2013 3:08 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Dear "ARVIND SONI",
I like to ask you the help in doing the (haar) wavelet on a skin detected images and what is going to be the result of the image
I am in need of your answer soon
PLZ
Yours
Ziyad
"ARVIND SONI" <arvindsoni008@gmail.com> wrote in message
<kvgb6a$1td$1@newscl01ah.mathworks.com>...
> i am studying in btech electronics and communication and have undertaken a project to use wavelets to compress images, i searched a lot of codes online in an attempt to understand how to build a software to compress images . one of the code i am interested in is given below and i would like the help of brilliant ppl who visit this forum . i hope some one would help me on this .
>
> %wavelet based compression sub-band coding
> clear all;
> % CLOSE ALL closes all the open figure windows.
> close all;
> X=imread('cameraman.tif');
> X=X(1:256,1:256);
> figure;
> %load woman;
> %subplot(2,1,1);
> imshow(uint8(X));
>
> [a1,a2]=size(X);
> disp('The number of rows in input image are');
> disp(a1);
> disp('The number of coloums in input image are');
> disp(a2);
> figure;
> title('Input image');
> % Perform single-level decomposition
> % of X using haar.
> [cA1,cH1,cV1,cD1] = dwt2(X,'haar');
> % Images coding.
> [C,S] = wavedec2(X,1,'haar');
> A1 = wrcoef2('a',C,S,'haar',1);
> H1 = wrcoef2('h',C,S,'haar',1);
> V1 = wrcoef2('v',C,S,'haar',1);
> D1 = wrcoef2('d',C,S,'haar',1);
> %Display the results of a first level decomposition.
> colormap(gray);
> subplot(2,2,1); image(wcodemat(A1,192));
> title('Approximation A1')
> subplot(2,2,2); image(wcodemat(H1,192));
> title('Horizontal Detail H1')
> subplot(2,2,3); image(wcodemat(V1,192));
> title('Vertical Detail V1')
> subplot(2,2,4); image(wcodemat(D1,192));
> title('Diagonal Detail D1')
> %disp(cod_cA1);
>
> %Multi-level 1-D wavelet reconstruction.
> re_ima1 = idwt2(cA1,cH1,cV1,cD1,'haar');
> re_ima=uint8(re_ima1);
> figure;
> subplot(2,1,1);
> imshow(uint8(X));
> title('Input image');
> subplot(2,1,2);
> imshow(re_ima);
> title('1-level reconstructed image');
> figure;
>
>
> %To perform a level 2 decomposition of the image
> %X using haar
> [C,S] = wavedec2(X,2,'haar');
> % decomposse the image X in Level 2
> %image coding
> A2 = wrcoef2('a',C,S,'haar',2);
> A1 = wrcoef2('a',C,S,'haar',1);
> H1 = wrcoef2('h',C,S,'haar',1);
> V1 = wrcoef2('v',C,S,'haar',1);
> D1 = wrcoef2('d',C,S,'haar',1);
> H2 = wrcoef2('h',C,S,'haar',2);
> V2 = wrcoef2('v',C,S,'haar',2);
> D2 = wrcoef2('d',C,S,'haar',2);
> colormap(gray);
> subplot(2,4,1);image(wcodemat(A1,192));
> title('Approximation A1')
> subplot(2,4,2);image(wcodemat(H1,192));
> title('Horizontal Detail H1')
> subplot(2,4,3);image(wcodemat(V1,192));
> title('Vertical Detail V1')
> subplot(2,4,4);image(wcodemat(D1,192));
> title('Diagonal Detail D1')
> subplot(2,4,5);image(wcodemat(A2,192));
> title('Approximation A2')
> subplot(2,4,6);image(wcodemat(H2,192));
> title('Horizontal Detail H2')
> subplot(2,4,7);image(wcodemat(V2,192));
> title('Vertical Detail V2')
> subplot(2,4,8);image(wcodemat(D2,192));
> title('Diagonal Detail D2')
> dec2d = [A2,A1,H1,V1,D1,H2,V2,D2];
>
> %Multi-level 2-D wavelet reconstruction.
> re_ima1 = waverec2(C,S,'haar');
> re_ima=uint8(re_ima1);
> figure;
> subplot(2,1,1);
> imshow(uint8(X));
> title('Input image');
> subplot(2,1,2);
> imshow(re_ima);
> title('2-level reconstructed image');
> %figure;
> %y=imsubtract(uint8(X),re_ima);
> %imshow(y);title('error image');
>
>
> % Using some plotting commands,
> % the following figure is generated.
> n=input('enter the decomposition level')
> X=imread('cameraman.tif');
> X=X(1:256,1:256);
> X=double(X)-128;
> %To compute four filters associated
> [Lo_D,Hi_D,Lo_R,Hi_R] = wfilters('haar');
> %Multilevel 2-D wavelet decomposition.
> [c,s]=wavedec2(uint8(X),n,Lo_D,Hi_D);
> disp('Decomposition vector of size 1*524288 is stored in c');
> disp('Coressponding book keeeping matrix');
> disp(s);
> [thr,nkeep] = wdcbm2(uint8(dec2d),1.5,prod(s(1,:)));
> %Default values for de-noising or compression.
> [THR,SORH,KEEPAPP,CRIT] = DDENCMP('cmp','wp',uint8(X));
> %De-noising or compression using wavelet packets.
> [XC,TREED,PERF0,PERFL2] =WPDENCMP(X,SORH,2,'haar',CRIT,THR,KEEPAPP);
> disp('Level-dependent thresholds');
> disp(THR);
> disp('The entropy used is');
> disp(CRIT);
> disp('The type of thersholding is');
> if SORH==s
> disp('Soft Thresholding');
>
> else
> disp('Hard Thresholding');
> end
> disp('Approximation coefficients are');
> disp(KEEPAPP);
> disp('Wavelet packet best tree decomposition of XD');
> disp(TREED);
> disp('The L^2 recovery');
> disp(PERFL2);
> disp('The compression scores in percentages');
> disp(PERF0);
> XC=double(X)+128;
> figure;
> %subplot(2,1,1);
> %imshow(uint8(X));
> %title('Original Image');
> %subplot(2,1,2);
> imshow(uint8(XC));
> title('Output image');
> [b1,b2]=size(XC);
> disp('The number of rows in compressed image are');
> disp(b1);
> disp('The number of coloums in image are');
> disp(b2);
> %figure;
> %y=imsubtract(uint8(X),uint8(XC));
> %imshow(y);title('error image');
>
> %INFO = IMFINFO(X,bmp);
> %INFO1 = IMFINFO(XC,bmp);
>
> The number of rows in input image are
> 256
>
> The number of coloums in input image are
> 256
>
> enter the decomposition level




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.