Quantization (image processing): Difference between revisions

Content deleted Content added
Added MPEG-2 to available tools that take in custom QMatrix graphs.
Line 10:
== Frequency quantization for image compression ==
 
The human eye is fairly good at seeing small differences in [[brightness]] over a relatively large area, but not so good at distinguishing the exact strength of a high frequency (rapidly varying) brightness variation. This fact allows one to getreduce away with a greatly reducedthe amount of information inrequired by ignoring the high frequency components. This is done by simply dividing each component in the frequency ___domain by a constant for that component, and then rounding to the nearest integer. This is the main lossy operation in the whole process. As a result of this, it is typically the case that many of the higher frequency components are rounded to zero, and many of the rest become small positive or negative numbers.
 
As human vision is also more sensitive to [[luminance]] than [[chrominance]], further compression can be obtained by working in a non-RGB color space which separates the two (e.g. [[YCbCr]]), and quantizing the channels separately.<ref name="wiseman">John Wiseman, ''An Introduction to MPEG Video Compression'', http://www.john-wiseman.com/technical/MPEG_tutorial.htm, retrieved 6 Nov 2010.</ref>
 
=== Quantization matrices ===
 
A quantizationtypical matrixvideo iscodec usedworks by breaking the picture into discreet blocks (8×8 pixels in combinationthe withcase aof DCTMPEG<ref coefficientname="wiseman"/>). matrixThese blocks can then be subjected to carry[[discrete cosine transform]] (DCT) to separate out the previouslylow mentionedfrequency transformationand high frequency components in both the horizontal and vertical direction.<ref name="wiseman"/> QuantizationThe resulting block (the same size as the original block) is then divided by the quantization matrix, and each entry rounded. The coefficients of quantization matrices are often specifically designed to keep certain frequencies in the source to avoid losing image quality. Many video encoders, such as [[MPEG-2]], [[DivX]], [[Xvid]], [[3ivx]] and [[H.264/AVC]] allow custom matrices to be used. Alternatively, the extent of the reduction may be varied by multiplying the quantizer matrix by a scaling factor, the quantizer scale code, prior to performing the division.<ref name="wiseman"/>
 
This is an example of DCT coefficient matrix: <!--NOTE: this matrix was generated using random numbers and the other two matricies. It may not actually work well with an iDCT. -->
Line 31 ⟶ 33:
</math>
 
A common quantization matrix is: <!-- A source for the "common" justification would be nice. Wiseman gives the default MPEG matrix, which varies from the one below. -->
A common quantization matrix is:
 
:<math>
Line 46 ⟶ 48:
</math>
 
UsingDividing thisthe quantizationDCT coefficient matrix element-wise with thethis DCT coefficientquantization matrix, and rounding fromto aboveintegers results in:
 
:<math>
Line 77 ⟶ 79:
</math>
 
Typically this process will result in matrices with values primarily in the upper left (low frequency) corner. By using a zig-zag ordering to group the non-zero entries and [[run length encoding]], the quantized matrix can be much more efficiently stored than the non-quantized version.<ref name="wiseman"/>
 
{{Compression Methods}}