function RGB= Lumiere
p=10;
Xi = imread('DiegoHuerta.jpg'); 
Xi = Xi(1:680,1:680,:);
x=double(Xi);
r=x(:,:,1);
g=x(:,:,2);
b=x(:,:,3);
Y=0.299*r+0.587*g+0.114*b;
U=b-Y;
V=r-Y;
Y=dct2C(p,Y);
U=dct2C(p,U);
V=dct2C(p,V);
b=Y+U;
r=V+Y;
g=(Y-0.299*r-0.114*b)/(0.587);
x(:,:,1)=r;
x(:,:,2)=g;
x(:,:,3)=b;
figure(1);RGB=imagesc(uint8(x));
title(['Compressed p = 10' ]);


function var=dct2C(p,X)
Xc=X-128;
sizeImage=size(Xc);
Xf=zeros(sizeImage(1));
for k=0:(sizeImage(1)/8)-1
    for l=0:(sizeImage(2)/8)-1
        c=Xc(8*k+1:8*k+8,8*l+1:8*l+8);
        cr=dctY(p,c);
        Xf(8*k+1:8*k+8,8*l+1:8*l+8)=cr;    
    end
end
var=Xf;

function R=dctY(p,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);

Y=C*X*C';
Qy=p*[16 11 10 16 24 40 51 61; 
     12 12 14 19 26 58 60 55; 
     14 13 16 24 40 57 69 56; 
     14 17 22 29 51 87 80 62; 
     18 22 37 56 68 109 103 77; 
     24 35 55 64 81 104 113 92; 
     49 64 78 87 103 121 120 101; 
     72 92 95 98 112 100 103 99]; 
 
Yq=round(Y./Qy);
Ydq=Yq.*Qy;
Xdq=C'*Ydq*C;
R=Xdq+128;
