%I've used this only once and commented out because I've to create avi
%files each time.
% --- from this block you comment out If you are using avi file
%load SurvTestFrames.mat
M=[];
for i=1:56
imshow(ag(:,:,i));
M=[M getframe()];
end
movie2avi(M,'bg11.avi');
%---- run above block once and comment out 
clear data
disp('input video');


avi = aviread('bg11.avi');
video = {avi.cdata};
for a = 1:length(video)
    imagesc(video{a});
    axis image off
    drawnow;
    pause(.2);
end;
disp('output video');
Detection(video);
histogram(video);