[求助]那位高手能帮我改下这个程序!急用!在线等!
代码如下 功能是实现JPEG图像的基本压缩<BR>1.主程序<BR>I=imread('autumn.tif');<BR>yiq=rgb2ntsc(I);<BR>my=;<BR>miq=;<BR>I1=yiq(:,:,1);I2=(:,:,2);<BR>=size(I1);<BR>t1=8;ti1=1;<BR>while(t1<BR>t1=t1+8;ti1=ti1+1;<BR>end<BR>t2=8;ti2=1;<BR>while(t2<BR>t2=t2+8;ti2=ti2+1;<BR>end<BR>times=0;<BR>for k=0:ti1-2<BR>for j=0:ti2-2<BR>dct8x8(I1(k*8+1:k*8+8,j*8+1:j*8+8),my,times*64+1);<BR>dct8x8(I2(k*8+1:k*8+8,j*8+1:j*8+8),miq,times*64+1);<BR>times=times+1;<BR>end<BR>block(I2(k*8+1:k*8+8,j*8+1:t2),, 'dctmtx(8)');<BR>end<BR>for j=0:ti2-2<BR>dct8x8(I1(k*8+1:t1,j*8+1:j*8+8),times*64+1);<BR>times=times+1;<BR>end<BR>dct8x8(I1(k*8+1:t1,j*8+1:t2),times*64+1);<BR>2.function dct8x8(I,m,s) %定义DCT量化子程序<BR>T=inline('dctmtx(8)');<BR>y=blkproc(I,,T);<BR>y=round(y./m);<BR>p=1;te=1;<BR>while(p<=64)<BR>for q=1:te<BR>y1(s+p)=y(te-q+1,q);p=p+1;<BR>end<BR>for q=te:-1:1<BR>y1(s+p)=y(te-q+1,q);p=p+1;<BR>end<BR>end<BR>f=haffman(y1);<BR>c(s:s+64,1)=f(:,1);c(s:s+64,2)=f(:,2);c(s:s+64,3)=f(:,3)<BR>3.function c=haffman(I) %定义Huffman编码子程序<BR>=size(I);<BR>p1=1;s=m*n;<BR>for k=1:m<BR>for h=1:n<BR>f=0;<BR>for b=1:p1-1<BR>if(c(b,1)==I(k,h)) f=1;break;end<BR>end<BR>if(f==0) c(p1,1)=I(k,h);p1=p1+1;end<BR>end<BR>end<BR>for g=1:p1-1<BR>p(g)=0;c(g,2)=0;<BR>for k=1:m<BR>for h=1:n<BR>if(c(g,1)==I(k,h)) p(g)=p(g)+1;end<BR>end<BR>end<BR>p(g)=p(g)/s;<BR>end<BR>pn=0;po=1;<BR>while(1)<BR>if(pn>=1.0) break;<BR>else<BR>=min(p(1:p1-1));p(p2)=1.1;<BR>=min(p(1:p1-1));p(p3)=1.1;<BR>pn=pm+pm2;p(p1)=pn;<BR>tree(po,1)=p2;tree(po,2)=p3;<BR>po=po+1;p1=p1+1;<BR>end<BR>end<BR>for k=1:po-1<BR>tt=k;m1=1;<BR>if(or(tree(k,1)<9,tree(k,2)<9))<BR>if(tree(k,1)<9)<BR>c(tree(k,1),2)=c(tree(k,1),2)+m1;<BR>m2=1;<BR>while(tt<BR>m1=m1*2;<BR>for h=tt:po-1<BR>if(tree(h,1)==tt+g)<BR>c(tree(k,1),2)=c(tree(k,1),2)+m1;<BR>m2=m2+1;tt=h;break;<BR>elseif(tree(h,2)==tt+g)<BR>m2=m2+1;tt=h;break;<BR>end<BR>end<BR>end<BR>c(tree(k,1),3)=m2;<BR>end<BR>tt=k;m1=1;<BR>if(tree(k,2)<9)<BR>m2=1;<BR>while(tt<BR>m1=m1*2;<BR>for h=tt:po-1<BR>if(tree(h,1)==tt+g)<BR>c(tree(k,2),2)=c(tree(k,2),2)+m1;<BR>m2=m2+1;tt=h;break;<BR>elseif(tree(l,2)==tt+g)<BR>m2=m2+1,tt=h;break;<BR>end<BR>end<BR>end<BR>c(tree(k,2),3)=m2;<BR>end<BR>end<BR>end<BR>!!!!!!!急用啊!!!!!!!回复:(vonneumann)[求助]那位高手能帮我改下这个程...
有什么问题吗? 运行不了啊,huffman编码的地方有错误,但是又看不出哪错<BR>
页:
[1]