How to undo the quantization step in DCT?
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.