Return to Digital Photography Articles
JPEG Minimum Coded Unit (MCU) and Partial MCU
This page should gives some background on how JPEG images are actually defined by 8x8 pixel blocks called the Minimum Coded Unit. This article should help one understand what happens with lossless rotation on odd-sized images.
The breakdown of an image into MCUs
Every JPEG image is actually stored as a series of compressed image tiles that are usually only 8x8 pixels in size. The proper name for one of these tiles is the MCU or Minimum Coded Unit. When one refers to image blocking artifacts, they are really talking about visual discontinuities observed between one or more of these tiles. You can see the edges or boundaries of these tiles in JPEG images that have been compressed at a very low quality.
|JPEG Image||JPEG Image at Low Quality|
The images below show the 8x8 boundaries of the MCU tiles
If you look carefully at the low-quality JPEG image, you will notice some of the boundaries of the MCU, as you will see abrupt changes in color and / or intensity. This is because each of these MCU tiles is compressed separately and different amounts of information is discarded from each tile.
Demonstrating the MCU boundaries
The Minimum Coded Unit size for JPEG images is usually 8x8, 16x8 or 16x16 pixels in size. The variations here (more specifically 16x8 and 16x16) are due to an optimization called chroma subsampling.
For JPEG compression and decompression algorithms to work, an image must be represented by an integer number of complete MCUs. In other words, the X and Y dimensions typically need to be a multiple of 8 pixels. Therefore, an image that is sized 501 x 375 must be first changed into an image sized 504 x 376 before it can be compressed. In this example, 501 = 62 horizontal MCUs + 3 extra pixels and 375 is 46 vertical MCUs + 1 extra pixel.
Partial MCU and Odd-sized JPEG images
In the case where there are not enough pixels in a row or column to complete a full tile, a partial MCU is used. A partial MCU is automatically extended to be the size of a full MCU but then the overall image dimensions are used to indicate where to cut off the extra later. This extension is generally done by repeating the last pixel of the row or column as necessary.
For the purposes of this discussion, I refer to images that contain partial MCU as an odd-sized image. In other words, if an image's overall dimensions are not a multiple of 8x8, then it is likely to contain partial MCU and therefore be termed an odd-sized image.