返回:OpenCV系列文章目录(持续更新中......)
上一篇:OpenCV如何通过梯度结构张量进行各向异性图像分割(69)
下一篇 :OpenCV如何为我们的应用程序添加跟踪栏(71)
目录
目标
理论
如何消除傅里叶域中的周期性噪声?
源代码
解释
目标
在本教程中,您将学习:
- 如何消除傅里叶域中的周期性噪声
理论
注意
解释基于该书[108]。此页面上的图像是真实世界的图像。
周期性噪声在傅里叶域中产生尖峰,通常可以通过视觉分析检测到。
如何消除傅里叶域中的周期性噪声?
通过频域滤波可以显著降低周期性噪声。在此页面上,我们使用具有适当半径的陷波抑制滤波器来完全封闭傅里叶域中的噪声尖峰。陷波滤波器抑制中心频率附近预定义邻域中的频率。陷波滤波器的数量是任意的。缺口区域的形状也可以是任意的(例如矩形或圆形)。在此页面上,我们使用三个圆形陷波抑制滤光片。图像的功率谱致密化用于噪声尖峰的视觉检测。
源代码
您可以在 OpenCV 源代码库中找到源代码。samples/cpp/tutorial_code/ImgProc/periodic_noise_removing_filter/periodic_noise_removing_filter.cpp
#include #include "opencv2/highgui.hpp" #include #include using namespace cv; using namespace std; void fftshift(const Mat& inputImg, Mat& outputImg); void filter2DFreq(const Mat& inputImg, Mat& outputImg, const Mat& H); void synthesizeFilterH(Mat& inputOutput_H, Point center, int radius); void calcPSD(const Mat& inputImg, Mat& outputImg, int flag = 0); const string keys = "{help h usage ? | | print this message }" "{@image |period_input.jpg | input image name }" ; int main(int argc, char* argv[]) { CommandLineParser parser(argc, argv, keys); string strInFileName = parser.get("@image"); samples::addSamplesDataSearchSubDirectory("doc/tutorials/imgproc/periodic_noise_removing_filter/images"); Mat imgIn = imread(samples::findFile(strInFileName), IMREAD_GRAYSCALE); if (imgIn.empty()) //check whether the image is loaded or not { cout