Hi I want to create an 30 frames of images with each image having 20*20 pixels. I would also want to access the grey scale level of each pixel. Please help me out with this Thanx

 Risposta accettata

PChoppala
PChoppala il 9 Ott 2011

0 voti

And also, I want to set a threshold \gamma = 2, and find which value of the pixels cross the threshold, for each frame

3 Commenti

Image Analyst
Image Analyst il 9 Ott 2011
Explain in more detail what "find which value of the pixels cross the threshold." Do want their x,y coordinates? Do you want a histogram of all pixels values > threshold? If you don't say then all I can tell you is "the value is > 2."
PChoppala
PChoppala il 9 Ott 2011
I want to access the intensity of each pixel, and find those pixels whose intensity cross the threshold '2'
Image Analyst
Image Analyst il 10 Ott 2011
Hmmm... that was not a clarification. So I'll just say the intensity of each pixel is imageArray(row, column). And the rows and columns can be found using [rows columns] = find(imageArray > 2). Regarding "those pixels whose intensity cross...": What pixels are those? A pixel has one single intensity - it's intensity does not "cross" anything. You'd have to be talking about a group of pixels to talk about the intensity crossing anything, like the boundary where the pixels are now >2 and where on the other side of the boundary they are <=2. Perhaps some careful decisions about what terms you use could help describe your situation better.

Accedi per commentare.

Più risposte (1)

Walter Roberson
Walter Roberson il 9 Ott 2011

0 voti

How have you stored the 30 frames ?
Probably the easiest way would be to store them as a 3D array indexed at Row, Column, and FrameNumber.

7 Commenti

PChoppala
PChoppala il 9 Ott 2011
I used
image = randn([20 20]);
imshow(image)
to generate one frame.
I want to generate 30 consecutive frames with each pixel size to be 1*1, number of pixels = 20*20, framerate = 1sec, standard deviation = 3, blurring = 0.7
Can you help me out in this specification?
I had not saved the image. I need to generate it randomly at each run.
thanks
Walter Roberson
Walter Roberson il 9 Ott 2011
You have a problem: randn() can generate indefinitely large positive or negative numbers. rand([20 20]) would generate an _average_ of 200 negative numbers.
I'm not sure what your "standard deviation = 3" refers to. Perhaps it means you are truncating the distribution at 3 standard deviations. That helps with not having to deal with extreme values, but you still end up with negative values, and the locations that you cut off at will end up with higher probability than would otherwise be expected.
But perhaps the standard deviation of 3 refers to the blurring ?
What kind of blurring? Gaussian?
If you go through and construct the series of steps to generate _one_ image with the required specifications, we can help you convert that to construct 30.
PChoppala
PChoppala il 9 Ott 2011
Hi
New to image processing, and hence facing some challenges.
Yeah, blurring is Gaussian and 0.7!
well, I think,
a = rand(20,20)
imshow(a)
looks pretty much as to what I am expecting from from frame.
From this I want to generate 30 consecutive frames with time steps.
But this statement does not allow me to control the number of pixels, size of the pixel, blurring etc?
Can you advise what would be a good start?
Walter Roberson
Walter Roberson il 9 Ott 2011
rand(M,N) generates M x N pixels. Each pixel is 1 unit by 1 unit.
See this discussion for gaussian blurring:
http://www.mathworks.com/matlabcentral/newsreader/view_thread/170165
You can store the frames in a mov struct, which is a structure array indexed at the frame number, with each entry having a field named 'cdata' and another named 'map'. You would leave 'map' as the empty array, and you would would store the frame data (the blurred version of "a") in the cdata field.
Once you have that, you could use mov2avi() to construct a .avi file.
See also the new VideoPlayer class.
PChoppala
PChoppala il 9 Ott 2011
Walter
so, do you way rand(20,20) is correct?
now i used
a = rand(20,20)
a = imnoise(a,'gaussian',3)
imshow(a)
so, that created a image with each pixel having 1x1 size, 20x20 pixels, variance of zero mean Gaussian noise = 3.
How to add blurring?
Grey scale level ranges from 0-255 right? But for the above command, each pixel has a value between 0-1. I still don't understand whether its a gray scale image or not?
What's the command to create 30 consecutive frames?
Thanks
PChoppala
PChoppala il 10 Ott 2011
rand(20,20) is not correct....
Image Analyst
Image Analyst il 10 Ott 2011
So multiply by 255 and cast to uint8. By the way, an image does not have to be in the range 0-255. That's just for 8 bit unsigned gray level images, but you can have 16 bit integer images, floating (double) point images, etc.

Accedi per commentare.

Categorie

Scopri di più su Convert Image Type in Centro assistenza e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by