# imnoise gaussian variance vs normal variance?

5 visualizzazioni (ultimi 30 giorni)
Zhouyang Xu il 14 Mar 2021
Commentato: Zhouyang Xu il 17 Mar 2021
Dear MATLAB community,
I'm currently trying to understand the imnoise function, if I create an image of just ones and add gaussian noise of 1e^-4 to it, the variance of teh output image is not any where close to that value, it seems to have a corrolation of 0.34 times the gaussian variance in imnoise.
img = ones(500);
img = imnoise(img,"gaussian",0,1e-4);
var(img(:))
Would anyone be kind enough to explain this to me?
Thank you very much! Really appreciate your support!
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

Uday Pradhan il 17 Mar 2021
Hi,
So the formula for adding Gaussian noise to the image by "imnoise" is given by:
output = input + sqrt(v)*randn(size(input)) + mu; %v is the provided variance and mu the mean
output = max(0,min(output,1)); %truncating the output to the range [0,1]
Now, in the first line, we are drawing 500*500 random values from a normal distribution with a mean of "mu" and variance "v". The mean and variance of the drawn sample will not exactly be "mu" and "v" because they are calculated from a sampling of the distribution. Also, the variance of the output is affected by the truncation step.
You can check the variance of the added noise multiple times to observe how it varies from the user - input variance to imnoise, by using the above formula instead.
##### 1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
Zhouyang Xu il 17 Mar 2021
Thank you very much, that is very helpful

Accedi per commentare.

### Categorie

Scopri di più su Image Category Classification in Help Center e File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by