%% load in a video file .MOV
%
video = VideoReader('IMG1383.MOV');
nframes = video.NumberOfFrames;
frameHeight = video.Height;
frameWidth = video.Width;
frameRate = video.FrameRate; % frames per second
duration = video.Duration;   % seconds
time = linspace(0,duration,nframes);

%% read each video frame and compute
% brightness of the red channel
%
skiptime = 3; % skip the first 3 seconds
skipindex = round(skiptime * frameRate);
%
brt = zeros(1, nframes-skipindex);
for i = 1:nframes-skipindex
  disp(sprintf('reading frame %4d/%4d ...', i+skipindex,nframes));
  frame = read(video, i+skipindex);
%  redChannel = frame(:, :, 1);
%  brt(i) = mean(redChannel(:));
  brt(i) = mean(frame(:));
end
nframes = length(brt);
time = time(skipindex+1:end);

%% subtract the mean brightness

% your code goes here

%% band-pass filter between frequencies of interest
% i.e. frequencies where we expect a human adult
%      heartrate to be

% your code goes here

%% compute a spectrum
%
[p,f] = pwelch(brt_f, [], [], [], frameRate);

