# How to undo the quantization step in DCT?

How can I do point by point multiplication of the quantized DCT coefficients with the quantization matrix before computing the inverse DCT for each block? I want to modify the reconstruction algorithm to approximately undo the quantization step shown here:

for i = 1:Blocks
for j=1:Blocks
irange = (i-1)*8+1:(i-1)*8+8;
jrange = (j-1)*8+1:(j-1)*8+8;
quantblock = round(y(irange,jrange)./Q);
quant_DCTblocks(irange,jrange) = quantblock;
end
end
figure
imagesc(quant_DCTblocks)
colormap(gray)
set(gca,'Xtick',[])
set(gca,'Ytick',[])
axis('square')
title('quantized DCT Coeffs')


From the code it looks like the quantization step is doing two things: 1) dividing by "Q", and 2) rounding. Undoing the divide by Q is easy. The rounding is where the actual quantizing is happening though, and unfortunately that is the part that you cannot undo- at least not without more information. Rounding causes information to be lost and you cannot undo that.

• So can you explicitly tell me which lines of the code should be changed? except rounding ? – Mona Jalal Mar 8 '14 at 4:43
• If you don't want to quantize just don't round. – Jim Clay Mar 8 '14 at 7:16