当前位置:首页 > 实验四 二维离散傅立叶变换的计算与显示
计算机与信息学院实验报告
系: 电子信息工程系 专业: 电子信息工程专业 年级: 08 姓名 学号: 实验室号_ 计算机号
实验时间: 2011.05 指导教师签字: 成绩: 报告退发 (订正 、 重做)
实验四 二维离散傅立叶变换的计算与显示
1. 实验目的和要求
掌握二维离散傅立叶变换。
2. 实验内容和原理
根据二维离散傅立叶变换公式计算傅立叶谱,并显示相应的傅立叶谱图像。
3. 实验环境
硬件:一般PC机
操作系统:WindowsXP
编程平台:MATLAB 或高级语言
4. 算法描述及实验步骤
4.1 二维离散傅里叶变换的计算和显示的算法描述:
(1)Draw a small image; (2)Show this image;
(3)Calculate the rows and columns in the matrix of the iamge,the mat-rix is [m,n];
(4)Create a matrix Y to store the image which is transformed; (5)u=1; (6)v=1; (7)Y(u,v)=0; (8)x=1; (9)y=1;
(10)Y(u,v)=X(x,y)*exp(-i*2*pi*(u*x/m+v*y/n))+Y(u,v); (11)y++;
(12)if y<=n,return(10);else go to (13); (13)x++;
(14)if x<=m,return(9);else go to (15); (15)Y(u,v)=Y(u,v)/(m*n);
1
(16)Real=real(Y(u,v)); (17)Imag=imag(Y(u,v));
(18)Y(u,v)=sqrt(Real*Real+Imag*Imag); (19)v++;
(20)if v<=n,return(7);else go to (21); (21)u++;
(22)if u<=m,return(6);else go to (23);
(23)Converts the matrix Y to the intensity image;
4.2实验步骤:
(1)使用M-file编辑器编辑功能建立一个M文件,编写其算法,命名为
shiyan4;
(2)检查和误差修正的功能; (3)修改shiyan4; (4)运行功能和对比结果;
4.3 matlab中的源程序: clear;
for I=1:30 for J=1:20 X(I,J)=0; end end for I=10:20 for J=10:15 X(I,J)=255; end
end %Draw a 30*20 size image
X=mat2gray(X); % Converts the matrix X to the intensity image subplot(1,2,1);
imshow(X); %Show the image title('原图')
[m,n]=size(X); %The number of rows and columns in the matrix of the iamge
2
X=double(X); %The double precision value for X Y=zeros(m,n); %For storing output image for(u=1:m) for(v=1:n) Y(u,v)=0; for(x=1:m) for(y=1:n)
Y(u,v)=X(x,y)*exp(-i*2*pi*(u*x/m+v*y/n))+Y(u,v);
end
end %Fourier transform Y(u,v)=Y(u,v)/(m*n);
Real=real(Y(u,v));
Imag=imag(Y(u,v));
Y(u,v)=sqrt(Real*Real+Imag*Imag); end end
Y=mat2gray(Y); %Converts the matrix Y to the intensity image subplot(1,2,2);
imshow(Y); %Show the image after transformed title('DFT');
5. 调试过程
其Workspace如下:
3
实验过程中没出现错误。
6. 实验结果
7. 总结
在大一高数课上有接触到傅里叶变换这个概念,我一直都以为它只是数学概念,没想到还可以用它进行图像处理,因此感触颇深。这个实验要求的是对二维离散傅里叶变换的计算,根据书本上二维离散傅里叶变换公式:
4
对实验进行程序的简单编写,离散傅里叶变换的复杂,为了避免图像处理过程中时间较长,采用较为简单的30*20的黑白图像进行运行。在实验过程中,借鉴一些和书本上的相关材料,对二维离散傅里叶变换进行更通透的认识,以便实验的顺利进行。由实验结果可知:本实验根据二维离散傅立叶变换公式计算傅立叶谱,进行相应的程序运行如期地得到了相应的傅立叶谱图像。
5
共分享92篇相关文档