VFX JPEG Demystified -

JPEG Demystified

JPEG is standardized image compression format. JPEG stands for (Joint photographic experts group), the name of the committee that wrote the standard. It works well on photographs and images with complex shading and texturing. The file extension for this format is .jpg

The advantages of using jpeg image compression format are:-

1. Reduction of file size.
2. It stores 24bits/pixel instead of 8bits/pixel.

Making files smaller helps in faster transmission of images through networks while taking lesser space on disk.

nullThere are two kinds of compression, lossy and lossless. In lossy compression the resulting compressed image does not carry all the detail as the original while in lossless it does. Jpeg has both kinds of compression lossy as well as lossless, but generally because most times jpeg is used for reducing file size (as in the weight of the file) even while retaining the same look, the compression is lossy.

The lossy compression is performed by exploiting the fact that small colour details are perceived less by the human eye then small details of light & darkness. The fact is that when it comes to representing real world scenes, no digital image format can retain all information that is captured by the human eye. When it comes to images that depict the real world scenes, JPEG compression loses far less information then 8bit images which have a limited palate of 256 colours to create the image from.

While jpeg is good for images with complex gradients and many colors, GIF is a better format to work with for images with distinct shapes and flat colours.

Compression:-For full colour images, the uncompressed data is normally 24bits/pixel.
Jpeg has a compression ratio of approx 10:1 to 20:1, and while it can store up to 24 bits per pixel, it has the capacity to even bring the storage down to 1 to 2 bits/pixel when highly compressed. It can also have a compression ratio of about 30:1 with visible defects in the image which are known as artifacts. Jpeg compress more hue data then brightness data.

A grey scale image is generally 10-25% smaller then a full colour image.

JPEG has basically two image compression formats viz:-

1. Progressive JPEG
2. Baseline JPEG

The difference in the way these 2 variations of the JPEG compression work is little.

Progressive JPEG additionally re-orders the compressed data. Baseline JPEG, while decoding, draws line after line until the entire image is shown.

Progressive creates whole image at once, but in very low quality (blurry). In next turn, another layer of data is added over previous one and quality is improved. In the end we have full quality image created on screen. Progressive JPEG is used in web publishing and designs. Internet connections are often slow and congested. Using progressive technique, user can make out the image before it’s fully downloaded, and thus save time and money. Almost all JPEG images found on web are progressive.

JPEG2000

Created in 2001 by the JPEG committee JPEG2000 is intended to be a new and improved image compression method that adds to the existing power of the JPEG format. The file extension for this format is .jp2

1. Jpeg 2000 offers both lossy and lossless compression in the same file stream, while JPEG usually utilizes lossy compression. JPEG does have a lossless compression engine but it is not often used. Thus when high quality is a concern, jpeg 2000 proves to be a much better compression tool. Due to manner in which a lossy compression engine works in JPEG2000, the final output image is rich. Hence even while carrying the same amount of image detail as the jpeg, the jpeg2000 format reduces file size considerably resulting in similar out-put at lesser payload.

2. JPEG2000 is able to offer high compression ratio for lossy compression, it can compress images from approx 20% to 200% more then JPEG.

3. JPEG2000 has the ability to display images at different resolutions & sizes even as it draws information from the same source file.

For example: if an image was available for download on internet, some one having faster speed could download full resolution, while someone with a slower connection could choose to save time by having a lower image resolution. But to do this in jpeg one has to make many files of same image. Using JPEG2000 the same image file could be used & user can choose the resolution to display image.

4. ROI Capability (REGION OF INTREST)
Using JPEG2000 one can select a certain area of image to view at a higher resolution while leaving the rest of the image at a lower quantity, so that user can view necessary part of the entire image. This helps in amount of memory required and also the timed consumed.

5. When any image is being downloaded from the internet, noise may be introduced into the image files causing small errors .Conversion of the file for use in other application is another way in which small errors may be brought into image file.JPEG2000 reduces these errors to certain extent and tries to make the image file as pure as possible.

STEPS FOR JPEG COMPRESSION

1. The jpeg algorithm divides an image into separate blocks of 8×8 pixels. Next, it converts the image data into luminance & chrominance space, such as YUV(Y-Brightness & others being the colour data). The reason for doing this is that it allows the compression in two factors, luminance & colour.

Since the human eye notices differences in luminance (brightness) more prominently than differences in color, the compression format tweaks more of the color data and tries to retain most of the luminance data.

2. The compression algorithm next applies DCT (Discrete Cosine Transform), a mathematical method, which works on every individual pixel. The method replaces the actual colour data of each pixel with the values that are the average of the entire block which is being worked upon.

3. Thirdly the algorithm looks at the image quality defined by user and accordingly it calculates two tables of quantization constants, one for luminance and the other
for chrominance. Using the values from the table, each DCT coefficient is quantized with its corresponding values from the table formed. The result obtained after quantizing the DCT co-efficients are rounded off to the nearest integer value. Sometimes the values obtained from the result are so small that it has to be rounded to ‘0’and the larger values due to rounding off no longer remain precise. It is this rounding off, that causes a loss in the image quality.

4. The last step in this process is to compress the resultant values obtained from step 3 using a type of encoding scheme.

And that’s what works in the background every time we convert our images into jpegs.

Jpeg Image courtesy: www.thisislancashire.co.uk

connect@animationxpress.com

VFX