如何在MATLAB中从静止图像创建视频?

时间:2014-03-21 07:34:42

标签: image matlab image-processing video-conversion

我是MATLAB的新手。我正在尝试在MATLAB中加密视频文件。我加密了单独的视频帧。我正在使用MATLAB 7.10.0(R2010a),这就是我使用“mmreader”功能的原因。但现在我没有得到如何将所有加密帧重新组合成新视频。这是我的代码,

vid = mmreader('videoSampl.avi');
numFrame = vid.NumberOfframes;

for i = 1:2:3
   frame = read(vid, i);
   gray = rgb2gray(frame);
   n = numel(gray);
   plaintext = reshape(gray, n, 1);
   cipherImg = cipher (plaintext, w, s_box, poly_mat, 1);
   re_plaintext = inv_cipher (cipherImg, plaintext, w, inv_s_box, inv_poly_mat, 1);
   img = reshape(cipherImg, 128, 128);
   imwrite(img,['videoaes/encrypted/image' int2str(i), '.jpg']);
   imgP = reshape(re_plaintext, 128, 128);
   imwrite(imgP,['videoaes/decrypted/Dimage' int2str(i), '.jpg']);
   im(i)=image(frames);
end

我有两个加密和解密的文件夹,我想再将这些文件夹转换为avi视频。

1 个答案:

答案 0 :(得分:-2)

以下是从您加密的图片转换视频的代码

ImagesFolder=uigetdir;
jpegFiles = dir(strcat(ImagesFolder,'\*.png'));
S = [jpegFiles(:).datenum]; 
[S,S] = sort(S);
jpegFilesS =jpegFiles(S);
VideoFile=strcat(ImagesFolder,'\MyVideo');writerObj=VideoWriter(VideoFile);
fps= 10; writerObj.FrameRate = fps;
open(writerObj);
fort=1:length(jpegFilesS)Frame=imread(strcat(ImagesFolder,'\',jpegFilesS(t).name))writeVideo(writerObj,im2frame(Frame))endclose(writerObj;