基于MATLAB的图像压缩编码技术

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

图像的压缩比计算:

>> f=imread('peppers.png');

>> imwrite(f,'peppers.png');

>> k=imfinfo('peppers.png');

>> ib=k.Width*k.Height*k.BitDepth/8;

>> cb=k.FileSize;

>> cr=ib/cb

cr =

2.0509

变换编码:

计算DCT变换的基函数:

>> n=4;

>> c=zeros(n,n);

>> for m=0:1:n-1

for k=0:1:n-1

if k==0

l=sqrt(1/n);

else

l=sqrt(2/n);

end;

c(m+1,k+1)=l*cos(((2*m+1)*k*pi)/(2*n));

end;

end;

>> colormap('gray');

>> for m=0:1:n-1

for k=0:1:n-1

subplot(n,n,m*n+k+1);

y=[zeros(m,n);zeros(1,k) 1 zeros(1,n-k-1);zeros(n-m-1,n)];

x=c*y*c';

imagesc(x);

axis square;

axis off;

end;

end;

对图像进行DCT和IDCT变换:>> rgb=imread('autumn.tif'); >> i=rgb2gray(rgb);

>> i=im2double(i);

>> i1=dct2(i);

>> i2=idct2(i1);

>> subplot(2,2,1);imshow(i);

>> subplot(2,2,2);imshow(i2);

>> subplot(2,2,3);imshow(i1);

>> subplot(2,2,4);imshow(abs(i-i2)); >> figure;mesh(i1);

>> colorbar('vert');

>> set(gcf,'color','w');

小波分析对图像进行增强处理:>> load wbarb;

>> subplot(1,2,1);image(X);

>> colormap(map);

>> axis square;

>> [c,s]=wavedec2(X,2,'sym4');

>> sizec=size(c);

>> for i=1:sizec(2)

if(c(i)>350)

c(i)=2*c(i);

else

c(i)=0.5*c(i);

end;

end;

>> xw=waverec2(c,s,'sym4'); >> subplot(1,2,2);image(xw); >> colormap(map);

>> axis square;

用二维小波分析融合图像:>> load woman;

>> X1=X;map1=map;

>> subplot(1,3,1);image(X1); >> colormap(map1);

>> axis square;

>> load wbarb;

>> X2=X;map2=map;

>> subplot(1,3,2);image(X2); >> colormap(map2);

>> axis square;

>> for i=1:256

for j=1:256

if(X2(i,j)>100)

X2(i,j)=1.25*X2(i,j);

else

X2(i,j)=0.6*X2(i,j);

end;

end;

end;

>> [c1,s1]=wavedec2(X1,2,'sym4');

>> sizec1=size(c1);

>> for i=1:sizec1(2)

c1(i)=1.25*c1(i);

end;

>> [c2,s2]=wavedec2(X2,2,'sym4');

>> c=c1+c2;

>> c=0.5*c;

>> xw=waverec2(c,s1,'sym4');

>> subplot(1,3,3);image(xw);

>> axis square;

利用图像融合法从模糊图像中恢复图像:>> load cathe_1;X1=X;

>> load cathe_2;X2=X;

>> XFUS=wfusimg(X1,X2,'sym4',5,'max','max'); >> colormap(map);

>> subplot(1,3,1);image(X1);

>> axis square;

>> subplot(1,3,2);image(X2);

>> axis square;

>> subplot(1,3,3);image(XFUS);

相关文档
最新文档