x=imread('mj.jpg');
x=double(x);
r=x(:,:,1);g=x(:,:,2);b=x(:,:,3);
xgray=0.2126*r+0.7152*g+0.0722*b;
xb=xgray(381:388,181:188);
xb;
figure(1); imagesc(uint8(xb));colormap(gray)
title('original')
xc=xb-128;
y=dct(dct(xc')');
p=1;
q=p*8./hilb(8);
yq=round(y./q);
ydq=yq.*q;
xdq=idct(idct(ydq')');
xe=xdq+128;
xf=uint8(xe);
figure(2);imagesc(xf);colormap(gray)
title('p=1')
xc=xb-128;
y=dct(dct(xc')');
p=2;
q=p*8./hilb(8);
yq=round(y./q);
ydq=yq.*q;
xdq=idct(idct(ydq')');
xe=xdq+128;
xf=uint8(xe);
figure(3);imagesc(xf);colormap(gray)
title('p=2')
xc=xb-128;
y=dct(dct(xc')');
p=4;
q=p*8./hilb(8);
yq=round(y./q);
ydq=yq.*q;
xdq=idct(idct(ydq')');
xe=xdq+128;
xf=uint8(xe);
figure(4);imagesc(xf);colormap(gray)
title('p=4')
xc=xb-128;
y=dct(dct(xc')');
p=10;
q=p*8./hilb(8);
yq=round(y./q);
ydq=yq.*q;
xdq=idct(idct(ydq')');
xe=xdq+128;
xf=uint8(xe);
figure(5);imagesc(xf);colormap(gray)
title('p=10')