1
我想通過opencv fastNlMeansDenoising()函數去除噪音。 但我的輸出圖像與原始噪聲圖像相同。fastNlMeansDenoising()不過濾掉噪音
輸入圖像:
代碼:
#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
using namespace std;
using namespace cv;
int main() {
Mat img = imread("noisy.jpg");
if (!img.data) {
cout << "File not found" << endl;
return -1;
}
// first copy the image
Mat img_gray = img.clone();
cvtColor(img, img_gray, CV_RGB2GRAY);
Mat img1;
//fastNlMeansDenoising(img_gray, img1, 3.0, 7, 21);
cv::fastNlMeansDenoising(img_gray, img1, 3.0, 7, 21);
imshow("img1", img1);
waitKey();
return 0;
}
輸出圖像:
我看不到任何平滑效果。我不明白它的原因。 請幫助我使用此功能來消除噪音。感謝
不知道它可能與你的問題,但你不必做'img.clone()'。 'cvtColor'會爲你創建輸出圖像。 – boaz001
我已更正它。但仍然輸出圖像不是去噪圖像。 – Abc