How to convert Image frame into video ?
Afficher commentaires plus anciens
clc;
output_folder = 'D:\Matlab book and files\SLT\frames'
location = dir('D:\Matlab book and files\SLT\frames\*.tiff');
vidObj = VideoReader('akiyo2_grayscale2.mp4');
numFrames = 0;
frame = cell(1,300) ;
frame2image = cell(1,300);
image2frame = cell(1,300);
rgbtogray = cell(1,300);
graytorgb = cell(1,300);
entrpopygray= cell(1,300);
while hasFrame(vidObj)
F = readFrame(vidObj);
numFrames = numFrames + 1;
frame{numFrames} = F ;
[r,c,n]=size(F)
end
numFrames
for i= 1:300
imshow(frame{1,i});
frame{1,i}=getframe;
rgbtogray{1,i} = rgb2gray(frame2im(frame{1,i}));
outputFileName = fullfile(output_folder, ['frame' num2str(i) '.tiff']);
imwrite(rgbtogray{1,i},outputFileName);
entrpopygray{1,i}= entropy(rgbtogray{1,i}); % calculate a entropy of each image
end
video = VideoWriter('yourvideo.avi'); %create the video object
video.FrameRate= vidObj.FrameRate;
open(video); %open the file for writing
for ii=1:300
img = location(ii).name ;
I = imread(img); % the problem i am facing to concatenate a frames into video
F= getframe(gcf);
writeVideo(video,F); %write the image to file
end
close(video); %close the file
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Process Point Clouds dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!