The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: randn repeating itself
Replies: 3   Last Post: Mar 29, 2013 5:36 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Bruno Luong

Posts: 9,822
Registered: 7/26/08
Re: randn repeating itself
Posted: Mar 29, 2013 5:36 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Nicholas" wrote in message <kj0jon$9ec$>...

> 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.5375e-12.

So yeah, you might run the loop 20 times, and chance that you still get the same image. Perfectly conform to the expectation.


Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.