Will someone help me with a script I am writing to create a video from multiple pictures

I am trying to make a code which will make a video from multiple pictures. I heard of Matlab about a month ago, and this is my third day in (im a noobie). I am using windows. This is what I have so far:
  1. vidObj = VideoWriter ('MeatLabVideoFrankenstein.mj2');
  2. vidObj.FrameRate = 5;
  3. open (vidObj);
  4. files = dir ('*jpg');
  5. for k = 1:numel(files);
  6. rgb = imread(files(k).name);
  7. currFrame = getframe (gcf);
  8. image (1424,2144,3);
  9. cmap = colormap;
  10. writeVideo (vidObj,currFrame);
  11. end
  12. close (vidObj);
The size of the photos I am attempting to process are 1424 pix by 2144 pix and i am trying to set this script up to process various files rather than just one file. I have no idea where I am going wrong. If anyone has any suggestions on how to get this script up and running that would be nice. If I just need to scrap my currnet approach please let me know, pref. with a suggestion of a new direction.

4 件のコメント

Image Analyst
Image Analyst 2013 年 4 月 13 日
Don't number your lines and double space them. It makes it hard to copy and paste your code into MATLAB. Learn how to properly format your code here: http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup
Curtis
Curtis 2013 年 4 月 15 日
Thanks for the constructive criticism. I will remember that for future posts. However, if someone out there were to help me with the problem at hand instead of a copy past formating problem that takes an extra 10 seconds of time to correct in matlab that would be nice too.
Thanks.
Matt Kindig
Matt Kindig 2013 年 4 月 15 日
Did you see my response below? Have you tried it?
Curtis
Curtis 2013 年 4 月 15 日
編集済み: Curtis 2013 年 4 月 15 日
No I had not, thank you. I will be trying it shortly.

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

 採用された回答

Matt Kindig
Matt Kindig 2013 年 4 月 12 日
The major issue that I see if that you are calling image() with a size, rather than the actual data (rgb). Try this:
vidObj = VideoWriter('MeatLabVideoFrankenstein.mj2');
vidObj.FrameRate = 5;
open (vidObj);
files = dir('*.jpg');
for k = 1:numel(files);
rgb = imread(files(k).name);
currFrame = getframe (gcf);
image(rgb);
cmap = colormap;
writeVideo(vidObj,currFrame);
end
close(vidObj);

1 件のコメント

Curtis
Curtis 2013 年 4 月 15 日
The correction worked perfectly, Thank you very much!

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

その他の回答 (0 件)

製品

Community Treasure Hunt

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

Start Hunting!

Translated by