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
2010-10-09 06:08:56
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
2010-10-10 15:43:19
Is `image` or `imshow` not enough for you? Or explain what do you mean "show the content"?
yuk
2010-10-10 17:59:15
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
2010-10-10 23:47:05
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
2010-10-11 04:24:46
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
2010-10-11 06:57:08
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
2010-10-11 07:11:06
Thanks for your help yuk!
appi
2010-10-11 08:28:49