フィルターのクリア

mpeg file

7 ビュー (過去 30 日間)
James
James 2011 年 7 月 19 日
Hi
I have two task that are similar that I dont know how to do:
1 - I want to be able to import an mpeg video and save each frame of this movie as individual images into a folder.
2 - Also, I want to be able to create an mpeg video given a number of individual images saved in a folder.

回答 (2 件)

Walter Roberson
Walter Roberson 2011 年 7 月 19 日
If you have a new enough MATLAB version, you could perhaps us the VideoReader class; older versions called it the mmreader. Extract frame by frame and use imwrite(). See http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F for information on automatic filename generation for such purposes.
Given a series of frames read in by imread() (in conjunction with dir() to find the file names), you can use the VideoWriter() class to produce a .avi .

James
James 2011 年 7 月 20 日
Sorry I need further help...
For task 1: - I have imported the mpeg video using:
object = mmreader('train.mpg')
and I know how to scroll through each frame using:
for i=1:NumberOfFrames
read(object,i)
end
But how do I save this frame as a jpg?
  11 件のコメント
James
James 2011 年 7 月 21 日
Hi
It seems when I double()a frame I still have the same numbers, which is not what you are saying?! However, when I use im2double() then I do get numbers between 0 and 1.
Walter Roberson
Walter Roberson 2011 年 7 月 21 日
Yes, double() keeps the same numeric values, such as uint8(42) becoming the double precision number 42.0. That is fine for some kinds of computations, but if you try to display or imwrite() a double precision array with such values you will have problems, as the expected range for representing graphics in double precision variables is 0 to 1. im2double() converts the data type _and_ rescales the values to be in the range 0 to 1.

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

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by