How to add uniform noise to image with median and standard deviation
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mahabba Almheiri
am 15 Apr. 2021
Bearbeitet: Matt J
am 15 Apr. 2021
Hello..
what is the direct command for "uniform noise" with specific median and standard deviation, for example if the median =40 and the standard deviation=20 how can I write the noise command to add noise to the following code of original image:
I=imread('cameraman.tif');
original=imshow(I)
thank you
0 Kommentare
Akzeptierte Antwort
Matt J
am 15 Apr. 2021
Bearbeitet: Matt J
am 15 Apr. 2021
I've never heard of "noise" with non-zero mean/median, but generating it is straightforward,
delta=standardDeviation*sqrt(12);
noiseTerm = (rand(size(I))-1/2)*delta + Median;
I = I + noiseTerm;
You can also use unifrnd() if you have the Statistics and Machine Learning Toolbox.
noiseTerm = unifrnd(Median-delta/2 , Median+delta/2, size(I));
3 Kommentare
Matt J
am 15 Apr. 2021
Bearbeitet: Matt J
am 15 Apr. 2021
delta is the width of the uniform distribution, i.e., if the variable is distributed on the interval [a,b] then delta=b-a.
The sqrt(12) comes from the formula for the variance of a uniform random variable
variance=(b-a)^2/12
William Rose
am 15 Apr. 2021
@Mahabba Almheiri, @Matt J is right. IN case it is not obvious, what Matt is doing is scaling up the range foe the uniform noise so it will have the standard deviaiton you want it to have. Uniform noise that ranges from A to B (range=B-A) has a standard deviation
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/584976/image.png)
Like @Matt J, I don;t understand the use of "median" here. It is just adding a constant "brightness" to the whole image. Are you worried about negative values when you add noise?
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Histograms finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!