採用された回答

Sean de Wolski
Sean de Wolski 2011 年 6 月 21 日

0 投票

A = 20; %amplitude of 10 - noise
noise = (rand(size(I))-.5)*A);
Inoisy = I+noise;

5 件のコメント

Walter Roberson
Walter Roberson 2011 年 6 月 21 日
Hmmm, that noise would be +/- (A/2), which would be floating point numbers. If I is an unsigned integer data class then the values that might dip below zero would be clipped at 0, which would distort the statistical noise characteristics.
Seems to me that Patan should specify the variety of noise involved.
Walter Roberson
Walter Roberson 2011 年 6 月 21 日
e.g., noise is often not uniformly distributed.
Gova ReDDy
Gova ReDDy 2011 年 6 月 21 日
for random noise.......
Gova ReDDy
Gova ReDDy 2011 年 6 月 21 日
What 0.5 and A represents...And which of them represents how much noise added in uints
Walter Roberson
Walter Roberson 2011 年 6 月 21 日
There are an infinite number of different random noise distributions that can be used, and you need to decide whether the noise is additive or multiplicative, and you need to decide whether noise can ever reduce the value of a pixel, and you need to decide whether your noise "overwrites" pixels instead of adding or multiplying them.
In Sean's formula above, A is the peak-to-peak spread of the uniformly distributed noise generated.
Sean's formula is for noise which is uniformly randomly distributed between -A/2 and +A/2 (a total spread of A). Each uniformly distributed random number from rand() is in the range 0 to 1, so subtracting 0.5 from those values translates the range to -0.5 to +0.5; the multiplication by A scales that to -A/2 to +A/2 .
If it would make things clearer for you, Sean's code can be rewritten as
A = 10; %maximum noise amplitude
noise = (2 * rand(size(I)) - 1) * A;
Inoisy = I + noise;
That is, 0 to +1 gets magnified to 0 to +2, which gets translated to -1 to +1 and that gets multiplied by A to scale it to the desired magnitude.
The code would differ for normally distributed noise. (And caution: normally distributed noise can range from -infinity to +infinity in theory.)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeRandom Number Generation についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by