%quantization loop
function Xe = Quantization(image,C,Q)
    
%quantization steps
Xd = image;    % change the image matrix from uint8 to double
Xc = Xd - 128; % centering the matrix
Y  = C*Xc*C';        % 2D-dct
Yq = round(Y./Q);      % quantization

%de-quantization steps
Ydq = Yq.*Q;
Xdq = C'*Ydq*C;
Xe  = Xdq + 128;
% Xf = uint8(Xe);

    