

input_file_stub = 's1_middle-200fps-';
input_file_stub = 's1_bottom-200fps-';
file_skip    = 1;


for movie_no     = 1
    
    inputfile  = [input_file_stub, num2str(movie_no),'.avi'];
    
    mov = mmreader(inputfile);
    
    
    outputdir = [input_file_stub, num2str(movie_no),'_skip', num2str(file_skip-1), '/'];
    mkdir(outputdir);
    
    [rows, frames]=size(mov);
    
    frames = mov.NumberOfFrames;
    vidHeight = mov.Height;
    vidWidth = mov.Width;
    
    %frames=3;
    
    % Preallocate movie structure.
    frame(1:frames) = ...
        struct('cdata', zeros(vidHeight, vidWidth, 3, 'uint8'),...
        'colormap', []);
    
    
    for f=2:file_skip:frames
        
        frame(f).cdata = read(mov, f);
        
        filename = [outputdir, sprintf('Frame%04.0f', f/file_skip), '.tif'];
        
        imwrite(frame(f).cdata, filename, 'tif');
    end
    
end
