How do I read in an AVI frame and save it to an image file in MATLAB?
10 ビュー (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2009 年 6 月 27 日
I would like to process each frame of an AVI file separately. I would like to know how to access the individual frames, what image type I can save these frames in, and if I will have to save the AVI file as something different before I open it in MATLAB.
採用された回答
MathWorks Support Team
2009 年 6 月 27 日
Accessing the individual AVI frames is not difficult and can be done in just a few short commands. As far as file types for the images, you can save in whatever file format that imwrite supports in your version of MATLAB.
Take for example an AVI-file called "clock.avi":
% READ THE AVI
mov=aviread('clock.avi');
% GRAB A SINGLE FRAME
[im1,map] = frame2im(mov(1));
% SHOW THE FRAME
imshow( im1 );
% SET THE COLORMAP PROPERLY SO THE IMAGE SHOWS CORRECTLY
colormap( map );
% WRITE OUT THE FRAME TO A BMP FILE
imwrite(im1,map,'clockFrame1.bmp');
For more details, see the documentation of the AVIREAD, FRAME2IM, IMSHOW, and IMWRITE functions used above.
1 件のコメント
Eric
2017 年 4 月 21 日
As of R2014b, "aviread" should be changed to "VideoReader". Also, I believe the VideoReader object cannot be indexed to obtain a frame, but rather readFrame(vidObj) must be called. See MATLAB's examples on reading video files.
その他の回答 (0 件)
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!