-
Notifications
You must be signed in to change notification settings - Fork 2
/
DemoFB.m
executable file
·63 lines (43 loc) · 1.36 KB
/
DemoFB.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
61
62
63
%%% Wrapper for Foreground-Background task in video layering
%%%If you use this code please cite the following paper
%%%[1] A Fast and Memory-Efficient Algorithm for Robust PCA (MEROP),
%%% Praneeth Narayanamurthy and Namrata Vaswani, ICASSP 2018.
%%Read video
clear;
clc;
close all
addpath('YALL1_v1.4/');
addpath('PROPACK/');
load('Data/Curtain.mat');
%I = M;
%% Training data processing
%%option 1 -- init using batch RPCA
t_train = 400;
TrainData = I(:, 1 : t_train);
rank_init = 50;
L_hat_init = ncrpca(TrainData, rank_init);
mu = mean(L_hat_init, 2);
[Utemp, Stemp, ~] = svd(1 / sqrt(t_train) * (L_hat_init - ...
repmat(mu, 1, t_train)));
ss1 = diag(Stemp);
L_init = Utemp(:, 1 : rank_init);
%%option 2 -- init using outlier free data
% mu = mean(DataTrain, 2);
% t_train = size(DataTrain, 2);
% [Utemp, Stemp, ~] = svd(1 / sqrt(t_train) * ...
% (DataTrain - repmat(mu, 1, t_train)));
% ss1 = diag(Stemp);
% b = 0.95;
% rank_init = min(find(cumsum(ss1.^2) >= b * sum(ss1.^2)));
% L_init = Utemp(:, 1 : rank_init);
fprintf('Initialized\n');
%% Call to MERoP
K = 3;
alpha = 60;
tic
fprintf('alpha = %d\tK = %d\n', alpha, K);
[BG, FG, L_hat, S_hat, T_hat, t_hat, P_track_full, P_track_new] ...
= MERoP(I(:, t_train + 1 : end), L_init, mu, alpha, K);
toc
VidName = 'DemoOutput';
DisplayVideo(I(:, t_train + 1 : end), FG, BG, T_hat, imSize, VidName);