Error using movie command in Matlab
조회 수: 3 (최근 30일)
이전 댓글 표시
I generated multiple images which I converted into frames with im2frame in order to create a movie. I used this code:
for i = 10:20
images = sprintf('img%d.jpg',i);
ImageData = imread(images);
M(i) = im2frame(ImageData);
end
movie(M)
movie2avi(M,'sonar.avi','compression','None','fps',5,'quality',100)
When I run it, I get the following error:
Error using hgMovie
Movie contains uninitialized frames
Error in movie (line 41)
builtin('hgMovie',varargin{:});
Error in open83B_edited_2 (line 324)
movie(M)
Does anyone have a clue what might be wrong with my code? Thank you!
댓글 수: 0
채택된 답변
Geoff Hayes
2014년 5월 8일
Hi Adrian,
I was able to reproduce the same issue with your above code. The problem is how the M array is being updated. The for loop iterates from 10 to 20 and the code uses these iteration values to assign the frame to the array. This means that M becomes an array of 20 frames, with the first nine not initialized - hence the error.
You can try the following instead:
% use this index into M
idxInM = 1;
for i = 10:20
images = sprintf('img%d.jpg',i);
ImageData = imread(images);
M(idxInM) = im2frame(ImageData);
idxInM = idxInM + 1;
end
Or any other mechanism that allows you to control how M is updated at each iteration.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Convert Image Type에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!