7. out_of_focus_deblur_filter.cpp使用维纳滤波器来恢复失焦的图像
代码的主要功能是通过使用维纳滤波器来恢复失焦的图像,它读取一个灰度图像文件,对其进行滤波操作,并将结果保存为新文件。这个过程包括计算点扩散函数(PSF),执行FFT变换,应用滤波器,然后完成逆FFT变换。这些步骤都在main函数中进行,并在帮助函数中分别解决。
/**
* @brief 你将了解如何通过维纳滤波器恢复失焦的图像
* @author Karpushin Vladislav, karpushin@ngs.ru, https://github.com/VladKarpushin
*/
// 导入所需的库和模块
#include <iostream>
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/imgcodecs.hpp"
// 声明使用的命名空间
using namespace cv;
using namespace std;
// 声明函数原型
void help();
void calcPSF(Mat& outputImg, Size filterSize, int R);
void fftshift(const Mat& inputImg, Mat& outputImg);
void filter2DFreq(const Mat& inputImg, Mat& outputImg, const Mat