本文介绍了OpenCV 的脉冲、高斯和椒盐噪声的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在著名的 Gonzales "Digital图像处理" 和谈论图像恢复的很多例子都是用计算机生成的噪声(高斯、盐和胡椒等)完成的.在 MATLAB 中有一些内置函数可以做到这一点.OpenCV 怎么样?

I'm studying Image Processing on the famous Gonzales "Digital Image Processing" and talking about image restoration a lot of examples are done with computer-generated noise (gaussian, salt and pepper, etc). In MATLAB there are some built-in functions to do it. What about OpenCV?

推荐答案

据我所知,没有像 Matlab 那样方便的内置函数.但只需几行代码,您就可以自己创建这些图像.

As far as I know there are no convenient built in functions like in Matlab. But with only a few lines of code you can create those images yourself.

例如加性高斯噪声:

Mat gaussian_noise = img.clone();
randn(gaussian_noise,128,30);

椒盐噪声:

Mat saltpepper_noise = Mat::zeros(img.rows, img.cols,CV_8U);
randu(saltpepper_noise,0,255);

Mat black = saltpepper_noise < 30;
Mat white = saltpepper_noise > 225;

Mat saltpepper_img = img.clone();
saltpepper_img.setTo(255,white);
saltpepper_img.setTo(0,black);

这篇关于OpenCV 的脉冲、高斯和椒盐噪声的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 10:00