【opencv 官方教程】翻译2 核心功能 下 傅里叶分离变换 XML格式IO

核心功能

  • The Core Functionality (core module)

    Here you will learn the about the basic building blocks of the library. A must read and know for understanding how to manipulate the images on a pixel level.

傅里叶分离变换 (DFT)

  • Discrete Fourier Transform

    Compatibility: > OpenCV 2.0

    Author: Bernát Gábor

    You will see how and why use the Discrete Fourier transformation with OpenCV.

研究这个需要:

 了解傅里叶变换

 了解OpenCV如何使用它

数学上 我们可以将二维图像转化为一维的数列,然后通过傅里叶变换将数列转换到频域

表达式(cosx表示该点的实部,isinx表示虚部):

F(k,l)=i=0N1j=0N1f(i,j)ei2π(kiN+ljN)
eix=cosx+isinx


步骤简要说明:

Expand the image to an optimal size

拓展图片的大小(貌似是为了变换时能有足够的画布存下临时数据,比较理想的是拓展两倍,使用cv::getOptimalDFTSize() 获取具体尺寸,cv::copyMakeBorder() 进行拓展

Make place for both the complex and the real values.

将拓展出来的区域填充上0;

Make the Discrete Fourier Transform

进行dft变换

Transform the real and complex values to magnitude.

求出变换结果的值M(由虚数转换为该虚数代表的某种值magnitude),虚数的两部分被分别存于原先的Mat部分和拓展部分,最后的结果被放于原有部分。

Switch to a logarithmic scale

对数形式表达M,因为直接用M来表示太大了。

Crop and rearrange

据描述是用来剔除扩展部分的

Normalize

将求出M后的图像拓展到可视化的范围(大概是三色0~255)


这些比较抽象,有兴趣的童鞋可以找相关资料仔细研究,不适合略读。


XML格式IO

XML/YAML File Open and Close

string filename = "I.xml";
FileStorage fs(filename, FileStorage::WRITE);
//...
fs.open(filename, FileStorage::READ);
fs.release();

基本的打开关闭操作

Input and Output of text and numbers

键值对io

fs << "iterationNr" << 100;

int itNr;
fs["iterationNr"] >> itNr;
itNr = (int) fs["iterationNr"];


Input/Output of OpenCV Data structures

Mat作为值进行键值对io

Mat R = Mat_<uchar >::eye (3, 3),
T = Mat_<double>::zeros(3, 1);
fs << "R" << R; // Write cv::Mat
fs << "T" << T;
fs["R"] >> R; // Read cv::Mat
fs["T"] >> T;


Input/Output of vectors (arrays) and associative maps.

字符串、map io 略

Read and write your own data structures

自定义数据结构io 记得编写对应的write read方法


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值