Gaussian Noise in emgucv

2019-05-23 01:16发布

问题:

How can I add gaussian noise ( with a particular mean and variance ) to an image using emgucv ?

回答1:

I'm not sure quite what your asking as a Gaussian filter tends to be there to remove noise. To use a custom kernel you can use the following code. If you wish to add noise with a set mean and variance then you may have to resort to looping through the my_image.Data property and add it that way. Here is the code for using a custom Kernel if it's not quite what your after let me know and I'll try and find something more appropriate a link to example images may be useful in this case.

Image<Bgr, Byte> my_image = new Image<Bgr, byte>(open.FileName);

float[,] k = { {0, 0, 0},
               {0, 0, -0},
               {0.33F, 0, -0}};

ConvolutionKernelF kernel = new ConvolutionKernelF(k);

Image<Bgr, float> convolutedImage = my_image * kernel;

pictureBox1.Image = convolutedImage.ToBitmap();

I Hope this Helps,

Chris