Matlab 视频读写操作



1):视频读取,

function  moive=read_moive(file)

      readerobj=VideoReader(file)

      NumFrame=readerobj.NumberOfFrames;

      for k=1:NumFrame

             frame=read(readerobj,k);
             moive(k).cdata=frame;
             moive(k).colormap=[];
      end
end

1):视频写

function  moive=save_moive(moive_data,filename)
        writerObj=VideoWriter(tmp_name,'Uncompressed AVI');  %%对应VideoReader()函数   
        writerObj.FrameRate=10;
       open(writerObj);   %%%将对象打开
       for k=1:length(moive_data);
                frame = moive_data(k).cdata;
                writeVideo(writerObj,frame);
       end
      close(writerObj);
end

你可能感兴趣的:(图像处理)