How do I read in an AVI frame and save it to an image file in MATLAB?

10 Ansichten (letzte 30 Tage)
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.

Akzeptierte Antwort

MathWorks Support Team
MathWorks Support Team am 27 Jun. 2009
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 Kommentar
Eric
Eric am 21 Apr. 2017
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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Images finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by