iSnare.com - Free Content Articles Directory
Authors Contents [Advanced Search][Add OpenSearch][Job Search]
Distribute your articles to thousands of article sites for only $2 and below! Read more...

Index  Computers and Technology
 

How Does JPEG Work? A Very Rough Answer

 
[ Contact the Author] [ Send to a Friend] [ Article Publisher] [Make PDF] [ Print] [ Bookmark & Share]
 
Read our Terms of Service before reprinting this article. The submitter specified above has claimed the rights to this article.
Andrew Spivak

We will have a look on how JPEG works in the simplest settings. Forget about color images, let's stick to grey-scale images. What is such an image? It is actually a table with numbers, representing brightness of the corresponding points, which vary from 0 to 255. What do we have to do? We have to develop two processes: the first (encoding) will transform an image (table with numbers) to a sequence of 0s and 1s, which is JPEG file. And aim is that such a sequence is not too long, i.e., it represents our picture in a compressed way. The second (decoding) will take JPEG file, the sequence of 0s and 1s, and will recover an image from it. Decoding is an inverse of encoding, so we concentrate on encoding process.

The core of the algorithm operates with small blocks of the image of size 8*8 pixels. There are three main steps: DCT, quantization, Huffman encoding. Sounds as abracadabra, lets look behind this.

DCT - discrete cosine transform. This is a tricky way to transform our image to another "image" of the same size (8*8), with new "colors" being called DCT-coefficients. Such transformation in a way simplifies the picture. In the following sense: if you have that all initial colors are close to some fixed color, the transformed "image", i.e., DCT-coefficients will have many close to zero numbers among themselves. It is easier to encode many zeros and few non-zeros (just trust in this).

Quantization - replacing DCT-coefficients by "rounded" numbers. For example, you have a DCT-coefficient which can be a number from -1023 to 1023. This gives you 2047 possibilities, and generally requires 12 bits (0s and 1s) to be stored in computer memory. OK, but let's say: we don't need to know that number exactly, some close number would be enough. Then one picks how rough we want to go, say we want to be not farther then 5. Then we can round up to 10. I.e., if we have 437, replace it by 440, if we have -171, replace it by -170. This way we have less possibilities - only numbers -1020, -1010, ..., -10, 0, 10, 20, ..., 1020. There are 205 cases then (much less than 2047), and 8 bits are enough to represent such a number. That's the idea. So, on quantization step, DCT-coefficients are rounded. This is where we loose some information, i.e., we would not be able to recover original image from quantized DCT-coefficients. But still, they are close enough to the real DCT-coefficients, so that the inverse DCT transform will give an image pretty close to our original one.

Huffman encoding - a way to store what is obtained after quantization. (There is in fact a small preliminary stage between quantization and Huffman encoding, called RLE, but we omit it now.) The goal is to code something which is frequent by bit combinations which are short. Example: you need to code a sequence of 100 letters, written using only a,b,c,d,e,f,g,h, 8 letters. Straightforward approach: 8 possibilities, 3 bits for each possibility, a=000, b=001, c=010, d=011, e=100, f=101, g=110, h=111, then you can always encode 100 letters using 100*3 = 300 bits. In practice, it may happen that 'a' appears much more frequently than other letters in your sequence. Then it is reasonable to spend less than 3 bits for such a letter. Of course, then you may need more bits for a rare letter, but overall you may win. This is the idea behind Huffman encoding - code frequent letters with shorter bit combinations. "Letters" in JPEG Huffman encoding are not letters, but properly arranged quantized DCT-coefficients.

That's all the magic. Without details. In summary, the ideas of JPEG compression algorithms are: special transform of the image (DCT), rounding the resulting numbers (quantization of coefficients) and smart coding of the result (Huffman) spending less info for more frequent "letters".

Important NoticeDISCLAIMER: All information, content, and data in this article are sole opinions and/or findings of the individual user or organization that registered and submitted this article at Isnare.com without any fee. The article is strictly for educational or entertainment purposes only and should not be used in any way, implemented or applied without consultation from a professional. We at Isnare.com do not, in anyway, contribute or include our own findings, facts and opinions in any articles presented in this site. Publishing this article does not constitute Isnare.com's support or sponsorship for this article. Isnare.com is an article publishing service. Please read our Terms of Service for more information.

JPEG, compression, archiving, ... - ever wondered how does it work? Andrew Spivak makes it clear at http://jpeg-explained.blogspot.com/ , where you can also find practical tips and advices.
Article Tags: bits [See Dictionary], image [See Dictionary], letters [See Dictionary]
Got a question about this article? Ask the community!
Article published on March 15, 2008 at Isnare.com
 
Rate [Ratings: 5 / 5] [Votes: 1]

How To Save Space On Digital Photos?
Submitted by: Andrew Spivak

As you probably know, JPEG file format is widely used in digital cameras because it can reduce the size of the files containing pictures dramatically...

School Surveillance Applications
Submitted by: Wesley Fernley

In this day in age it has almost become necessity that our schools, from the elementary level through the college level, include video surveillance for precautionary measures to help provide a secure environment for staff and especially for the students attending...

Using IP Surveillance Cameras in Check Cashing Locations
Submitted by: Wesley Fernley

As tax season approaches and during this challenging economy, payday loan check cashing locations are busier than ever...

How to Install Aftermarket Stereo in Vauxhall Agila
Submitted by: Jack Wylde

DESCRIPTION: The radio installation in VAUXHALL AGILA Some Cars have steering controls from new and when you replace your radio...

Don't Ruin Your Laminator - 4 Reasons to Always Use a Carrier With Your Pouch Laminating Machine
Submitted by: Jeff McRitchie

One of the most important supplies you'll need when getting ready to use a pouch laminator is a carrier...

GBC ShredMaster CC195 Cross-Cut Shredder Review
Submitted by: Jeff McRitchie

If you've visited an office supply store recently or checked out paper shredders on the Internet, it probably seems like paper shredders are all alike, especially in the looks department...

Frequently Asked Questions About Spiral Coil Binding
Submitted by: Jeff McRitchie

Coil binding - also known as spiral binding - is a very popular method of binding, but it can be difficult to understand how it's done...

An Overview of the GBC C-75 Comb Binding Machine
Submitted by: Jeff McRitchie

If you are looking for an inexpensive comb binding machine for your office or home office you might be considering the GBC C75...

5 Great Features of the Rhin-O-Tuff HD6500
Submitted by: Jeff McRitchie

Designed for the heaviest duty users such as print and copy shops, binderies and large organizations, the Rhino Tuff HD6500 is a machine that offers top of the line flexibility and capacity...

Comparing the Swingline SmartCut EasyBlade and EasyBlade Plus Rotary Trimmers
Submitted by: Jeff McRitchie

At first glance, Swingline's SmartCut EasyBlade and EasyBlade Plus may look very similar, except for the price...

Five Reasons to Consider the Rhino-Tuff OD4000 Modular Binding Punch
Submitted by: Jeff McRitchie

Though it may be the smallest of Rhino's electric interchangeable punches, the OD4000 offers you about as much as a binding punch can offer...

Carnival of New Digital Camera Camcorder
Submitted by: Leo Vegner

The category of camcorder is one broad category of the old and new, dynamic and basic offing in the world of digital photography...

DirectAccess Takes the Place of VPN For Windows Seven
Submitted by: Gregg Housh

Microsoft has unveiled Direct Access for Windows 7 and Windows Server 2008, remotely connecting users to their office as if they were right there...

Looking For Reliable Software To Restore Memory Cards Files
Submitted by: Lance Edwards

Well, bad things always happen There is no exception...

Where Can You Sell Your Used Toner Cartridges?
Submitted by: Adriana N

Many hi-tech devices now come with many accessories, components, and specific parts For instance, there are many computer related devices that over time will require new parts...

History of Dell Computers
Submitted by: Adriana Noton

Dell is a well-known computer company that has been around for over 20 years Most people recognize the name and thousands of people buy new Dell products every day...

Isnare.com Footer Divider

© 2004-2009. Isnare Free Articles - An Isnare Online Technologies Free Articles Project. All Rights Reserved.   Privacy Policy