仿真结果如下:
部分核心程序如下:
clc;
clear all;
close all;
tic;
orimg=imread('lena.bmp');
%orimg=imread('barbara.png');
imshow(orimg);
title('原始图象');
orimage=double(orimg);
tImg=wavelet('2D D5',3,orimage,'sym');
tImage=uint8(tImg);
figure;
imshow(tImage);
Img=zeros(512,512);
Img(1:256,1:256)=tImg(1:256,1:256);
[Image,sc,dmatrix]=double2uint(Img); %调整系数
x=select(Image);
code=RLC(x);
%%%%%%%%%%%%%%%%%%%解码部分%%%%%%%%%%%%%%%%%%
Image=dec(code);
Image_r=uint2double(Image,sc,dmatrix);
IImg=wavelet('2D D5',-3,Image_r,'sym');
IImg=uint8(IImg);
figure;imshow(IImg);
title('恢复图象');
% diff=orimg-IImg;
% %figure;imshow(diff);
% e=sum(sum(diff))/(sum(sum(orimg)));
% total_infor=512*512;
% [code_r,code_c]=size(code);pp=(512*512)/code_c;
% disp(['压缩前的图像字节数为:',int2str(total_infor)]);
% disp(['压缩后的图像字节数为:',int2str(code_c)]);
% disp(['压缩率为:',num2str(pp),':1']);
% disp(['压缩误差为:',num2str(e)]);
% orimage = double(orimage)/256;
% IImg=double(IImg)/256;
% Y = PSNR(orimage, IImg);
% fprintf('PSNR = %fdB\n',Y);
% toc;
% tt = toc;
% fprintf('运算时间:%fs\n',tt);
D192