From 14d0660f8f142189f8069076fd8fb0b03e321a28 Mon Sep 17 00:00:00 2001
From: Elian Dib <elian.dib@inria.fr>
Date: Thu, 25 Apr 2019 19:59:42 +0200
Subject: [PATCH] Updated factorization

---
 factorize.m | 26 +++++++-------------------
 1 file changed, 7 insertions(+), 19 deletions(-)

diff --git a/factorize.m b/factorize.m
index 62a64d1..1c71f54 100644
--- a/factorize.m
+++ b/factorize.m
@@ -1,27 +1,15 @@
-function [LFB,C,U,S,V] = factorize(LFRef,varargin)
+function [LFB,C,U,S,V] = factorize(LFRef,k,varargin)
 %FACTORIZE Summary of this function goes here
 %   Detailed explanation goes here
 
-sz = size(LFRef);
-Mask = isnan(LFRef); LFRef(Mask) = 0;
-vecResh = @(x)   reshape(x,size(x,1)*size(x,2),[])';
-boxResh = @(x,sz) reshape(x',sz);
+LFSize = size(LFRef);
+ImgSize = LFSize(1:3);
+ImgRes  = LFSize(4:end);
 
-LFRefvec = vecResh(LFRef);
-Maskvec = vecResh(Mask);
+LFRef  = reshape(LFRef,prod(ImgSize),prod(ImgRes));
 
-kList = 1:size(LFRefvec,2);
-if nargin>1
-    kList = varargin{1};
-end
+[LFB,C,U,S,V] = utils.factorize(LFRef,k);
 
-[U,S,V] = svd_nsq(LFRefvec);
-B = U*S;
-C = V';
+LFB = reshape(LFB ,[ImgSize,k,1]);
 
-B(Maskvec) = NaN;
-B = B(:,kList);
-C = C(kList,:);
-
-LFB = boxResh(B,[numel(kList),1,sz(3:end)]);
 end
\ No newline at end of file
-- 
GitLab