%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %function []= plotAverage(ROI,nbIm, fps) % % Task: plotting the average color of the ROI over time % % Inputs: % - ROI: 3D matrix, Region of interest, made out of 'nbIm' different images % - nbIm: integer, number of images stored from the video % - fps: frames per seconds of the video % % Outputs: % - plot of the average color of the ROI as a function of time % % Antoine Rodary - Julian Leclerc - Gwenn Durpoix-Espinasson - Luc Pichot % 06/04/2021 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [averageArray]= plotAverage(ROI,nbIm, fps) display("PlotAv Start") % passing through each image of the video averageArray = zeros(1,nbIm); [n,m,Nimg]=size(ROI); for k = 1:nbIm % calculating the average value of the ROI sum = 0; for i = 1:n for j = 1:m sum = sum + ROI(i,j,k); end end average = sum/(i*j); %storing averageArray(k)= average; end xAxis = [0:(1/fps):(nbIm/fps)-(1/fps)]; figure(1); plot(xAxis, averageArray); title('Average color of the ROI over time') xlabel('t (s)') ylabel('Average color of the ROI') display("PlotAv End") endfunction