-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathQMUL_partA5ii.m
37 lines (32 loc) · 1.02 KB
/
QMUL_partA5ii.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
function[newFrame] = QMUL_partA5ii(vidFrames, limit)
%
%QMUL_partA5ii frame averaging
% This averages the RGB values of all the frames given.
% 90 percent of most videos are background so our image will tend
% towards the background
% This function is used in QMUL_partA5.
%
% averagedFrame = QMUL_partA5i(vidFrames, limit)
%
% INPUT
% vidFrames - Video frames
% Limit - The limit of frames we are allowed to use
%
% OUTPUT
% averagedFrame - The background Frame
%%
%Create a blank frame to put averaged pixels on
[rows cols depth frames] = size(vidFrames);
newFrame = zeros(rows, cols, depth);
%%
%Average RGB pixels across the 'limit' of frames
for i=1:rows
for j=1:cols
for k=1:depth
newFrame(i,j,k) = mean(vidFrames(i,j,k,1:limit));
end
end
end
%render frame in uint8 before passing back
newFrame = uint8(newFrame);
end