├── Demo_NRAM ├── images │ ├── 1.bmp │ ├── 2.bmp │ └── 3.bmp ├── results │ ├── target │ │ ├── 1.bmp │ │ ├── 2.bmp │ │ └── 3.bmp │ └── background │ │ ├── 1.bmp │ │ ├── 2.bmp │ │ └── 3.bmp ├── functions │ ├── prox_l21.m │ ├── prox_weighted_l1.m │ ├── DC.m │ ├── construct.m │ ├── reconstruct.m │ └── nram.m └── Demo_NRAM.m └── README.md /Demo_NRAM/images/1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lanneeee/NRAM/HEAD/Demo_NRAM/images/1.bmp -------------------------------------------------------------------------------- /Demo_NRAM/images/2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lanneeee/NRAM/HEAD/Demo_NRAM/images/2.bmp -------------------------------------------------------------------------------- /Demo_NRAM/images/3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lanneeee/NRAM/HEAD/Demo_NRAM/images/3.bmp -------------------------------------------------------------------------------- /Demo_NRAM/results/target/1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lanneeee/NRAM/HEAD/Demo_NRAM/results/target/1.bmp -------------------------------------------------------------------------------- /Demo_NRAM/results/target/2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lanneeee/NRAM/HEAD/Demo_NRAM/results/target/2.bmp -------------------------------------------------------------------------------- /Demo_NRAM/results/target/3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lanneeee/NRAM/HEAD/Demo_NRAM/results/target/3.bmp -------------------------------------------------------------------------------- /Demo_NRAM/results/background/1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lanneeee/NRAM/HEAD/Demo_NRAM/results/background/1.bmp -------------------------------------------------------------------------------- /Demo_NRAM/results/background/2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lanneeee/NRAM/HEAD/Demo_NRAM/results/background/2.bmp -------------------------------------------------------------------------------- /Demo_NRAM/results/background/3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lanneeee/NRAM/HEAD/Demo_NRAM/results/background/3.bmp -------------------------------------------------------------------------------- /Demo_NRAM/functions/prox_l21.m: -------------------------------------------------------------------------------- 1 | function [E] = prox_l21(X,beta) 2 | A = sqrt(sum(X.^2,1)); 3 | A(A==0) = beta; 4 | B = (A-beta)./A; 5 | E = X*diag((A>beta).*B); -------------------------------------------------------------------------------- /Demo_NRAM/functions/prox_weighted_l1.m: -------------------------------------------------------------------------------- 1 | function [S]= prox_weighted_l1(Y1,X,W,E,lambda,mu) 2 | 3 | [m,n] = size(X); 4 | 5 | % update weight 6 | C = sqrt(min(m,n))/2.5; 7 | tempT = X - W - E -(1 / mu) * Y1; 8 | Wt = (C)./(abs(tempT)+0.04); 9 | 10 | S = max(tempT - lambda*Wt / mu, 0); 11 | S = S + min((tempT + lambda*Wt), 0); 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NRAM 2 | The implemention of NRAM model in this paper: 3 | 4 | Reference: 5 | Zhang L, Peng L, Zhang T, et al. Infrared Small Target Detection via Non-Convex 6 | Rank Approximation Minimization Joint l2, 1 Norm[J]. Remote Sensing, 2018, 10(11): 1821. 7 | 8 | For the detailed algorithm interpretation, please read our paper. 9 | -------------------------------------------------------------------------------- /Demo_NRAM/functions/DC.m: -------------------------------------------------------------------------------- 1 | function [ X,T ] = DC(D,rho,T0,epislon) 2 | % This Matlab code implements the DC programming 3 | [U,S,V] = svd(D,'econ'); 4 | maxIter = 100; 5 | for t = 1:maxIter 6 | lambda = 1/rho; 7 | S0 = diag(S); 8 | grad = (1 + epislon)*epislon./(epislon + T0).^2; 9 | T1 = max(S0-lambda*grad,0); 10 | X = U*diag(T1)*V'; 11 | error = sum((T1-T0).^2); 12 | if error < 1e-6 13 | break 14 | end 15 | T0 = T1; 16 | end 17 | T = T1; 18 | end -------------------------------------------------------------------------------- /Demo_NRAM/functions/construct.m: -------------------------------------------------------------------------------- 1 | function patchImg = construct(img, patchSize, slideStep) 2 | 3 | % This matlab code generates the patch-image for infrared 4 | % patch-image model. 5 | % 6 | % Yimian Dai. Questions? yimian.dai@gmail.com 7 | % Copyright: College of Electronic and Information Engineering, 8 | % Nanjing University of Aeronautics and Astronautics 9 | 10 | 11 | [m, n] = size(img); 12 | 13 | rowNum = ceil((m - patchSize) / slideStep) + 1; 14 | colNum = ceil((n - patchSize) / slideStep) + 1; 15 | rowPosArr = [1 : slideStep : (rowNum - 1) * slideStep, m - patchSize + 1]; 16 | colPosArr = [1 : slideStep : (colNum - 1) * slideStep, n - patchSize + 1]; 17 | 18 | patchImg = zeros(patchSize * patchSize, rowNum * colNum); 19 | 20 | k = 0; 21 | for col = colPosArr 22 | for row = rowPosArr 23 | k = k + 1; 24 | tmp_patch = img(row : row + patchSize - 1, col : col + patchSize - 1); 25 | patchImg(:, k) = tmp_patch(:); 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /Demo_NRAM/functions/reconstruct.m: -------------------------------------------------------------------------------- 1 | function recImg = reconstruct(patchImg, img, patchSize, slideStep) 2 | 3 | % This matlab code implements the reconstruction of target/background 4 | % images. 5 | 6 | % Yimian Dai. Questions? yimian.dai@gmail.com 7 | % Copyright: College of Electronic and Information Engineering, 8 | % Nanjing University of Aeronautics and Astronautics 9 | 10 | [Hei, Wid] = size(img); 11 | 12 | rowNum = ceil((Hei - patchSize) / slideStep) + 1; 13 | colNum = ceil((Wid - patchSize) / slideStep) + 1; 14 | rowPosArr = [1 : slideStep : (rowNum - 1) * slideStep, Hei - patchSize + 1]; 15 | colPosArr = [1 : slideStep : (colNum - 1) * slideStep, Wid - patchSize + 1]; 16 | 17 | accImg = zeros(Hei, Wid); 18 | weiImg = zeros(Hei, Wid); 19 | k = 0; 20 | onesMat = ones(patchSize, patchSize); 21 | for col = colPosArr 22 | for row = rowPosArr 23 | k = k + 1; 24 | tmpPatch = reshape(patchImg(:, k), [patchSize, patchSize]); 25 | accImg(row : row + patchSize - 1, col : col + patchSize - 1) = tmpPatch; 26 | weiImg(row : row + patchSize - 1, col : col + patchSize - 1) = onesMat; 27 | end 28 | end 29 | 30 | % recImg = accImg ./ weiImg; 31 | recImg = accImg; 32 | -------------------------------------------------------------------------------- /Demo_NRAM/functions/nram.m: -------------------------------------------------------------------------------- 1 | function [L, S] = nram(X,lambda) 2 | [m,n] = size(X); 3 | 4 | muzero = 3*sqrt(max(m,n)); % initial mu 5 | rate = 1.1; % update rate of mu 6 | gamma = 2*1e-3; % gamma parameter in the rank approximation 7 | tol = 1e-7; % stopping criterion 8 | beta = 3/sqrt(min(m,n)); 9 | maxIter = 1000; 10 | 11 | 12 | %% Initialization 13 | [m,n] = size(X); 14 | S = zeros(m,n); 15 | Y = zeros(m,n); 16 | E = zeros(m,n); 17 | L = zeros(m,n); 18 | sig = zeros(min(m,n),1); % for DC 19 | mu = muzero; 20 | 21 | %% Solving the proposed NRAM model 22 | for ii=1:maxIter 23 | 24 | % update low-rank component L 25 | [ L,sig] = DC(X-S-E-Y/mu,mu,sig,gamma); 26 | 27 | % update sparse component S 28 | S = prox_weighted_l1(Y,X,L,E,lambda,mu); 29 | 30 | % update strong edge component E 31 | E = prox_l21(X-S-L-Y/mu,beta/mu); 32 | 33 | % update multiplier Y 34 | Y=Y+mu*(L+E-X+S); 35 | 36 | % update mu 37 | mu=mu*rate; 38 | 39 | % calculate relative error 40 | sigma = norm(X-S-L-E,'fro'); 41 | RE = sigma/norm(X,'fro'); 42 | if mod( ii, 10) == 0 43 | disp(['#svd ' num2str(ii) ' r(A) ' num2str(rank(L))... 44 | ' |E|_0 ' num2str(length(find(abs(S)>0)))... 45 | ' stopC ' num2str(RE)]); 46 | end 47 | 48 | if RE