-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrough.m
60 lines (50 loc) · 1.49 KB
/
rough.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
clc;
clear;
close all;
mov=VideoReader('input_subsampled.avi');
vidFrames=double(read(mov));
nFrames=mov.NumberOfFrames;
frameRate = mov.FrameRate;
save('face_data.mat','vidFrames','nFrames','frameRate','-v7.3');
%%
clc;
close all;
NumElementsInFrame = numel(vidFrames(:,:,:,1));
ColumnizedFrames = reshape(vidFrames,NumElementsInFrame,nFrames);
size(ColumnizedFrames)
bpFilt = designfilt('bandpassfir','FilterOrder',40, ...
'CutoffFrequency1',2,'CutoffFrequency2',2.33, ...
'SampleRate',frameRate);
fvtool(bpFilt)
BandPassFiltered = zeros(size(ColumnizedFrames));
%%
ColumnizedFrames = reshape(vidFrames,NumElementsInFrame,nFrames);
%%
for i = 1:NumElementsInFrame
% i
BandPassFiltered(i,:) = filter(bpFilt,ColumnizedFrames(i,:)')';
end
ColumnizedFrames = ColumnizedFrames + 2*BandPassFiltered;
FilteredFrames = reshape(ColumnizedFrames,size(vidFrames));
save('newFiltered.mat','FilteredFrames','-v7.3');
%%
v = VideoWriter('output');
v.FrameRate = frameRate;
open(v);
band = FilteredFrames - vidFrames;
m = max(band(:));
n = min(band(:));
dif = m - n;
s = size(band(:,:,:,1));
for i = 1:nFrames
writeVideo(v,((band(:,:,:,i)-n)./dif));
end
close(v)
%%
aviobj = VideoWriter('example.avi');
aviobj.FrameRate = frameRate;
open(aviobj);
for frame = 1:3
aviobj = addframe(aviobj, FilteredFrames(:,:,:,frame)); %// This is assuming your image is a vector of RGB images. If it's a vector of indexed images then drop one : and make the loop go to size(M,3)
end
aviobj = close(aviobj);