RGB=imread('autumn.tif');
A=rgb2gray(RGB);
subplot(3,2,1);imshow(A);
title('原始图像灰度显示');
[cA,cH,cV,cD]=dwt2(A,'db7');
A1=upcoef2('a',cA,'db7',1);
H1=upcoef2('a',cH,'db7',1);
V1=upcoef2('a',cV,'db7',1);
D1=upcoef2('a',cD,'db7',1);
colnb=size(RGB,1);
subplot(3,2,2);
image(wcodemat(cA,colnb));title('近似分量');
subplot(3,2,3);
image(wcodemat(cH,colnb));title('水平细节分量');
subplot(3,2,4);
image(wcodemat(cV,colnb));title('垂直细节分量');
subplot(3,2,5);
image(wcodemat(cD,colnb));title('对角细节分量');
程序运行结果如下:
实验一 DCT变换和IDCT变换
RGB=imread('autumn.tif');
subplot(3,2,1);
imshow(RGB);title('原始图像');
A=rgb2gray(RGB);
subplot(3,2,2);
imshow(A);title('原始图像灰度显示');
B=dct2(A);
subplot(3,2,3);
imshow(log(abs(B)),[ ]),colormap(jet()),colorbartitle('离散余弦变换结果图像');
F=fft2(A);
F2=abs(fftshift(F));
subplot(3,2,4);
imshow((F2),[ ]),colormap(jet()),colorbartitle('傅里叶变换结果图像');
B(abs(B)<10)=0;
K=idct2(B);
subplot(3,2,5);
imshow(K,[0 255]);title('反变换图像');
程序运行结果如下: