简体   繁体   English

OpenCV:去噪图像/视频帧

[英]OpenCV: Denoising image / video frame

I want to denoise a video using OpenCV and C++.我想使用 OpenCV 和 C++ 对视频进行降噪。 I found on the OpenCV doc site this:我在 OpenCV 文档网站上找到了这个:

fastNlMeansDenoising(contourImage,contourImage2);

Every time a new frame is loaded, my program should denoise the current frame (contourImage) and write it to contourImage2.每次加载新帧时,我的程序应该对当前帧(contourImage)进行降噪并将其写入contourImage2。

But if I run the code, it returns 0 and exits.但是如果我运行代码,它会返回 0 并退出。 What am I doing wrong or is there an alternative way to denoise an image?我做错了什么还是有另一种去噪图像的方法? (It should be fast, because I am processing a video) (应该很快,因为我正在处理视频)

while you are using c++ you are not providing the full argument try this that way.当您使用 c++ 时,您没有提供完整的参数,请尝试这种方式。

cv::fastNlMeansDenoisingColored(contourImage, contourImage2, 10, 10,7, 21);

// This is Original Function to be used.
cv::fastNlMeansDenoising(src[, dst[, h[, templateWindowSize[,     searchWindowSize]]]]) → dst

Parameters:参数:
src – Input 8-bit 1-channel, 2-channel or 3-channel image. src – 输入 8 位 1 通道、2 通道或 3 通道图像。
dst – Output image with the same size and type as src . dst – 与 src 具有相同大小和类型的输出图像。
templateWindowSize – Size in pixels of the template patch that is used to compute weights. templateWindowSize – 用于计算权重的模板补丁的大小(以像素为单位)。 Should be odd.应该是奇葩。 Recommended value 7 pixels.推荐值 7 像素。
searchWindowSize – Size in pixels of the window that is used to compute weighted average for given pixel. searchWindowSize – 窗口的像素大小,用于计算给定像素的加权平均值。 Should be odd.应该是奇葩。 Affect performance linearly: greater.线性影响性能:更大。
searchWindowsSize - greater denoising time. searchWindowsSize - 更长的去噪时间。 Recommended value 21 pixels.推荐值 21 像素。
h – Parameter regulating filter strength. h –调节过滤强度的参数。 Big h value perfectly removes noise but also removes image details, smaller h value preserves details but also preserves some noise大h值完美去除噪声但也去除图像细节,较小h值保留细节但也保留一些噪声

I was facing this problem recently as well.我最近也面临这个问题。 I learned that you need to crop the image into patches, each of about 500x500.我了解到您需要将图像裁剪成补丁,每个大约 500x500。 Then you need to denoise each patch and put it all together.然后你需要对每个补丁进行去噪并将它们放在一起。 This usually gets the most accurate results.这通常会得到最准确的结果。 Let me know if you need anything else需要帮助请叫我

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM