Impulse, gaussian and salt and pepper noise with OpenCV

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.

For example additive gaussian noise:

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

Salt and pepper noise:

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);

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)