当前位置:网站首页>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;
边栏推荐
- 微信小程序获取用户手机号码
- ABAB-740新语法
- Fastjson反序列化
- LyScript implements memory stack scanning
- ERC20通证标准是什么?
- How to use outside the PHP command in the container
- 一文带你弄懂 CDN 技术的原理
- Machines need tokens more than people
- For invoice processing DocuWare, cast off the yoke of the paper and data input, automatic processing all the invoice received
- RICON:NER SOTA 又来!
猜你喜欢
技术总监需要会些什么?也太难了!
CDH6.3.2开启kerberos认证
【MySQL功法】第2话 · 数据库与数据表的基本操作
后台图库上传功能
在线生成接口文档
Cross-chain bridge protocol Nomad suffers hacker attack, losing more than $150 million
劝退背后。
MySQL - 2059 - Authentication plugin ‘caching_sha2_password‘ cannot be loaded
For invoice processing DocuWare, cast off the yoke of the paper and data input, automatic processing all the invoice received
fast planner中拓扑路径搜索
随机推荐
赛灵思MPSOC裸机下的 USB调试实验
Classical Architecture and Memory Classification of Embedded Software Components
Skills required to be a good architect: How to draw a system architecture that everyone will love?What's the secret?Come and open this article to see it!...
【Mysql】清理binlog日志的方法
Objective - C code analysis of the deep and shallow copy
Fastjson反序列化
ETL data cleaning case in MapReduce
LeetCode 899 有序队列[字典序] HERODING的LeetCode之路
Cookie and Session usage
后台图库上传功能
FR9811S6 SOT-23-6 23V,2A同步降压DC/DC转换器
微信为什么使用 SQLite 保存聊天记录?
[Explanation of JDBC and inner classes]
[Star Project] Little Hat Plane Battle (9)
Dry goods!A highly structured and sparse linear transformation called Deformable Butterfly (DeBut)
通过组策略安装软件和删除用户配置文件
LeetCode——622.设计循环队列
How to use outside the PHP command in the container
数据库一席谈:打造开源的数据生态,支撑产业数字化浪潮
redis基础知识总结——数据类型(字符串,列表,集合,哈希,集合)