Matlab source code for file selection
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Rishav
am 10 Mär. 2014
Bearbeitet: Marta Salas
am 10 Mär. 2014
I am doing a project on Video Compression. My problem is that i have a folder named "Snaps" that contains all the frames of the video. I want to select a number of sequential files having a certain interval and save those files into another folder named "Newsnaps". Can anyone please help me with the source code on this matter??
0 Kommentare
Akzeptierte Antwort
Marta Salas
am 10 Mär. 2014
Bearbeitet: Marta Salas
am 10 Mär. 2014
Hi,
If I understood correctly you want to read the files from the folder Snaps, subsample them and then save them on a new folder called NewSpnas.
video_dir = 'snaps/'
extension = 'jpg'
out_dir = 'Newsnaps/'
step = 2 % this parameter decide which frames to save
resnames=dir(fullfile(video_dirs,['*.' extension]));
for i=1:step:length(resnames)
img=imread(fullfile(video_dirs,resnames(i).name));
imwrite(img, [out_dir resnames(i).name]);
end
0 Kommentare
Weitere Antworten (1)
Nitin
am 10 Mär. 2014
This should get you started on selecting the sequential frames:
% The following will give the lengths of the consecutive sequences of your vector:
a=diff(frame_number);
b=find([a inf]>1);
c=diff([0 b]); % length of the sequences
d=cumsum(c); % endpoints of the sequences
% Choose frames with highest number of consecutive frames
ind5 = max(c);
if length(ind5)> 1
ind5 = ind5(1);
end
% Proceed only if the number of consecutive frames is greater >
% length consecutive frames
if ind5>=length_cons_frames
ind6 = find(c==ind5);
end_point = d(ind6);
0 Kommentare
Siehe auch
Kategorien
Mehr zu Whos finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!