?? image compression using sofm using wavelet.mht
字號(hào):
From: <由 Microsoft Internet Explorer 5 保存>
Subject:
Date: Mon, 30 Jun 2008 15:18:22 +0800
MIME-Version: 1.0
Content-Type: text/html;
charset="gb2312"
Content-Transfer-Encoding: quoted-printable
Content-Location: http://www.mathworks.com/matlabcentral/files/8746/decvqcorcomp.m
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dgb2312">
<META content=3D"MSHTML 6.00.2900.3354" name=3DGENERATOR></HEAD>
<BODY><PRE>%wavelet based compression using Sofm
clear all;
% CLOSE ALL closes all the open figure windows.
close all;
%read the image
% Load original image.
load woman;
% X contains the loaded image.=20
% map contains the loaded colormap.
c=3Dinput('enter the codebook size');
b=3Dinput('enter the block size b=3D');
if b=3D=3D4
imshow(uint8(X));
else
imshow('invalid');
end
nbcol =3D size(map,1);
imshow(uint8(X));
figure;
% Perform single-level decomposition=20
% of X using haar.=20
[cA1,cH1,cV1,cD1] =3D dwt2(X,'haar');
% Images coding.=20
cod_X =3D wcodemat(X,nbcol);=20
cod_cA1 =3D wcodemat(cA1,nbcol);=20
cod_cH1 =3D wcodemat(cH1,nbcol);=20
cod_cV1 =3D wcodemat(cV1,nbcol);=20
cod_cD1 =3D wcodemat(cD1,nbcol);=20
dec2d =3D [cod_cA1, cod_cH1; cod_cV1, cod_cD1 ];
imshow(uint8(dec2d));
%A5 =3D idwt2(cod_cA1, cod_cH1, cod_cV1, cod_cD1,'db1');
%imshow(uint8(A5));
%disp('dfds');
[cA2,cH2,cV2,cD2] =3D dwt2(cA1,'haar');
% Images coding.=20
cod_cA1 =3D wcodemat(cA1,nbcol);=20
cod_cA2 =3D wcodemat(cA2,nbcol);=20
cod_cH2 =3D wcodemat(cH2,nbcol);=20
cod_cV2 =3D wcodemat(cV2,nbcol);=20
cod_cD2 =3D wcodemat(cD2,nbcol);=20
dec2d =3D [cod_cA2, cod_cH2; cod_cV2, cod_cD2 ];
imshow(uint8(dec2d));
figure;
% disp('dfds');
=20
[cA3,cH3,cV3,cD3] =3D dwt2(cA2,'haar');
% Images coding.=20
cod_cA2 =3D wcodemat(cA2,nbcol);=20
cod_cA3 =3D wcodemat(cA3,nbcol);=20
cod_cH3 =3D wcodemat(cH3,nbcol);=20
cod_cV3 =3D wcodemat(cV3,nbcol);=20
cod_cD3 =3D wcodemat(cD3,nbcol);=20
dec2d =3D [cod_cA3, cod_cH3; cod_cV3, cod_cD3 ];
% imshow(uint8(dec2d));
%disp('dfds');
=20
[cA4,cH4,cV4,cD4] =3D dwt2(cA3,'haar');
% Images coding.=20
cod_cA3 =3D wcodemat(cA3,nbcol);=20
cod_cA4 =3D wcodemat(cA4,nbcol);=20
cod_cH4 =3D wcodemat(cH4,nbcol);=20
cod_cV4 =3D wcodemat(cV4,nbcol);=20
cod_cD4 =3D wcodemat(cD4,nbcol);=20
dec2d =3D [cod_cA4, cod_cH4; cod_cV4, cod_cD4 ];
%imshow(uint8(dec2d));
=20
%disp('dfds');
=20
=20
=20
=20
=20
=20
% Using some plotting commands,
% the following figure is generated.
%n=3Dinput('enter the decomposition level');
%[Lo_D,Hi_D,Lo_R,Hi_R] =3D wfilters('haar');
%[c,s]=3Dwavedec2(uint8(dec2d),1,Lo_D,Hi_D);
%[thr,nkeep] =3D wdcbm2(uint8(dec2d),1.5,prod(s(1,:)));
%disp('level-dependent thresholds');=20
%disp(thr);
%disp(' numbers of coefficients to be');
%disp(nkeep);=20
comp_image =3D IMNOISE(uint8(X),'gaussian',0,.1);
[compressed_image,TREED,PERF0,PERFL2] =
=3DWPDENCMP(148,'s',1,'haar','threshold',2,1);
subplot(2,1,1);
imshow(uint8(X));
title('original image');
subplot(2,1,2);
imshow(comp_image);
title('compressed_image');
%disp(PERF0);
% disp('compression ratio=3D');</PRE></BODY></HTML>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -