matlab - sparse representation for image prediction -


i m working on project have implemented dictionary omp algorithm cant understand how implement on lena image.i providing code on here.

%function [x_pr pp]=ompmod_pred2(d1,a1,sl,errorgoal) %____________________________________________________ %prediction using (aurelie method) % d1=dictionary; %a1=image block of size (16x16); %sl=sparsity label %x_pr=predicted block s=8; %d=first 3:4 of d1 d=d1(1:3*s^2,:); %d2=last 1:4 of d1 d2=d1(3*s^2+1:4*s^2,:); %x_ac=block predicted x_ac=a1(9:16,9:16); %x1=reshape a1 column y1=im2col(a1,[s,s],'distinct'); x1=im2col(y1,[s^2,4],'distinct'); %x=first 3:4 of x1 x=x1(1:3*s^2,1); %x2=last 1:4 of x1 x2=x1(3*s^2+1:4*s^2,1); %___________________________________ %a2=calculation of solution vector @  %diffrent sparsity label using omp %___________________________________ [n,p]=size(x); [n,k]=size(d); e2 = errorgoal^2*n; s1=1:s1 maxnumcoef = s1; a2(:,1)= zeros(size(d,2),size(x,2)); errorres = x;     % new entry k=1:1:p,     x=x(:,k);     residual=x;     indx = [];     = []; %    currresnorm2 = sum(residual.^2);  % creates problem complex vectors      currresnorm2 = residual'*residual;    %'     j = 0;     while currresnorm2>e2  & j < maxnumcoef,         j = j+1;         proj=d'*residual;    %'         pos=find(abs(proj)==max(abs(proj)));         pos=pos(1);         indx(j)=pos;         z1=pinv(d(:,indx(1:j)));         a=pinv(d(:,indx(1:j)))*x;         residual=x-d(:,indx(1:j))*a; %        currresnorm2 = sum(residual.^2);         currresnorm2 = residual'*residual;    %'    end;    if (length(indx)>0)        %_____________________________________        l1=length(indx); k1=1:l1 k2=1:k     if k2==indx(1,k1)         a1(k2,k1)=a(k1,1);     else a1(k2,k1)=0;     end end if l1==1     a=a1; else a=sum(a1')'; end        %_______________________________________         errorres(:,k)=residual;   % new entry        end    end; end    a2=[a2 a]; end %________________________________________________ %x3=calculation of error @ different sparsity label l1=length(indx); k1=1:l1 x3(k1)=((d2*a2(:,k1+1))-x2)'*((d2*a2(:,k1+1))-x2);   %' end % %________________________________________________ %pv=minimum error,pp=iteration  [pv pp]=min(x3); %x_pr=predicted block x_pr1=d2*a2(:,pp+1); x_pr=col2im(x_pr1,[8 8],[8 8],'distinct'); %_________________________________________________ return; 

here code creating dictionary.

function[d]=dict1(s) %generate dct dictionary of size (s^2 x s^2) a=idct(eye(s)); k1=1:s^2     if rem(k1,s)==0 b(:,(k1-1)*s+1:k1*s)=a(:,ceil(k1/s))*a(:,1)';    %'     else b(:,(k1-1)*s+1:k1*s)=a(:,ceil(k1/s))*a(:,rem(k1,s))';    %'     end end d1=im2col(b,[s/2 s/2],'distinct'); d=im2col(d1,[s^2/4 4],'distinct'); end 

where s=16

please me .


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -