1、OpenCV傅里叶变换相关函数
首先我要说明的是,在使用OpenCV写代码做图像傅里叶变换的时候,并仅仅是调用dft
函数做一个傅里叶变换这么简单的,而是先要对图像进行一些变换之后,才能得到正确的傅里叶变换结果。因此,第一部分我想先列出几个OpenCV提供的与傅里叶变换相关的函数,在了解这些函数功能的基础上,我们再进行具体的图像傅里叶变换的过程。
1.1 dft()
首先,OpenCV提供的傅里叶变换函数dft
。其定义如下:
void dft(InputArray src, OutputArray, dst, int flags, int nonzeroRows);
/**
* 参数解释:
* src : 输入图像
* dst : 输出图像,傅里叶变换结果。默认情况下返回值有两个通道,第一个通达是实部,第二个通道是虚部。
* flags : 转换的标识符,有默认值0,暂时不用理会这个参数
*/
1.2 magnitude()
计算二维矢量的幅值。其定义如下:
void magnitude(InputArray x, InputArray y, OutputArray magnitude);
/**
* 参数解释:
* x : 实部
* y : 虚部
* magnitude : 幅值结果
*/
其计算公式如下:
d s t ( I ) = x ( I ) 2 + y ( I ) 2 dst(I) = \sqrt{x(I)^2 + y(I)^2} dst(I)=x(I)2+y(I)2
1.3 phase()
void phase(InputArray x, InputArray y, OutputArray dst, bool angleIndegrees=false);
/**
* 参数解释:
* x : 实部
* y : 虚部
* dst : x和y的反正切值结果
*/
其计算公式如下:
d s t = arctan y x dst = \arctan \frac{y}{x} dst=arctanx