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

问题描述

我正在着名的上学习图像处理,并谈论图像修复很多例子都是用计算机生成的噪音(高斯,盐和胡椒等)完成的。在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的脉冲,高斯和盐和胡椒噪音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 16:07