xcol=imread('colorimg.jpg')
xdco=double(xcol);
r=xdco(:,:,1);g=xdco(:,:,2); b=xdco(:,:,3);



n=8;
for i=2:n
   for j=1:n
       K(i,j)=sqrt(2/n)*cos((i-1)*(j-1/2)*pi/n);
   end
end
K(1,1:n)=ones(1,n)/sqrt(n);
p=1;

for k=1:8
    for l=1:8
         Q(k,l)=8*p*((k-1)+(l-1)+1);
    end
end



Xf=zeros(8,8);

Re=b(81:88,81:88);
Red=Re-96;
Yr=K*Red*K';
YQr=round(Yr./Q);

Ydqr=YQr.*Q;
Xdqr=K'*Ydqr*K;
Xer=Xdqr+96;

imagesc(uint8(Xer))