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 specifically16x8 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.
For more information about partial minimum coded units and how they affect image rotation, please see: Lossless rotation & Partial MCU and Digicams and Lossless Rotation.
Reader's Comments:
Please leave your comments or suggestions below!I have a question about the luma (Y) and two chrominance (UV) components, how they are related to MCU? Each YUV component will have one MCU each? How can we find the total number of MCU in image corresponding to luma (Y) and two chrominance (UV) components.
I have all the informations extracted from the jpg header and now I would need to know what should I do. I mean "You should read the first bit from the stream and than...".
Could you please help me or give me some pages where to find this informations ? Thanks.
I have a question, if a mcu is equal to a block, i can use a block instead of mcu ,what's the mcu existing for? Is there other function on mcu?
Thank you!
To get the dimension, multiply this by 8x8 pixels for each block. So we end up with a 16x16 pixel MCU. Hope that is helpful!
You explain so well on JPEG MCU,
I learn a lot from it, THANKS !!!
However, I got a question here
Is it necessary to define MCU?
why don't we just apply DCT on the whole image?
I guess i miss something in the middle.
Thanks in advance ,
peace
Ray
By using a much larger block size (or the full image size!), you would not easily be able to achieve the same compression quality.
In hardware implementations, the breaking down of the image into blocks has the added advantage of enabling the encoder or decoder to work on several blocks in parallel, thereby increasing compression performance significantly.
Its really good explanation, One can easily understand about MCU.
-Ameen
really interesting and informative stuff about jpeg. learnt quite a bit.
cheers,
natasha