function d = histogram(video)
load SurvTestFrames.mat
%bgMean11 = mean(ag,3);

if ischar(video)
    % Load the video from an avi file.
    avi = aviread(video);
    pixels = double(cat(4,avi(1:2:end).cdata))/255;
    clear avi
else
    % Compile the pixel data into a single array
    pixels = double(cat(4,video{1:2:end}))/255;
    clear video
end

% Convert to RGB to GRAY SCALE image.
nFrames = size(pixels,4);
disp(nFrames);
for f = 1:nFrames
 
    pixel(:,:,f) = (rgb2gray(pixels(:,:,:,f)));  
end
bgMean11 = mean(pixel,3);
rows=240;
cols=320; 
nrames=f;
for l = 2:nrames
d(:,:,l)=(abs(pixel(:,:,l)-pixel(:,:,l-1)));
end
bgMean12 = mean(d,3);
Bg21= histeq(abs(bgMean11-bgMean12));
%--------
subplot(3,3,1)
bgMean11=(bgMean11);
imshow(bgMean11)
 text(0, -40, ['background picture ' ]);
subplot(3,3,3)
imhist(bgMean11);
 text(0, -40, ['histogram of background picture ' ]);
 subplot(3,3,4)
 bgMean12 = mean(d,3)*10;
 imshow(bgMean12)
  text(0, -60, ['foreground picture ' ]);
  subplot(3,3,6)
imhist(bgMean12)
subplot(3,3,7)
Bg21=(Bg21);
imshow(Bg21)
text(0, -60, ['Background - Foreground  picture ' ]);
subplot(3,3,9)
imhist(Bg21);
end
