Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


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

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: 8,813
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$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.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.

Bruno



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

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.