汉宁窗作用:
代码:
#include <iostream>
#include "opencv2/highgui.hpp"
#define PI 3.1415926
cv::Mat CreatHannWindow(int width, int height)
{
cv::Mat vertical(height, 1, CV_32FC1);
cv::Mat horizontal(1, width, CV_32FC1);
for (int r = 0; r < height; r++)
{
vertical.at<float>(r, 0) = 0.5 - 0.5 * cos(2 * PI * r / (height - 1));
}
for (int c = 0; c < width; c++)
{
horizontal.at<float>(0, c) = 0.5 - 0.5 * cos(2 * PI * c / (width - 1));
}
cv::Mat out = vertical * horizontal;
return out;
}
int main()
{
cv::Mat out = CreatHannWindow(200, 200);
return 1;
}
得到的汉宁窗效果: