x = imread('DHSquare.jpg'); 
% Original image is multiples of 8 
x=double(x);
r=x(:,:,1); g=x(:,:,2); b=x(:,:,3);
xgray=0.2126*r+0.7152*g+0.0722*b;
figure(3);imagesc(uint8(xgray));colormap(gray)
title('Original');
n=1;
sizeImage=size(xgray);
Xf=zeros(sizeImage(1));
for p = [1];
    p(n)
    for k=0:(sizeImage(1)/8)-1
        for l=0:(sizeImage(2)/8)-1
        c=xgray(8*k+1:8*k+8,8*l+1:8*l+8);
        c=dctV2(p(n),c);
        Xf(8*k+1:8*k+8,8*l+1:8*l+8)=c;    
        end
    end
figure(p(n));imagesc(uint8(Xf));colormap(gray)
title('JPG Quantization, p=1');
end



