views:

45

answers:

1

Hi. I'm trying to figure out how to use cdata under Movie function in MATLAB. Can any expert please give me a short explanation? Thank you!

+1  A: 

As you can find in the MOVIE function documentation, it plays a movie, which is actually an array of frames. Frame in its turn is a single "shot", or still image, represented in MATLAB by a structure with fields cdata (matrix of pixels data) and colormap (if used).

You can create a frame from current figure with GETFRAME function: F = getframe;. F.cdata will be an image matrix H x W x 3, with 3rd dimension representing 3 color channels - red, green and blue. You can show it with image(F.cdata) command.

If M is a movie frames, you can show just the first frame with image(M(1).cdata).

I would recommend you to play with examples on the MOVIE and GETFRAME help pages to have a better inderstanding.

yuk
Hi yuk. Thanks for your explanation. It was quite clear. But I got a bit difficulty over here. How do I show the content of cdata so that I can do further manipulation?
appi
Is `image` or `imshow` not enough for you? Or explain what do you mean "show the content"?
yuk
okay. Im trying to use movie function to read a yuv video clip and store the data. Do you think the following piece of program will work?for k=1:nFrames mov(l).cdata=loadFileYuv(...) end the loadFileYuv function can be found over here http://stackoverflow.com/questions/3887494/how-to-extract-y-u-and-v-components-from-a-given-yuv-file-using-matlab-each-com
appi
I've used `loadFileYuv` from your other previous questions: http://stackoverflow.com/questions/3614441/how-to-extract-frames-from-yuv-420-video-clip-and-store-them-as-different-images. If you run `mov = loadFileYuv(file, 176, 144, 1:nFrames);` you will get variable that you can use directly in `movie` function. To access individual frames `imshow(mov(i).cdata)`.
yuk
Thanks yuk! That really works! Now I'm working on how to separate the y,u,v components in a single frame. Thanks again!
appi
Check my answer to your question http://stackoverflow.com/questions/3887494/how-to-extract-y-u-and-v-components-from-a-given-yuv-file-using-matlab-each-com. Also if an answer is helpful to you please consider upvoting and don't forget to accept the best answer.
yuk
Thanks for your help yuk!
appi

related questions