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
| SNum = 21; I = imread('img.bmp'); h = size(I,1); w = size(I,2); R = I(:,:,1); G = I(:,:,2); B = I(:,:,3); debug = 'RGB disposed' Rd = im2double(R); Gd = im2double(G); Bd = im2double(B); [Ur,Sr,Vr] = svd(Rd); [Ug,Sg,Vg] = svd(Gd); [Ub,Sb,Vb] = svd(Bd); debug = 'end SVD decomposition' Rt = zeros(h,w); Gt = zeros(h,w); Bt = zeros(h,w); for i = 1:SNum Rt = Rt + Sr(i,i)*Ur(:,i)*Vr(:,i)'; Gt = Gt + Sg(i,i)*Ug(:,i)*Vg(:,i)'; Bt = Bt + Sb(i,i)*Ub(:,i)*Vb(:,i)'; end I2(:,:,1) = im2uint8(Rt); I2(:,:,2) = im2uint8(Gt); I2(:,:,3) = im2uint8(Bt); imshow(I2);
|