function colimg(X,p)
[m,n,l]=size(X);
imgc = zeros(m,n,l);
s = m/8;
t = n/8;
r = 8;
for i=2:r
    for j=1:r
        C(i,j)=sqrt(2/r)*cos((i-1)*(j-1/2)*pi/r);
    end
end
C(1,1:r)=ones(1,r)/sqrt(r);
for w=0:2
Q = (2^w)*8./hilb(8);
Xd = double(X);
for k=1:l
for i=1:s
    for j=1:t
       X8 = Xd(((i-1)*8+1):(i*8),((j-1)*8+1):(j*8),k);
       Xc = X8 - 128;
       Y = C*Xc*C';
       Yq = round(Y./Q);
       Ydq = Yq.*Q;
       Xdq = C'*Ydq*C;
       Xe = Xdq+128;
       imgc(((i-1)*8+1):(i*8),((j-1)*8+1):(j*8),k) = Xe;
    end
end
end
subplot(2,2,w+2)
imagesc(uint8(imgc));
title(['compressed p =' int2str(2^w)])
end
subplot(2,2,1)
imagesc(uint8(X));
title('original')
