creating a frame(image), randn
2 views (last 30 days)
Show older comments
Hello,
Appreciate some quick help from you, my dear Matlab friends!
a = randn(20,20) + sqrt(3)*randn
imshow(a)
will create an image with 20x20 pixels, each pixel with the size 1x1. the values in the pixels are pseudo random number which are Gaussian with variance '3'.
Can i say that the pixel intensity of this image is shown in gray linear scale, assuming the value of the pixel is the pixel intensity?
0 Comments
Accepted Answer
David Young
on 13 Oct 2011
Your existing code will clip the pixel values at 0 and 1, so all the negative values are shown as black and all values greater than 1 as white. The intensity scale is therefore very much not linear.
Instead of imshow(a), use
imshow(a, []);
The pixel values will then be mapped to intensities approximately linearly (but only approximately, because it depends on the physical response of your screen and its associated electronics). The value nearest to -infinity will be displayed as black, and the value nearest to +infinity as white, with the other values distributed through the gray shades between.
You can also specify the mapping imshow uses with imshow(a, [blackval whiteval]) - see the documentation.
By the way, I don't think randn(20,20) + sqrt(3)*randn produces the distribution you describe. Do you perhaps mean sqrt(3)*randn(20,20)?
2 Comments
Image Analyst
on 13 Oct 2011
The second one is correct, for a mean of zero. Add the desired mean to shift it so that it has the desired mean. See the example in the help.
More Answers (0)
See Also
Categories
Find more on Fluid Dynamics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!