资源描述:
《数字图像处理课设xx》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、数字图像处理课程设计报告题目:基于图像的DCT编码解码的设计专业班级:通信0802学号:2008001314姓名:吴向禹基于图像的DCT编码解码的设计一、设计目的1.1熟悉和掌握MATLAB程序设计方法1.2掌握图像DCT的编码解码过程61.3学习和熟悉MATLAB图像处理工具箱1.4学会运用MATLAB工具箱对图像进行处理和分析二、设计环境WindowXP,MATLAB7.1三、具体设计:3.1%编码程序functiony=jpegencode(x,quality)error(nargchk(1,2,nargin));ifnargin<2quality=1;e
2、ndx=double(x)-128;[xm,xn]=size(x);t=dctmtx(8);y=blkproc(x,[88],'P1*x*P2',t,t');m=[1611101624405161;1212141926586055;1413162440576956;1417222951878062;182237566810910377;243555648110411392;49647887103121120101;7292959811210010399]*quality;yy=blkproc(y,[88],'round(x./P1)',m);y=im2col(y
3、y,[88],'distinct');xb=size(y,2);order=[19231017251811451219263341342720136714212835424957504336292215816233037445158595245383124323946536061544740485562635664];%z型扫描对变换系数重新排列y=y(order,:);eob=max(x(:))+1;num=numel(y)+size(y,2);r=zeros(num,1);count=0;forj=1:xbi=max(find(y(:,j)));ifisem
4、pty(i)i=0;endp=count+1;q=p+i;r(p:q)=[y(1:i,j);eob];count=count+i+1;endr((count+1):end)=[];r=r+128;6r=uint8(r);savedatr;y.size=uint16([xm,xn]);y.numblocks=uint16(xb);y.quality=uint16(quality*100);保存为叫jpegencode的m文件,方便调用。3.2解码程序functionx=jpegdecode(y)error(nargchk(1,1,nargin));m=[16111
5、01624405161;1212141926586055;1413162440576956;1417222951878062;182237566810910377;243555648110411392;49647887103121120101;7292959811210010399];order=[19231017251811451219263341342720136714212835424957504336292215816233037445158595245383124323946536061544740485562635664];rev=order;for
6、k=1:length(order)rev(k)=find(order==k);endm=double(y.quality)/100*m;xb=double(y.numblocks);sz=double(y.size);xn=sz(1);xm=sz(2);%x=imread('rice.png');loaddatr;x=r;x=double(x)-128;eob=max(x(:));z=zeros(64,xb);k=1;forj=1:xbfori=1:64ifx(k)==eobk=k+1;break;elsez(i,j)=x(k);k=k+1;endendendz
7、=z(rev,:);x=col2im(z,[88],[xmxn],'distinct');x=blkproc(x,[88],'x.*P1',m);6t=dctmtx(8);x=blkproc(x,[88],'P1*x*P2',t',t);这里为编码程序,保存为函数jpegdecode的m文件方便调用。3.3%%%压缩率%%%%functioncr=imageratio(f1,f2)error(nargchk(2,2,nargin));cr=bytes(f1)/bytes(f2);保存为函数imageratio的m文件3.4%%%%bytes%%%%%%funct
8、ionb=bytes(f