clear X = imread('wgxy.jpg'); I = rgb2gray(X); imshow(I); I=double(I); subplot(231); imshow(I,[]); title('原始图像'); axis square; disp('压缩前图像大小字节'); whos('I'); [c,s] = wavedec2(I,3,'bior3.7'); ca1 = appcoef2(c,s,'bior3.7',1); ch1 = detcoef2('h',c,s,1); cv1 = detcoef2('v',c,s,1); cd1 = detcoef2('d',c,s,1); a1 = wrcoef2('a',c,s,'bior3.7',1); h1 = wrcoef2('h',c,s,'bior3.7',1); v1 = wrcoef2('v',c,s,'bior3.7',1); d1 = wrcoef2('d',c,s,'bior3.7',1); c1=[a1,h1;v1,d1]; subplot(232); imshow(c1,[]); axis square; title('分解后低频和高频信息'); ca1 = appcoef2(c,s,'bior3.7',1); ca1 = wcodemat(ca1,500,'mat',0); a11 = wrcoef2('a',c,s,'bior3.7',1); subplot(233); imshow(a11,[]); axis square; title('第一次压缩图像'); disp('第一次压缩图像字节大小'); whos('ca1'); subplot(234); ca2 = appcoef2(c,s,'bior3.7',2); ca2 = wcodemat(ca2,500,'mat',0); a22 = wrcoef2('a',c,s,'bior3.7',2); imshow(a22,[]); axis square; title('第二次压缩图像'); disp('第二次压缩图像字节大小'); whos('ca2'); subplot(235); ca3 = appcoef2(c,s,'bior3.7',3); ca3 = wcodemat(ca3,500,'mat',0); a33 = wrcoef2('a',c,s,'bior3.7',3); imshow(a33,[]); axis square; title('第三次压缩图像'); disp('第三次压缩图像字节大小'); whos('ca3');想让第三次压缩的字节有变化怎么改程序
时间: 2023-12-04 13:02:39 浏览: 12
可以通过更改wcodemat函数中的压缩比例参数来改变第三次压缩后的字节大小。将500改成其他数值即可,例如改为250。具体地,将
```
ca3 = wcodemat(ca3,500,'mat',0);
```
改为
```
ca3 = wcodemat(ca3,250,'mat',0);
```
即可。
相关问题
Img = imread('wgxy.jpg'); imshow(Img); disp('原始图像字节::'); whos('Img') I = rgb2gray(Img); imshow(I); disp('灰度图像字节:'); whos('I'); J = dct2(I); figure, imshow(log(abs(J))), colorbar; b=uint32(15/100*1080); J=J(1:b,1:b); disp('分块后反变换前字节:'); whos('J'); J(1080,1080)=0 K = idct2(J); disp('离散余弦变换后字节:'); whos('K'); figure, imshow(I), title('原图'); figure, imshow(J), title('二维离散余弦变换结果'); figure, imshow(K, [0,255]), title('还原图');加一段程序把峰值信噪比显示出来
Img = imread('wgxy.jpg');
imshow(Img);
disp('原始图像字节::');
whos('Img')
I = rgb2gray(Img);
imshow(I);
disp('灰度图像字节:');
whos('I')
J = dct2(I);
figure, imshow(log(abs(J))), colorbar;
b=uint32(15/100*1080);
J=J(1:b,1:b);
disp('分块后反变换前字节:');
whos('J');
J(1080,1080)=0
K = idct2(J);
disp('离散余弦变换后字节:');
whos('K')
figure, imshow(I), title('原图');
figure, imshow(J), title('二维离散余弦变换结果');
figure, imshow(K, [0,255]), title('还原图');
peaksnr = psnr(K, I);
disp(['峰值信噪比为: ', num2str(peaksnr)]);
阅读全文