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?

采纳的回答

David Young
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 个评论
PChoppala
PChoppala 2011-10-13
Thanks about imshow(a, ([]))
I need to create a frame with 20x20 pixels, size of each pixel to be 1x1 and a standard deviation of sigma = 3. Its Gaussian in nature. So I thought,
a = randn(20,20) + sqrt(3)*randn
imshow(a, ([]))
would work!
Is that wrong?
Is, a = sqrt(3) * randn(20,20) correct?
Image Analyst
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 个)

类别

Help CenterFile Exchange 中查找有关 Fluid Dynamics 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by