function Y=dct(X) 
[m,n]=size(X);n=m;
for i=2:n
    for j=1:n
        C(i,j)=sqrt(2/n)*cos((i-1)*(j-1/2)*pi/n);
    end
end
C(1,1:n)=ones(1,n)/sqrt(n);
p=4;

for k=1:8
    for l=1:8
         Q(k,l)=8*p*((k-1)+(l-1)+1);
    end
end
Y=C*X*C';
YQ=round(Y./Q);

Ydq=YQ.*Q;
Xdq=C'*Ydq*C;
Xe=Xdq+128;
Xf=uint8(Xe);
imagesc(Xf,[0 250]);colormap(gray)
