Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Add gaussian noise

Subject: Add gaussian noise

From: mayan mayan

Date: 5 Nov, 2010 13:56:03

Message: 1 of 10

I am trying add Gaussian noise to image with 10db using i imnoise(I,'gaussian',0,1) function in matlap.
Please could anyone help me to do this ?

Subject: Add gaussian noise

From: Sean

Date: 5 Nov, 2010 14:10:06

Message: 2 of 10

"mayan mayan" <mayan_n@yahoo.com> wrote in message <ib12dj$4fg$1@fred.mathworks.com>...
> I am trying add Gaussian noise to image with 10db using i imnoise(I,'gaussian',0,1) function in matlap.
> Please could anyone help me to do this ?

So what's the problem?

Subject: Add gaussian noise

From: mayan mayan

Date: 5 Nov, 2010 15:38:03

Message: 3 of 10

"Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <ib137u$sqp$1@fred.mathworks.com>...
> "mayan mayan" <mayan_n@yahoo.com> wrote in message <ib12dj$4fg$1@fred.mathworks.com>...
> > I am trying add Gaussian noise to image with 10db using i imnoise(I,'gaussian',0,1) function in matlap.
> > Please could anyone help me to do this ?
>
> So what's the problem?
Hi
I have to add 10db. please can you tell me how to use this function to set '10db'

Subject: Add gaussian noise

From: mayan mayan

Date: 5 Nov, 2010 16:50:04

Message: 4 of 10


"mayan mayan" <mayan_n@yahoo.com> wrote in message <ib18cr$ekl$1@fred.mathworks.com>...
> "Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <ib137u$sqp$1@fred.mathworks.com>...
> > "mayan mayan" <mayan_n@yahoo.com> wrote in message <ib12dj$4fg$1@fred.mathworks.com>...
> > > I am trying add Gaussian noise to image with 10db using i imnoise(I,'gaussian',0,1) function in matlap.
> > > Please could anyone help me to do this ?
> >
> > So what's the problem?
> Hi
> I have to add 10db. please can anyone tell me how to use this function to set '10db'
i used this code ?
A=imread('x.bmp');
  db=10.0;
   I1=double(A);
    I2=zeros(size(I1));
    s_std=std(I1(:));
  n_std=s_std/10^(db/20); % noise standard deviation
   J=n_std*(imnoise(I2,'gaussian',0,1));
   J2=I1+J;

Subject: Add gaussian noise

From: ImageAnalyst

Date: 5 Nov, 2010 17:08:49

Message: 5 of 10

So does the pixel value represent the amplitude or the power?
Since decibels (http://en.wikipedia.org/wiki/Decibel) is 20 *
log10(amplitude ratio) or 10 * log10(power ratio) you need to know how
to calculate the ratio. (If it's power, 10 dB = 20log10(P/255) so a
gray level of 806.38 would be the amount of noise on a pixel with
power gray level 255, if I'm doing the math correctly.) But an image
has lots of gray levels in it, not just 255, so the noise level for a
1 dB noise would be different for different gray levels. Do you need
up to, or exactly, 10 dB on each pixel, or just 10 dB for the whole
image averaged over all pixels, even if some pixels have more or less
than 10 dB?

Subject: Add gaussian noise

From: mayan mayan

Date: 8 Nov, 2010 11:50:06

Message: 6 of 10

(1) I am planning to have upto 10 dB noise on each pixel.
Does this code give that result?
A=imread('x.bmp');
  db=10.0;
   I1=double(A);
    I2=zeros(size(I1));
    s_std=std(I1(:));
  n_std=s_std/10^(db/20); % noise standard deviation
   J=n_std*(imnoise(I2,'gaussian',0,1));
   J2=I1+J;

(2) In your reply you have 10*log10(power ratio), but in your example
for power you use 10 dB = 20log10(P/255). Why does 10 become 20?

(3) If I said I like to add 10 dB noise, surely I should see a picture with
a lot more snow than the picture that has 2 dB noise. According to the
formula which involves the reciprocal of 10^(db/20) - this means that
larger value of db in it gives smaller result, hence the noise SD produced
is smaller. Do I understand this correctly?


ImageAnalyst <imageanalyst@mailinator.com> wrote in message <5a5a81c8-1623-4eaa-a848-d11d078a5797@o2g2000vbh.googlegroups.com>...
> So does the pixel value represent the amplitude or the power?
> Since decibels (http://en.wikipedia.org/wiki/Decibel) is 20 *
> log10(amplitude ratio) or 10 * log10(power ratio) you need to know how
> to calculate the ratio. (If it's power, 10 dB = 20log10(P/255) so a
> gray level of 806.38 would be the amount of noise on a pixel with
> power gray level 255, if I'm doing the math correctly.) But an image
> has lots of gray levels in it, not just 255, so the noise level for a
> 1 dB noise would be different for different gray levels. Do you need
> up to, or exactly, 10 dB on each pixel, or just 10 dB for the whole
> image averaged over all pixels, even if some pixels have more or less
> than 10 dB?

Subject: Add gaussian noise

From: ImageAnalyst

Date: 8 Nov, 2010 13:34:52

Message: 7 of 10

For #2, that was my mistake.

I'm not an expert with decibels - I deal with noise in terms of gray
levels - so anything I say might be incorrect so I think you should
wait for someone to answer who is more knowledgeable about decibels.
But they will still probably want you to answer the last question in
my earlier response.

Subject: Add gaussian noise

From: Cris Luengo

Date: 8 Nov, 2010 17:34:03

Message: 8 of 10

"mayan mayan" <mayan_n@yahoo.com> wrote in message <ib8o5e$39p$1@fred.mathworks.com>...
> (1) I am planning to have upto 10 dB noise on each pixel.
> Does this code give that result?
> A=imread('x.bmp');
> db=10.0;
> I1=double(A);
> I2=zeros(size(I1));
> s_std=std(I1(:));
> n_std=s_std/10^(db/20); % noise standard deviation
> J=n_std*(imnoise(I2,'gaussian',0,1));
> J2=I1+J;

A = double(imread('x.bmp'));
S2 = sum(A(:)^2); % signal power
N2 = S2*10^(db/10); % noise power
B = imnoise(A,'gaussian',0,N2); % add noise to image

> (2) In your reply you have 10*log10(power ratio), but in your example
> for power you use 10 dB = 20log10(P/255). Why does 10 become 20?

It is 10*log10(power ratio) = 10*log10(N^2/S^2) = 20*log10(N/S), with
S^2 the signal power and N^2 the noise power. Noise power is the
noise variance. Signal power can be approximated by the signal
variance if your signal has no DC component. If it does, the variance
ignores this component.

Sometimes people use 255^2 as the signal power. This is silly, IMO.

> (3) If I said I like to add 10 dB noise, surely I should see a picture with
> a lot more snow than the picture that has 2 dB noise. According to the
> formula which involves the reciprocal of 10^(db/20) - this means that
> larger value of db in it gives smaller result, hence the noise SD produced
> is smaller. Do I understand this correctly?

I think there was a confusion between noise level in dB and signal to noise ratio (SNR) in dB. SNR is the inverse of noise level: SNR = 10*log10(S^2/N^2).

Cheers,
Cris.

Subject: Add gaussian noise

From: Cris Luengo

Date: 9 Nov, 2010 08:53:04

Message: 9 of 10

"Cris Luengo" <cris.luengo@google.for.my.name.to.contact.me> wrote in message <ib9cab$9kl$1@fred.mathworks.com>...
> A = double(imread('x.bmp'));
> S2 = sum(A(:)^2); % signal power
> N2 = S2*10^(db/10); % noise power
> B = imnoise(A,'gaussian',0,N2); % add noise to image

That should have been
   S2 = mean((A(:).^2);

Subject: Add gaussian noise

From: Dodoo

Date: 11 Jun, 2012 01:49:57

Message: 10 of 10

i used SNR = 20log(signal mean / noise standard deviation)
but i'm not sure about that........


--
http://compgroups.net/comp.soft-sys.matlab/add-gaussian-noise/411106

--http://compgroups.net/comp.soft-sys.matlab/add-gaussian-noise/411106

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us