why each pixel of the predicted image is same?

1 view (last 30 days)
I m working on prediction using orthogonal matching pursuit algorithm where at the output i m getting same pixel value through out the patch. i m providing the program.
D=Dictionary;
%a1=image block of size (16X16);
%sl=sparsity label
%X_pr=predicted block
a1=[162,162,162,161,162,157,163,161,166,162,162,160,155,163,160,155;162,162,162,161,162,157,163,161,166,162,162,160,155,163,160,155;162,162,162,161,162,157,163,161,166,162,162,160,155,163,160,155;162,162,162,161,162,157,163,161,166,162,162,160,155,163,160,155;162,162,162,161,162,157,163,161,166,162,162,160,155,163,160,155;164,164,158,155,161,159,159,160,161,160,155,159,154,154,156,154;160,160,163,158,160,162,159,156,159,163,158,163,155,155,156,152;159,159,155,157,158,159,156,157,159,162,162,160,153,153,153,151;155,155,158,158,159,160,157,157,163,157,159,160,159,154,156,157;155,155,157,158,155,154,155,157,161,155,155,157,157,157,157,152;156,156,156,160,156,155,155,152,159,159,157,157,159,154,158,154;156,156,156,159,159,155,150,148,160,159,158,158,156,155,157,158;158,158,157,156,157,153,159,156,161,158,160,157,156,153,156,171;157,157,157,157,160,157,156,156,159,155,154,158,156,155,154,160;158,158,159,155,155,158,158,156,157,156,151,160,157,156,156,155;158,158,159,157,155,158,157,154,158,158,158,159,155,156,154,171];
s4=16;
D=dict1(s4);
%D=first 3:4 of D1
s1=100;
s=8;
errorGoal=10;
D1=D(1:3*s^2,:);
%D2=last 1:4 of D1
D2=D(3*s^2+1:4*s^2,:);
%X_ac=block to be predicted
%X_ac=a1(9:16,9:16);
%X1=reshape a1 to 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 at
%diffrent sparsity label using OMP
%___________________________________
[n,P]=size(X);
[n,K]=size(D1);
E2 = errorGoal^2*n;
for s1=1:s1
maxNumCoef = s1;
A2(:,1)= zeros(size(D1,2),size(X,2));
errorRes = X; % new entry
for k=1:1:P,
x=X(:,k);
residual=x;
indx = [];
e = [];
% currResNorm2 = sum(residual.^2); % creates problem for complex vectors
currResNorm2 = residual'*residual;
j = 0;
while currResNorm2>E2 & j < maxNumCoef,
j = j+1;
proj=D1'*residual;
pos=find(abs(proj)==max(abs(proj)));
pos=pos(1);
indx(j)=pos;
z1=pinv(D1(:,indx(1:j)));
e=pinv(D1(:,indx(1:j)))*x;
residual=x-D1(:,indx(1:j))*e;
% currResNorm2 = sum(residual.^2);
currResNorm2 = residual'*residual;
end;
if (length(indx)>0)
%_____________________________________
l1=length(indx);
for k1=1:l1
for k2=1:K
if k2==indx(1,k1)
A1(k2,k1)=e(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 at diffrent sparsity label
l1=length(indx);
for 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;
disp(X_pr);
X_pr is the output where whole patch has same pixel value.help me out.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!