Industrial Training




Intoduction to JPEG



JPEG (pronounced "jay-peg") is a standardized image compression mechanism. JPEG stands for Joint Photographic Experts Group, the original name of the committee that wrote the standard. The committee wrote the standard in late eighties and early nineties. The format is ISO standard 10918. Considering there was no adequate standard for compressing 24-bit per pixel colour data, committee came up with algorithm for compressing full colour or greyscale images depicting real world scenes (like photographs). JPEG works well on photographs, naturalistic artwork, and similar material; not so well on lettering, simple cartoons, or line drawings. JPEG handles only still images, but there is a related standard called MPEG for motion pictures.

 

JPEG is "lossy," meaning that the decompressed image isn't quite the same as the one you started with. (There are lossless image compression algorithms, but JPEG achieves much greater compression than is possible with lossless methods.) JPEG is designed to exploit known limitations of the human eye, notably the fact that small color changes are perceived less accurately than small changes in brightness. Thus, JPEG is intended for compressing images that will be looked at by humans. If you plan to machine-analyze your images, the small errors introduced by JPEG may be a problem for you, even if they are invisible to the eye. The main benefit JPEG exploits from human eye (in) sensitivity to certain images producing a powerful compression ratio even to 100:1 (usually 10:1 to 20:1 without noticeable degradation).

 

A useful property of JPEG is that adjusting compression parameters can vary the degree of lossiness. This means that the image maker can trade off file size against output image quality. You can make extremely small files if you don't mind poor quality; this is useful for applications such as indexing image archives. Conversely, if you aren't happy with the output quality at the default compression setting, you can jack up the quality until you are satisfied, and accept lesser compression.

Another important aspect of JPEG is that decoders can trade off decoding speed against image quality, by using fast but inaccurate approximations to the required calculations. Some viewers obtain remarkable speedups in this way.

 

A growing class of multimedia telecommunications applications such as video conferencing requires real time compression and decompression of moving pictures. Many of those applications use JPEG or a related image compression method. JPEG is a widely used file format for storing images digitally.

  

JPEG images have become a default standard for a variety of mediums, mainly the Internet and other applications where it is necessary to have images of high quality, but low data size. The advantages of this include low transmission times for Internet web browsing and the development of useful Digital Cameras that can store a number of images on a relatively low amount of on-board memory. Without JPEG compression many aspects of computer imaging would be severely hampered, if not impossible.

 

JPEG files generally have the file extension. jpeg or .jpg, but. jfif is also used occasionally, which stands for JPEG File Interchange Format.

 

JPEG Modes:

 

JPEG is the very well known ISO/ITU-T standard created in the late 1980s. There are several modes defined for JPEG 3.0, including baseline, lossless, progressive and hierarchical. The JPEG standard defines four variations for compression of images. These are known as follows,
 

1.        Sequential DCT based mode: This is the JPEG baseline format. The baseline mode is the most popular one and supports lossy coding only. The Baseline algorithm analyzes the image in just one top-to-bottom pass.
 

2.      Sequential lossless mode: This format is defined for applications in which it would be desirable to have no image detail lost in the compression process. This is not widely used as the compression statistics for this method is modest compared to the other styles.
 

3.      Progressive DCT based mode: This format is very similar to the Baseline mode, however instead of processing information in one scan of the image, this mode processes in a serious of scans, each one better defining the image from the last scan that was processed.
 

4.      Hierarchical mode: This format allows a number of different resolution images to be held within one file. This means that only one image file needs to be made for a number of resolutions it could be viewed at. Again it uses more than one scan to define the image, the decoder simply uses scans in order until it has reached the resolution it requires.
 

The JPEG standard specifies that all JPEG decoders MUST support the baseline version, even if it uses some of the other features within the JPEG standard.

 

The JPEG Baseline codec (compression/decompression algorithm) is a "lossy" compression, which means that images that are converted to the JPEG format will lose some of the data that described the image in the process. The driving idea behind the JPEG format is to take advantage of the simple fact that the human eye is not as sensitive to subtle color changes as it is to subtle intensity changes. Thus, very slight and gradual color changes are essentially lost to human viewers, so they might as well not be included in image files. The user is able to specify the amount of data that is thrown away, leading to a tradeoff between file size and image quality. The user can often set the amount of tradeoff when compressing an image. In much the same fashion as the encoding process, "JPEG decoders can trade off decoding speed against image quality by using fast but inaccurate approximations to the required calculations." The inevitable data loss is due to the fact that even when retaining maximum image quality during compression, some data will always be thrown out.

 

Two negative aspects result from this:

 

1)         If a picture is resized or otherwise edited after being JPEG compressed, it could take on an unacceptable image quality, due to the fact that it doesn't have all the image information available. This leads to the practice of keeping a master file in a format that holds all of the image data (such as a bitmap), and then making copies off of that into the JPEG format for distribution, as on a web page. This would only be done if the original were needed for something like image editing.

 

2) Repeated compressions of the same file, even at maximum image quality, will result in a serious loss of detail. This will begin to create "artifacts" in the image, which are instances of "false color and blockiness. These artifacts make smooth curves look jagged and blocky.

In the baseline mode, the image is divided in 8x8 blocks and each of these is transformed with the DCT. The transformed blocks are quantized with a uniform scalar quantizer, zig-zag scanned and entropy coded with Huffman coding. The quantization step size for each of the 64 DCT coefficients is specified in a quantization table, which remains the same for all blocks. The DC coefficients of all blocks are coded separately, using a predictive scheme. Generally this mode can be referred as JPEG.

 

Why use JPEG?

  There are two good reasons: to make your image files smaller, and to store 24-bit-per-pixel color data instead of 8-bit-per-pixel data.

 

Making image files smaller is a win for transmitting files across networks and for archiving libraries of images. Being able to compress a 2 Mbyte full-color file down to, say, 100 Kbytes makes a big difference in disk space and transmission time! And JPEG can easily provide 20:1 compression of full-color data. If you are comparing GIF and JPEG, the size ratio is usually more like 4:1.

 

If your viewing software doesn't support JPEG directly, you'll have to convert JPEG to some other format to view the image. Even with a JPEG-capable viewer, it takes longer to decode and view a JPEG image than to view an image of a simpler format such as GIF. Thus, using JPEG is essentially a time/space tradeoff: you give up some time in order to store or transmit an image more cheaply. But it's worth noting that when network or telephone transmission is involved, the timesaving from transferring a shorter file can be greater than the time needed to decompress the file.

 

The second fundamental advantage of JPEG is that it stores full color information: 24 bits/pixel (16 million colors). GIF, the other image format widely used on Usenet, can only store 8 bits/pixel (256 or fewer colors). GIF is reasonably well matched to inexpensive computer displays --- most run-of-the-mill PCs can't display more than 256 distinct colors at once. But full-color hardware is getting cheaper all the time, and JPEG images look much better than GIFs on such hardware. Within a couple of years, GIF will probably seem as obsolete as black-and-white MacPaint format does today. Furthermore, JPEG is far more useful than GIF for exchanging images among people with widely varying display hardware, because it avoids prejudging how many colors to use. Hence JPEG is considerably more appropriate than GIF for use as a Usenet posting standard.

 

A lot of people are scared off by the term "lossy compression". But when it comes to representing real-world scenes, no digital image format can retain all the information that impinges on your eyeball. By comparison with the real-world scene, JPEG loses far less information than GIF. The real disadvantage of lossy compression is that if you repeatedly compress and decompress an image, you lose a little quality each time. This is a serious objection for some applications but matters not at all for many others.

 

When should I use JPEG, and when should I stick with GIF?

 

JPEG is not going to displace GIF entirely; for some types of images, GIF is superior in image quality, file size, or both. One of the first things to learn about JPEG is which kinds of images to apply it to.

 

Generally speaking, JPEG is superior to GIF for storing full-color or gray-scale images of "realistic" scenes; that means scanned photographs and similar material. Any continuous variation in color, such as occurs in highlighted or shaded areas, will be represented more faithfully and in less space by JPEG than by GIF.

 

GIF does significantly better on images with only a few distinct colors, such as line drawings and simple cartoons. Not only is GIF lossless for such images, but it often compresses them more than JPEG can. For example, large areas of pixels that are all exactly the same color are compressed very efficiently indeed by GIF. JPEG can't squeeze such data as much as GIF does without introducing visible defects. (One implication of this is that large single-color borders are quite cheap in GIF files, while they are best avoided in JPEG files.)

 

Computer-drawn images, such as ray-traced scenes, usually fall between photographs and cartoons in terms of complexity. The more complex and subtly rendered the image, the more likely that JPEG will do well on it. The same goes for semi-realistic artwork (fantasy drawings and such). But icons that use only a few colors are handled better by GIF.

 

JPEG has a hard time with very sharp edges: a row of pure-black pixels adjacent to a row of pure-white pixels, for example. Sharp edges tend to come out blurred unless you use a very high quality setting. Edges this sharp are rare in scanned photographs, but are fairly common in GIF files: consider borders, overlaid text, etc. The blurriness is particularly objectionable with text that's only a few pixels high. If you have a GIF with a lot of small-size overlaid text, don't JPEG it. (If you want to attach descriptive text to a JPEG image, put it in as a comment rather than trying to overlay it on the image. Most recent JPEG software can deal with textual comments in a JPEG file, although older viewers may just ignore the comments.)

 

Plain black-and-white (two level) images should never be converted to JPEG; they violate all of the conditions given above. You need at least about 16 gray levels before JPEG is useful for gray-scale images. It should also be noted that GIF is lossless for gray-scale images of up to 256 levels, while JPEG is not.

 

If you have a large library of GIF images, you may want to save space by converting the GIFs to JPEG. This is trickier than it may seem --- even when the GIFs contain photographic images, they are actually very poor source materials for JPEG, because the images have been color-reduced. Non-photographic images should generally be left in GIF form. Good-quality photographic GIFs can often be converted with no visible quality loss, but only if you know what you are doing and you take the time to work on each image individually. Otherwise you're likely to lose a lot of image quality or waste a lot of disk space ... quite possibly both.

 

How well does JPEG compress images?

 

Very well indeed, when working with its intended type of image (photographs and such like). For full-color images, the uncompressed data is normally 24 bits/pixel. The best known lossless compression methods can compress such data about 2:1 on average. JPEG can typically achieve 10:1 to 20:1 compression without visible loss, bringing the effective storage requirement down to 1 to 2 bits/pixel. 30:1 to 50:1 compression is possible with small to moderate defects, while for very low quality purposes such as previews or archive indexes, 100:1 compression is quite feasible. An image-compressed 100:1 with JPEG takes up the same space as a full-color one-tenth-scale thumbnail image, yet it retains much more detail than such a thumbnail.

 

For comparison, a GIF version of the same image would start out by sacrificing most of the color information to reduce the image to 256 colors (8 bits/pixel). This provides 3:1 compression. GIF has additional "LZW" compression built in, but LZW doesn't work very well on typical photographic data; at most you may get 5:1 compression overall, and it's not at all uncommon for LZW to be a net loss (i.e., less than 3:1 overall compression). LZW does work well on simpler images such as line drawings, which is why GIF handles that sort of image so well. When a JPEG file is made from full-color photographic data, using a quality setting just high enough to prevent visible loss, the JPEG will typically be a factor of four or five smaller than a GIF file made from the same data.

 

Gray-scale images do not compress by such large factors. Because the human eye is much more sensitive to brightness variations than to hew variations, JPEG can compress huge data more heavily than brightness (gray-scale) data. A gray-scale JPEG file is generally only about 10%-25% smaller than a full-color JPEG file of similar visual quality. But the uncompressed gray-scale data is only 8 bits/pixel, or one-third the size of the color data, so the calculated compression ratio is much lower. The threshold of visible loss is often around 5:1 compression for gray-scale images.

 

The exact threshold at which errors become visible depends on your viewing conditions. The smaller an individual pixel, the harder it is to see an error; so errors are more visible on a computer screen (at maybe 70 dots/inch) than on a high-quality color printout (300 or more dots/inch). Thus a higher-resolution image can tolerate more compression ... which is fortunate considering it's much bigger to start with. The numbers quoted above are typical for screen viewing. Also note that the threshold of visible error varies considerably across images.

 

What are good "quality" settings for JPEG?

 

Most JPEG compressors let you pick a file size vs. image quality tradeoff by selecting a quality setting. There seems to be widespread confusion about the meaning of these settings. "Quality 95" does NOT mean "keep 95% of the information", as some have claimed. The quality scale is purely arbitrary; it's not a percentage of anything.
 

In fact, quality scales aren't even standardized across JPEG programs. Apple's and HSI's, use completely different quality scales; for instance, Apple's scale runs from 0-4, not 0-100. Some programs don't even provide a numeric scale, just "high"/"medium"/"low" style choices.

 

In most cases the user's goal is to pick the lowest quality setting, or smallest file size, that decompresses into an image indistinguishable from the original. This setting will vary from one image to another and from one observer to another.

 

What is the future of JPEG?

 

The current JPEG standard provides excellent performance at rates above 0.25 bits per pixel. However, at lower rates there is a sharp degradation in the quality of the reconstructed image. To correct this and other shortcomings, the JPEG committee initiated work on another standard, commonly known as JPEG 2000. To date, only a few aspects of JPEG 2000 are certain, including the intention to base the standard on wavelet decomposition. The remainder of the JPEG 2000 standard is in the process of being reviewed.

 

Hardware Requirements:

 

An uncompressed JPEG file is represented as a 24-bits-per-pixel full color image. In order to represent this on the screen, a VGA (Video Graphics Array) adapter card with VESA (Video Electronics Standards Association) compatibility or greater must be used. Different resolutions require different amounts of video RAM.

 

Resolution

Color depth

VRAM

640x480

24-bit

1M

800x600

24-bit

2M

1024x768

24-bit

4M

 

In addition, JPEG conversions include repetitive amounts of integer arithmetic. A digital signal-processing chip can significantly speed up such processes, by way of optimizing the frequencies in which data is stored without any loss of data. The DSP chip would need to be programmed for JPEG operations to maximize its usage and efficiency.

 

Limitations & Advantages:

 

JPEG files have some general limitations. As mentioned earlier, compressing line drawings, cartoons, or large blocks of text with the JPEG code does not produce quality results. Artifacts tend to be introduced into the image in these cases. These types of images are more suited to GIF compression.

 

Some of the limitations of JPEG encoding come from the limitations of Huffman encoding itself (suppose that a JPEG algorithm uses Huffman encoding). One of these limitations is that the table holding the compressed data's frequencies must be transmitted with the file; thus the file is not actually as small as it could be. Another drawback introduced with Huffman is that the encoder must make two passes through all the data, once to generate the frequency table and once to actually code the data. The third Huffman drawback is that when the data is distributed very evenly (large areas of similar color) the Huffman process won't compress the file very much.

 

One of the advantages that the JPEG standard has over the GIF code technique is that while the GIF encoding is limited to 256 colors (once again contributing to its suitability for cartoons and line drawings), JPEGs support infinite number of colors.

 

JPEG files also consistently offer smaller file sizes than bitmaps, as some amount of compression will always occur. Bitmaps, on the other hand, have the previously mentioned advantage of storing all of the data that the JPEG format does not. Thus, master files to be used in image editing would be more useful as bitmaps than JPEGs.


 

 

JPEG Fundamentals

 

The JPEG standard is applicable to both grey scale and colour images. Breaking a picture down into a number of components does this. When each component is put together, the end image can be viewed. For example a black and white image would have only one component which would depict the grey scale of the image, whereas a colour image generally has three components (one for each primary colour, red green and blue or equivalent). Each component is made up of x columns and y rows of samples. These samples are simply the actual "pixel" data of the image.

 

In JPEG Baseline the number of samples is the same as the resolution of the image. A single pass through a component and its samples is known as a scan. In JPEG Baseline this does not mean a great deal as only one scan of the image is used.

 

In JPEG encoding the data is broken into a number of blocks called Minimum Coded Units (MCU’s). These MCU’s are simply made by taking a number of 8x8 pixel sections of the source image. MCU’s are used to break down the image into workable blocks of data as well as to allow manipulation of local image correlation at a given part of the image by the encoding algorithm. When processing each MCU, the algorithm always moves through the component from the left to right, then top to bottom order.

 

There are two methods of processing MCU’s and components.

·        The first method is whereby each MCU contains data from a single component only, and hence is comprised of only one unit of data.
·        The second method is where the data from each component is interleaved within a single MCU. This means that each MCU contains all the data for a particular physical section of an image, rather than a number of MCUs containing each component of that section.
 

This project uses the latter option. Further to this, there are horizontal and vertical sampling factors. These sampling factors dictate how many 8x8 pixel sections are to be placed within an MCU when the component data is interleaved.

 

Image Orientation

 

In JPEG files, the image orientation is always top-down. This means that the first image samples encoded in a JPEG file are located in the upper left hand corner of the image and encoding/decoding proceeds from left to right and top to bottom. Top-down orientation is used for both the full resolution image and the thumbnail image.  



Hi I am Pluto.