I want to add white gaussian noise to an image of 10 dB in Matlab.
I tried to use Matlab function imnoise but I couldn't figure out what values for mean and variance should I choose to add noise of 10 dB.
How do I do this ?
Signal Processing Stack Exchange is a question and answer site for practitioners of the art and science of signal, image and video processing. It only takes a minute to sign up.
Sign up to join this communityI want to add white gaussian noise to an image of 10 dB in Matlab.
I tried to use Matlab function imnoise but I couldn't figure out what values for mean and variance should I choose to add noise of 10 dB.
How do I do this ?
Additive noise is usually mean-free, i.e. the mean should be 0. A noise level of 10 dB = 1 B ("bel") usually means that the variance of the noise is by a factor 10¹ = 10 smaller than the variance of the image. As the documentation states, the variance parameter to imshow
is interpreted under the assumption that the image data are doubles in the range [0, 1].
Here's an example:
Load sample grayscale image included with Matlab:
[I, map] = imread('eight.tif');
That image is of data type uint8
, i.e. integers in the range 0 to 255. Let's convert it to a double in [0, 1]:
I = double(I) / 255;
Compute the image variance
v = var(I(:));
and tell imnoise
to add Gaussian white noise with mean 0 and a tenth of that variance:
J = imnoise(I, 'gaussian', 0, v / 10);
This is the result:
Because imnoise
clips the data to the range [0, 1] after adding noise, the actual noise variance is smaller,
var(J(:) - I(:)) / v
gives something like 0.093.
use y=wgn(m,n,p) command in matlab. it generates a mxn matrix of white Gaussian noise. p specifies the power of y in decibels relative to a watt.