【发布时间】:2022-04-04 20:06:59
【问题描述】:
我想应用我在标题中命名的降噪滤波器,它基于以下等式:
其中d = 1 是一个标量常数扩散参数,I(x, y) 是初始噪声图像,u(x, y, t) 是在扩散时间t 之后获得的图像5, 10 and 30。但是,为了在 OpenCV 中实现这一点,我对使用哪个函数以及如何使用感到很困惑。我觉得这很简单,但由于某种原因我很困惑。有人有想法吗?
这是一个示例图像:
然后我想将其与高斯过滤方法进行比较,该方法根据以下内容:
其中G√2t (x, y) 是高斯核。这证明了用t 和d = 1 执行一段时间的各向同性线性扩散完全等同于用σ = √(2t) 执行高斯平滑
我有一个应用高斯滤波的函数:
void gaussian_2D_convolution(const cv::Mat& src, cv::Mat& dst, const float sigma, const int ksize_x = 0, const int ksize_y = 0)
{
int ksize_x_ = ksize_x, ksize_y_ = ksize_y;
// Compute an appropriate kernel size according to the specified sigma
if (sigma > ksize_x || sigma > ksize_y || ksize_x == 0 || ksize_y == 0)
{
ksize_x_ = (int)ceil(2.0f*(1.0f + (sigma - 0.8f) / (0.3f)));
ksize_y_ = ksize_x_;
}
// The kernel size must be and odd number
if ((ksize_x_ % 2) == 0)
{
ksize_x_ += 1;
}
if ((ksize_y_ % 2) == 0)
{
ksize_y_ += 1;
}
// Perform the Gaussian Smoothing
GaussianBlur(src, dst, Size(ksize_x_, ksize_y_), sigma, sigma, BORDER_DEFAULT);
// show result
std::ostringstream out;
out << std::setprecision(1) << std::fixed << sigma;
String title = "sigma: " + out.str();
imshow(title, dst);
imwrite("gaussian/" + title + ".png", dst);
waitKey(260);
}
但我在实施第一种情况时遇到了困难。
【问题讨论】:
标签: opencv filtering smoothing