exponential noise
9 views (last 30 days)
Show older comments
hi
im new to image processing. i was trying to generate a matrix with random variables of exponential type(to model exponential noise). i used the cdf to generate them.
k=-1/a;
R=k*log(1-rand(M,N));
my image is 256X256 sized, 0-255 grayvalued. problem is, no matter what values I give for 'a'(from .00001 to 10000), and compute R(which is my additive noise matrix), and then add it to my image I, I always get a full white image.i cant see even a speck of black?why is that? what values should i give?
0 Comments
Answers (1)
Walter Roberson
on 6 Jun 2011
Could you show the code you use?
log(1-rand(M,N)) would have rand() at least 2^(-53) and at most 1-2^(-53). 2^(-53) is more easily expresed as eps(1/2). Because of the 1 minus, the lowest rand() value translates to log(eps(1/2)) and the highest rand() value translates to log(1-eps(1/2)). Effectively the 1 minus step is wasted here.
log(eps(1/2)) is about -36 and log(1-eps(1/2)) is about -1E-16 . Your k is -1/a so the signs will be flipped, leading to one end being (1E-16)/a and the other end being 36/a . Which is larger will depend on whether a is less than 1 or greater. If a is greater than 72, then 36/a would be less than 1/2 (and (1E-16)/a much less still); when that is added to a uint8 value and the result converted back to a uint8 value, there would be no change. Unless, of course, you added it to the uint8 value an came up with a floating point result, in which case any value from 1 or higher would saturate as white. (hint hint)
If your a are much less than 1, even the 1E-16 would get magnified substantially. And if you have the double vs uint8 result as described above...
In short, you likely have a data type conversion problem.
5 Comments
Walter Roberson
on 13 Jun 2011
When you do the imadd(), is the image being added to uint8 data class? Is the result of imadd() still uint8 data class? What is the minimum and maximum values of the image after addition?
If the added image ended up being floating point, then as you have indicated that the minimum R is 30, every value after the addition would be at least 30, and so all of those floating point values would be greater than 1. The maximum value permitted for a floating point image is 1; everything beyond that is clamped to 1. The result would be an all-white image just like you are seeing, if you display the result using image() or imshow(). If you display the result using imagesc() you would see differences.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!