matlab中怎样将像素为512×512的图像压缩为128×128,JPEG图像压缩Matlab程序

matlab中怎样将像素为512×512的图像压缩为128×128,JPEG图像压缩Matlab程序blockbit_seq=[];zrl_seq=[];trt_seq=[];zerolen=0;zeronumber=0;%%分块中只有第一个DC系数为0或不为0,AC系数全为0的情况ifnumel(e)==1blockACbit_seq=[];blockbit_seq=[blockDCbit_seq,eob_seq];blockbit_len=length(blockbit_seq);els…

matlab中怎样将像素为512x512的图像压缩为128x128,JPEG图像压缩Matlab程序

blockbit_seq=[];zrl_seq=[];trt_seq=[];zerolen=0;zeronumber=0;%% 分块中只有第一个DC系数为0或不为0,AC系数全为0的情况if numel(e)==1blockACbit_seq=[];blockbit_seq=[blockDCbit_seq,eob_seq];blockbit_len=length(blockbit_seq);elsefor i=2:wif ( e(i)==0 & zeronumber<16)zeronumber=zeronumber+1;elseif (e(i)==0 & zeronumber==16);bit_seq=dec2bin(2041,11);%%zrl=1111 1111 001zeronumber=1;blockACbit_seq=[blockACbit_seq,bit_seq];elseif (e(i)~=0 & zeronumber==16)zrl_seq=dec2bin(2041,11);amplitude=e(i);trt_seq=ACHuffmanEncoding(0,amplitude);bit_seq=[zrl_seq,trt_seq];blockACbit_seq=[blockACbit_seq,bit_seq];zeronumber=0;elseif(e(i))zerolen=zeronumber;amplitude=e(i);zeronumber=0;bit_seq=ACHuffmanEncoding(zerolen,amplitude);blockACbit_seq=[blockACbit_seq,bit_seq];endendendblockbit_seq=[blockDCbit_seq,blockACbit_seq,eob_seq];blockbit_len=length(blockbit_seq);%% blockbit_seq为整个块的编码序列,blockbit_len为整个块的编码长度blockbit_seq;blockbit_len;ImageBitSeq=[ImageBitSeq,blockbit_seq];ImageBitLen=numel(ImageBitSeq);colloop=colloop+1;endrowloop=rowloop+1;end%% 整个图像编码后的bit序列ImageBitSeq以及bit序列的长度ImageBitLenImageBitSeq;ImageBitLen;CompressionRatio=Row*Col*8/ImageBitLen;disp(‘DCTJPEG压缩编码比特率(bpp)’)AverageBit=ImageBitLen/Row/Col%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%************************* Encoding is finished ********************************%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Huffman解码程序省略%% 反量化:把矩阵CoefAfterQDecode反量化得矩阵CoefInverseQCoefInverseQ=blkproc(CoefAfterQ,[8,8],’x.*P1′,L);%% 反dct2变换:把CoefInverseQ分成8*8像素块,分别进行反dct2变换重建图像ImageSubRecon,并显示ImageSubRecon=blkproc(CoefInverseQ,[8,8],’idct2(x)’);ReconImage=round(ImageSubRecon)+128;%%向靠近的整数取圆整,反向电平平移128% figure,imshow(ReconImage,[]);%%title(‘DCTJPEG压缩重建图像’);%% 求峰值信噪比PSNR:disp(‘DCTJPEG压缩前后图像峰值信噪比(dB)’)PSNR0=PSNR(OriginalImage,ReconImage)

今天的文章matlab中怎样将像素为512×512的图像压缩为128×128,JPEG图像压缩Matlab程序分享到此就结束了,感谢您的阅读,如果确实帮到您,您可以动动手指转发给其他人。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/31376.html

(0)
编程小号编程小号

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注