-
Notifications
You must be signed in to change notification settings - Fork 4
/
QMUL_partA1.m
38 lines (31 loc) · 1.04 KB
/
QMUL_partA1.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
38
function[diffFrame] = QMUL_partA1(vidFrames, frame, threshold)
%
%QMUL_partA1 Frame difference
% Frame differene using the first frame as reference frame
% and specified frame as original frame
% Apply specified threshold and display image
%
% differencedFrame = QMUL_partA1(VideoFrames, FrameNumber, Threshold)
%
% INPUT
% VideoFrames - Frames of the video
% FrameNumber - Number of frame you want to difference
% Threshold - Marker to indicate threshold
%
% OUTPUT
% differencedFrame - The thresholded differenced Frame
%vidMatrix = VideoReader(video);
%vidFrames = read(vidMatrix);
%%
%Difference the Frame
diffFrame = uint8(abs(double(rgb2gray(vidFrames(:,:,:,1))) - double(rgb2gray(vidFrames(:,:,:, frame)))));
%%
%Apply Threshold if specified
if(threshold>0)
diffFrame(diffFrame<threshold) = 0;
diffFrame(diffFrame>threshold) = 255;
end
%%
%Display thresholded frame
figure(),imshow(diffFrame)
end