x = imread('project5original.jpg');
xd=double(x);
r=xd(:,:,1);
g=xd(:,:,2);
b=xd(:,:,3);
Xgray =0.2126*r+0.7152*g+0.0722*b;
imagesc(uint8(Xgray)); colormap(gray);

xb = Xgray(160:167,74:81);
figure(1);imagesc(uint8(xb), [0,255])

%Part B
xb1 = double(xb);
xc = xb1 - 128;
y = dct(dct(xc')');

%Part C
%p = 1;
%p = 2;
p = 4;
Q = p*8./hilb(8);
yq=round(y./Q)

  
%Part D
yq1 = double(yq);
ydq = yq1.*Q;
xdq = idct(idct(ydq')');
xe = xdq + 128;
figure(2);imagesc(uint8(xe), [0,255]);colormap(gray);
 
 
