الخميس، 26 ديسمبر 2013

video editing by matlab

convert video from rgb to hsv 

by this way u can edit the video and make it again video 
split it to image and do what u want 


this the input

http://www.youtube.com/watch?v=WiUsRbTegEg&feature=youtu.be

the output
http://www.youtube.com/watch?v=2HCnCrudz0A&feature=youtu.be


the matlab code

mkdir('workingDir');
mkdir('workingDir','images');
shuttleVideo = VideoReader('723493_558567347510592_214063615_n.mp4');
for ii = 1:shuttleVideo.NumberOfFrames
img = read(shuttleVideo,ii);
img=rgb2hsv(img);  % u can edit all here :)
imwrite(img,fullfile('workingDir','images',sprintf('img%d.jpg',ii)));
end
imageNames = dir(fullfile('workingDir','images','*.jpg'));
imageNames = {imageNames.name}';
imageStrings = regexp([imageNames{:}],'(\d*)','match');
imageNumbers = str2double(imageStrings);
[~,sortedIndices] = sort(imageNumbers);
sortedImageNames = imageNames(sortedIndices);
outputVideo = VideoWriter(fullfile('workingDir','shuttle_out.avi'));
outputVideo.FrameRate = shuttleVideo.FrameRate;
open(outputVideo);
for ii = 1:length(sortedImageNames)
    img = imread(fullfile('workingDir','images',sortedImageNames{ii}));
    writeVideo(outputVideo,img);
end
close(outputVideo);

ليست هناك تعليقات: