creating a frame(image), randn
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
David Young
2011-10-13
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 个评论
Image Analyst
2011-10-13
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.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!