【问题标题】:how can i removing sinusoidal noise w\ frequency domain in opencv如何在opencv中去除正弦噪声w\频域
【发布时间】:2015-03-29 07:05:44
【问题描述】:

我正在尝试删除部分中的“5 行”,在音乐论文中,我的原始图像是这样的:http://en.wikipedia.org/wiki/Requiem_(Mozart)#/media/File:K626_Requiem_Mozart.jpg

首先,我应用高斯滤波器并使用阈值进行二值化(最小:100,最大 255)。 然后对该图像应用dft,擦除一些适当的线条,并通过逆dft重建图像。

我在 opencv 文档中使用示例代码,实际上我怀疑自己是否理解此代码。 :( http://docs.opencv.org/doc/tutorials/core/discrete_fourier_transform/discrete_fourier_transform.html

在此示例代码中,有 2 个垫子。一个是频谱的“complexI”,另一个是实际可视化的“magI”。 cv::dft 的结果是 complexI,magI 是归一化的 complexI。我的问题是这个。如何添加黑线(在频率域中取消)并重建?

【问题讨论】:

  • Gabor 过滤器可能会起作用。维基百科链接:en.wikipedia.org/wiki/Gabor_filter
  • 顺便说一句,“5 行”是正弦噪声吗?试试其他一些方法,比如腐蚀。
  • thunderstick,感谢您的回复。 “5 条线”不是完美的正弦噪声,但它是一种模式,可以通过傅立叶变换去除。那是我的主意。

标签: opencv image-processing dft noise-reduction


【解决方案1】:

OpenCV(现在)提供了关于如何通过频谱过滤处理周期性噪声的详细教程:https://docs.opencv.org/trunk/d2/d0b/tutorial_periodic_noise_removing_filter.html

这取决于使用 cv::dft()cv::idft()cv::mulSpectrums()cv::magnitude()

执行过滤的核心函数(来自教程)如下所示:

void filter2DFreq(const Mat& inputImg, Mat& outputImg, const Mat& H)
{
    Mat planes[2] = { Mat_<float>(inputImg.clone()), Mat::zeros(inputImg.size(), CV_32F) };
    Mat complexI;
    merge(planes, 2, complexI);
    // find FT of image
    dft(complexI, complexI, DFT_SCALE);

    Mat planesH[2] = { Mat_<float>(H.clone()), Mat::zeros(H.size(), CV_32F) };
    Mat complexH;
    merge(planesH, 2, complexH);
    Mat complexIH;

    // apply spectral filter
    mulSpectrums(complexI, complexH, complexIH, 0);

    // reconstruct the filtered image
    idft(complexIH, complexIH);

    split(complexIH, planes);
    outputImg = planes[0];
}

有关详细信息,请参阅教程。

【讨论】:

    猜你喜欢
    • 2017-07-05
    • 2014-05-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-03
    相关资源
    最近更新 更多