% Flow pattern visualisation from PIV data, by Xiangyu LI,April 26, 2014

clear all
close all
clc

tic;

% Read png files----------------------------------------------
%filepath = 'E:\2014SoapPTV\2cm_largr_statistics\Flow pattern\plot2\';
%filepath1 = 'E:\2014SoapPTV\2cm_largr_statistics\Flow pattern\';
%file = dir([filepath,'*.png']);
filepath='./swarm_visual_plot/';
file = dir([filepath,'*.png']);
startframe = 1;
endframe = length(file);

% create AVI object-------------------------------------------------------
vidObj = VideoWriter([filepath,'movie.avi']);
vidObj.Quality = 100;
vidObj.FrameRate = 2;
open(vidObj);


for i = startframe:endframe
    filename = file(i).name;
    plotimage = imread([filepath,filename]);
    writeVideo(vidObj,plotimage);
    
end

% save as AVI file, and open it using system video player----------------
close(vidObj);
%winopen('movie.avi');

toc;

