|
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
如何利用MATLAB自带的傅里叶变换进行图像处理
4 R4 }# A2 V) ? |# H& p
5 W( @- r4 P2 O! n+ J( f. ^( S3 o) ~/ Q- w, @& K1 E
代码如下:
) Z1 K& R! }1 t! \( w0 j5 U- ]8 x' d7 D" @1 p8 ]) E% b
& a' s' Z4 R4 a- clear;
- clc;
-
- img=imread('test.jpg');
- img=rgb2gray(img);
-
- f=fft2(img); %傅里叶变换
- f=fftshift(f); %使图像对称
- r=real(f); %求图像频域实部
- i=imag(f); %求图像频域虚部
- margin=log(abs(f)); %图像幅度谱,加log便于显示
- phase=log(angle(f)*180/pi); %图像相位谱
- l=log(f);
-
- subplot(2,2,1),imshow(img),title('源图像');
- subplot(2,2,2),imshow(l,[]),title('频谱');
- subplot(2,2,3),imshow(margin,[]),title('幅度谱');
- subplot(2,2,4),imshow(phase,[]),title('相位谱');
3 x- [$ m5 w0 y. |$ U/ Y. B
3 D/ a/ ~2 W* I* ]4 g
' m0 Y, X5 Y- l" y4 s$ I( {
- }1 }1 u, l7 e% M
) k/ y- i6 n( C2 _- ~
0 H( e/ O: [; Q4 C. v; u |
|