Movie via Frames from Loaded Images

2 ビュー (過去 30 日間)
Kate Godwin
Kate Godwin 2011 年 8 月 15 日
I am trying to design a basic visual stimulus (full-field vertical grating with contrast reversal), but am very new to MATLAB. I have created the images I want to use as frames and saved them as jpegs, but when I have tried to use the code to turn these into a movie, I just get a gray screen as my result. If anyone sees what I am doing wrong, I would greatly appreciate any help/guidance.
Here is my code:
reruns = 10;
fps = 4;
nframes = 2;
Frames = moviein(nframes);
load VerticalBars1.jpg
Frames(:,1) = getframe;
load VerticalBars2.jpg
Frames(:,2) = getframe;
movie(Frames, reruns, fps)
Thanks so much in advance for any help you can provide!

採用された回答

Kate Godwin
Kate Godwin 2011 年 8 月 15 日
Ah, that did seem to help some - thanks! Unfortunately, though, when I repeat the same commands for my second frame (I only have 2 total), the movie I end up with only shows the first frame correctly, and a gray screen for the other. All I changed in my second frame was the file name and the end to "Frames(:,2) = getframe" since I figured the rest of the commands should stay the same. Am I wrong in that assumption, though?
  4 件のコメント
Kate Godwin
Kate Godwin 2011 年 8 月 18 日
I have been looking around for the code for this kind of animation for a while, but this is the first time I have seen it written like this. Do you have any MATLAB imaging resources (books, websites, anything) that you would recommend to gain proficiency in this area?
Walter Roberson
Walter Roberson 2011 年 8 月 18 日
Sorry, by the time I get "images" in my work, they have been converted to datasets and features extracted and so on, so I just get feature vectors to classify that might have come from anything. I have not done any animation work since before 1980, and most of what I know about "image processing" has come from reading what Image Analyst has written and seeing how he solves problems.
Techniques such as reading images directly in to a Frames structure are, to me, merely routine data structure manipulations based upon experience.

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2011 年 8 月 15 日
load() of an image does not display it on the screen for getframe() to be able to operate on it.
Also, it is better to imread() than to load() when you are working with images.
[img, immap] = imread('VerticalBars1.jpg');
image(img);
if ~isempty(immap); colormap(immap); end
Frame(:,1) = getframe;
and so on.

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by