当前位置:网站首页>Matlab学习10-图像处理之傅里叶变换
Matlab学习10-图像处理之傅里叶变换
2022-08-03 11:30:00 【CHengYuP】
前言
图像变换
- 一维离散变换
- 二维离散变换
- 傅里叶变换
- 离散余弦变换
Matlab学习10-图像处理之傅里叶变换
傅里叶变换
优点:能从空间域和频率域两个不同的角度来看待问信号或图像。
缺点:傅里叶变换的收敛速度慢。
一、离散傅里叶变换
效果
代码
% 离散傅里叶变换示例。显示二维图、对称傅里叶幅度谱图像和傅里叶幅度图对数图像。
fxy=imread("img/F5_11a.bmp");
fxy=rgb2gray(fxy);
subplot(2,2,1),imshow(fxy),xlabel('原始图像');
Fuv=fft2(fxy);
FftShiftAbs=fftshift(abs(Fuv));
subplot(2,2,2),imshow(FftShiftAbs,[]),xlabel('对称傅里叶变换图像');
LogFftShiftAbs=log(FftShiftAbs);
subplot(2,2,3),imshow(LogFftShiftAbs,[]),xlabel('对称傅里叶幅度谱对称图像'),colormap(gray),colorbar;
二、二维离散傅里叶变换
效果
代码
% 二维离散傅里叶变换原理示例,显示二维图、傅里叶变换后的图,对称傅里叶幅度谱图像和他们的三维示意图。
A=1;
X=1;
Y=1;
uu=-1*pi:0.1:1*pi;
vv=-2*pi:0.1:2*pi;
[u,v]=meshgrid(uu,vv);
Fuv=A*X*Y*(sin(pi*u*X).*exp(-j*pi*u*X)./(pi*u*X)).*(sin(pi*v*Y).*exp(-j*pi*v*Y)./(pi*v*Y));
subplot(2,2,1),mesh(u,v,real(Fuv)),xlabel('\itu'),ylabel('\itv'),zlabel('{\itG}({\itu},{\itv})'),title('(a) 傅里叶变换');
subplot(2,2,2),mesh(u,v,abs(Fuv)),xlabel('\itu'),ylabel('\itv'),zlabel('{\itG}({\itu},{\itv})'),title('(b) 傅里叶幅度谱');
subplot(2,2,3),plot(uu,Fuv),xlabel('\itu'),ylabel('{\itG}({\itu})'),title('(c) 傅里叶变换在u轴上的投影'),grid on;
subplot(2,2,4),plot(vv,Fuv),xlabel('\itv'),ylabel('{\itG}({\itv})'),title('(d) 傅里叶变换在v轴上的投影'),grid on;
三、傅里叶级数将周期函数转换为不同正弦波的叠加
效果
代码
% 使用傅里叶级数将周期函数转换为不同正弦波的叠加。
A=2;
x=-5:0.1:5;
%前一次谐波叠代
hold on;
fx1=A/2+2*A/pi*(sin(1*pi*x/2)/1);
fxdd1=fx1;
subplot(2,3,1),plot(x,fxdd1,'k'),xlabel('(a)前一次谐波迭代');
%前两次谐波叠代
hold on;
fx2=A/2+2*A/pi*(sin(1*pi*x/2)/1+sin(3*pi*x/2)/3);
fxdd2=fx1+fx2;
subplot(2,3,2),plot(x,fxdd2,'k'),xlabel('(b)前两次谐波迭代');
%前三次谐波叠代
hold on;
fx3=A/2+2*A/pi*(sin(1*pi*x/2)/1+sin(3*pi*x/2)/3+sin(5*pi*x/2)/5);
fxdd3=fx1+fx2+fx3;
subplot(2,3,3),plot(x,fxdd3,'k'),xlabel('(c)前三次谐波迭代');
%前四次谐波叠代
hold on;
fx4=A/2+2*A/pi*(sin(1*pi*x/2)/1+sin(3*pi*x/2)/3+sin(5*pi*x/2)/5+sin(7*pi*x/2)/7);
fxdd4=fx1+fx2+fx3+fx4;
subplot(2,3,4),plot(x,fxdd4,'k'),xlabel('(d)前四次谐波迭代');
%前五次谐波叠代
hold on;
fx5=A/2+2*A/pi*(sin(1*pi*x/2)/1+sin(3*pi*x/2)/3+sin(5*pi*x/2)/5+sin(7*pi*x/2)/7+sin(9*pi*x/2)/9);
fxdd5=fx1+fx2+fx3+fx4+fx5;
subplot(2,3,5),plot(x,fxdd5,'k'),xlabel('(e)前五次谐波迭代');
%前四十次谐波叠代
hold on;
syms n;
k=symsum(2*A/pi*sin((2*n+1)*pi*x/2)/(2*n+1),0,39);
fxdd80=A/2+subs(k);
subplot(2,3,6),plot(x,fxdd80,'k'),xlabel('(f)前40次谐波迭代'),box off;
边栏推荐
- html网页如何获取后台数据库的数据(html + ajax + php + mysql)
- shell编程-测试
- 小身材有大作用——光模块基础知识(一)
- Analysis of the idea of the complete knapsack problem
- Question G: Word Analysis ← Questions for the second provincial competition of the 11th Blue Bridge Cup Competition
- LyScript implements memory stack scanning
- 【倒计时5天】探索音画质量提升背后的秘密,千元大礼等你来拿
- 【LeetCode—第2题 两数之和 代码详解 】附有源码,可直接复制
- ABAB-740新语法
- 机器比人更需要通证
猜你喜欢
随机推荐
完全背包问题的思路解析
The effects of the background and the Activiti
2022年五面蚂蚁、三面拼多多、字节跳动最终拿offer入职拼多多
浅谈SVN备份
ABAB-740新语法
Why is the new earth blurred, in-depth analysis of white balls, viewing pictures, and downloading problems
第四课 标识符、关键字、变量、变量的分类和作用域、常量
SmobilerService 推送实现
ETL data cleaning case in MapReduce
第四周学习 HybridSN,MobileNet V1,V2,V3,SENet
[Star Project] Little Hat Plane Battle (9)
MySQL database combat (1)
永寿 永寿农特产品-苹果
asdn涨薪技术之apifox+Jenkins如何玩转接口自动化测试
通过组策略安装软件和删除用户配置文件
矩阵的计算[通俗易懂]
微信小程序获取用户手机号码
码率vs.分辨率,哪一个更重要?
【网络原理的概念】
What is a smart contract?