Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.



Re: randn repeating itself
Posted:
Mar 29, 2013 5:36 PM


"Nicholas" wrote in message <kj0jon$9ec$1@newscl01ah.mathworks.com>...
> im = imread('lena.tif'); > for i = 1:20 > % add 10% noise > x = 0.1*randn(size(im)) + im; > y = 0.1*randn(size(im)); > noisy = sqrt(x.^2 + y.^2); > % image processing % > end
Wasn't the variable im is of class uint8?
When you add mixed types, e.g., uint8 and double, matlab cast to lower type, i.e. uint8.
In order to get the resultant x different than im, you must have the noise  randn(x)  > 0.5.
The probability for that event to happens is:
P = erfc(0.5/0.1) = 1.5375e12.
So yeah, you might run the loop 20 times, and chance that you still get the same image. Perfectly conform to the expectation.
Bruno



