MATLAB code, sub-function
function [A_hat e_hat] =RPCA (res)%res, input image, output is low rank a_hat and sparse e_hat [row col] = size (res); Lambda = 1/sqrt (max (Size (res))); Tol = 1e-7; Maxiter = 1000;% Initializey = res; [U,s,v]=svd (y); norm_two=s (1); Norm_inf=max (abs (Y (:)))/lambda;dual_norm = Max (Norm_two, Norm_inf); Y = Y/dual_norm; A_hat = zeros (row, col); E_hat = zeros (row, col); mu = 0.01/norm_two; % this one can be Tunedmu_bar = mu * 1e7;rho = 1.9; % this one can be tunedd_norm=sqrt (sum (res (:). ^2)); iter = 0;TOTAL_SVD = 0;converged = 0;% Convergence stopcriterion = 1;SV = 10;while ~converged iter = iter + 1; temp_t = Res-a_hat + (1/MU) *y; E_HAT=TEMP_T-LAMBDA/MU; N1=find (e_hat<0); E_hat (n1) = 0; tmp=temp_t + lambda/mu; N1=find (tmp>0); TMP (n1) = 0; E_hat= e_hat+tmp; [U1 S1 V1] = SVD (Res-e_hat + (1/MU) *y); If Chsvd (col, sv) = = 1 U=u1 (:, 1:SV); S=S1 (:, 1:SV); V=V1 (:, 1:SV); End diagS = Diag (S); SVP = Length (Find (DiagS > 1/mu)); If SVP < sv SV = min (SVP + 1, col); else SV = min (SVP + round (0.05*col), col); end% a_hat = U (:, 1:SVP) * DIAG (DiagS (1:SVP)-1/mu) * V (:, 1:SVP) '; U2=u (:, 1:SVP); S2=diag (DiagS (1:SVP)-1/MU); V2=v (:, 1:SVP) '; A_hat=u2*s2*v2; TOTAL_SVD = TOTAL_SVD + 1; Z = Res-a_hat-e_hat; y = y + mu*z; mu = min (Mu*rho, mu_bar); Percent Stop Criterion stopcriterion = sqrt (sum (Z (:). ^2))/d_norm; If stopcriterion < tol converged = 1; End If ~converged && iter >= maxiter disp (' Maximum iterations reached '); converged = 1; Endendendfunction Y=CHSVD (n, D) y=0; if ((n<=100) && (d/n<=0.02)) Y=1;end if ((n<=200) && (d/n<=0.06)) Y=1; End if ((n<=300) && (d/n<=0.26)) Y=1;end if ((n<=400) && (d/n<=0.28)) Y=1;end if ((n<=500) && (d/n<=0.34) y=1;end if (n>500&& (d/n<=0.38)) y=1;endend
Download Low rank: http://download.csdn.net/detail/ck1798333105/9499455
RPCA (robust PCA), low-rank sparse decomposition