# Does every 8 by 8 DCT matrix have a valid (in range) IDCT?

For a given quantization level of JPEG compression, are all possible DCT matrices have valid IDCTs. By valid, I mean matrices whose elements are in the range [0,255] ?

• The possible DCT matrices depend on the quantization method. Thus, your question is inanswerable – JPEG doesn't restrict the quantization matrices at all, and it's up to any compressor to choose the quantization matrix for a quantization level; those aren't standardized. – Marcus Müller Mar 9 '17 at 22:34
• I believe the context could be clarified: By valide, do you mean integer? If not, some floating-points issues may prevent the IDCT from being always integer. What is the quantization level? The percentage proposed in most JPEG compression interfaces? – Laurent Duval Mar 10 '17 at 8:28
• @LaurentDuval extrapolating from the previous question, the point is that when 2D-DCT transforming an 8x8 matrix, the entries of the resulting matrix aren't inherently all within the 8-bit range. The question is whether "image (sufficiently bounded) ->DCT -> differing quantization per bin ->IDCT" might lead to images that are not sufficiently bounded, due to the quantization possibly adding energy – Marcus Müller Mar 10 '17 at 9:36

## 1 Answer

• All images blocks that are applied by DCT matrix have a valid IDCT - i.e. they can always bring back original pixels and in general inverse transfer is theoretically as well as computationally viable.

• However, while your pixels have values in range 0-255 - the DCT matrix of the block never results in values which are confined between 0-255. Not only that, they are not even integers - they are real values. So while they are valid numbers, they can't be stored in the same container as pixels.

• Given that they are real numbers, it would be useless to be used for compression against integers of the original source. So hence they are confined in a particular range and then divided by a specific number - this is a process of quantization. Hence, what really goes inside your JPG or MPG are quantized co-eofficients.

• The quantization is not equal. Certain components are preserved more than others (with finer quantization) - hence dynamic range of each component, though finite, is not 0-255 but different for each DCT co-efficient. this is practically taken care by Huffman coding which maps these values into binary bits.

• So they are valid in 'general' definition but not what you are interpreting as.