Image Compression Using wavelet- MATLAB

user101509 picture user101509 · Jan 25, 2013 · Viewed 8.7k times · Source

I am working on image compression based on wavelet in MATLAB... I have constructed the below code. Everything is working fine but the compressed image is displayed as plain black and white image. If I give the decomposition level as 1, it shows compressed image as full black, for the decomposition level: 2, it gives fully white image.. For the decomposition level 3, it gives 3/4 white and 1/4 black color.. Please help. The code I have used is

clear all;

close all;

input_image1=imread('C:\Users\Prem\Documents\MATLAB\mandrill.jpg');

input_image=imnoise(input_image1,'speckle',.01);

figure;

imshow(input_image);

n=input('enter the decomposition level=');

[Lo_D,Hi_D,Lo_R,Hi_R] = wfilters('haar');

[c,s]=wavedec2(input_image,n,Lo_D,Hi_D);

disp(' the decomposition vector Output is');

disp(c);

[thr,nkeep] = wdcbm2(c,s,1.5,3*prod(s(1,:)));

 [compressed_image,TREED,comp_ratio,PERFL2] =wpdencmp(thr,'s',n,'haar','threshold',5,1);

 disp('compression ratio in percentage');

 disp(comp_ratio);

  re_ima1 = waverec2(c,s,'haar'); 

 re_ima=uint8(re_ima1);

  subplot(1,3,1);

 imshow(input_image);

 title('i/p image');

 subplot(1,3,2);

 imshow(compressed_image);

 title('compressed image');

 subplot(1,3,3);

 imshow(re_ima);

 title('reconstructed image');

Answer

Mussa picture Mussa · May 11, 2016

My opinion the problem with scaling the images .You can divide resulted images by suitable number or use

imagesc(desire image);

subplot(1,3,2);

imshow(compressed_image/156);

title('compressed image');

subplot(1,3,3);

imagesc(re_ima);

title('reconstructed image');