Sunday, September 1, 2013

Compression Techniques



Data compression squeezes data so it requires less disk space for storage and less bandwidth on a data transmission channel. Communications equipment like modems, bridges, and routers use compression schemes to improve throughput over standard phone lines or leased lines. Compression is also used to compress voice telephone calls transmitted over leased lines so that more calls can be placed on those lines. In addition, compression is essential for videoconferencing applications that run over data networks.
Most compression schemes take advantage of the fact that data contains a lot of repetition. For example, alphanumeric characters are normally represented by a 7-bit ASCII code, but a compression scheme can use a 3-bit code to represent the eight most common letters.
In addition, long stretches of "nothing" can be replaced by a value that indicates how much "nothing" there is. For example, silence in a compressed audio recording can be replaced by a value that indicates how long that silence is. White space in a compressed graphic image can be replaced by a value that indicates the amount of white space.
Compression has become critical in the move to combine voice and data networks. Compression techniques have been developed that reduce the data requirements for a voice channel down to 8 Kbits/sec. This is a significant improvement over noncompressed voice (64 Kbits/sec) and older compression techniques yielding 32 Kbits/sec.
Two important compression concepts are lossy and lossless compression:
  • Lossy compression    With lossy compression, it is assumed that some loss of information is acceptable. The best example is a videoconference where there is an acceptable amount of frame loss in order to deliver the image in real time. People may appear jerky in their movements, but you still have a grasp for what is happening on the other end of the conference. In the case of graphics files, some resolution may be lost in order to create a smaller file. The loss may be in the form of color depth or graphic detail. For example, high-resolution details can be lost if a picture is going to be displayed on a low-resolution device. Loss is also acceptable in voice and audio compression, depending on the desired quality.
  • Lossless compression    With lossless compression, data is compressed without any loss of data. It assumes you want to get everything back that you put in. Critical financial data files are examples where lossless compression is required.
The removal of information in the lossy technique is acceptable for images, because the loss of information is usually imperceptible to the human eye. While this trick works on humans, you may not be able to use lossy images in some situations, such as when scanners are used to locate details in images.
Lossy compression can provide compression ratios of 100:1 to 200:1, depending on the type of information being compressed. Lossless compression ratios usually only achieve a 2:1 compression ratio. Lossy compression techniques are often "tunable" in that you can turn the compression up to improve throughput, but at a loss in quality. Compression can also be turned downed to the point at which there is little loss of image, but throughput will be affected.

Basic Compression Techniques
The most basic compression techniques are described here:
  • Null compression    Replaces a series of blank spaces with a compression code, followed by a value that represents the number of spaces.
  • Run-length compression    Expands on the null compression technique by compressing any series of four or more repeating characters. The characters are replaced with a compression code, one of the characters, and a value that represents the number of characters to repeat. Some synchronous data transmissions can be compressed by as much as 98 percent using this scheme.
  • Keyword encoding    Creates a table with values that represent common sets of characters. Frequently occurring words like for and the or character pairs like sh or th are represented with tokens used to store or transmit the characters.
  • Adaptive Huffman coding and Lempel Ziv algorithms    These compression techniques use a symbol dictionary to represent recurring patterns. The dictionary is dynamically updated during a compression as new patterns occur. For data transmissions, the dictionary is passed to a receiving system so it knows how to decode the characters. For file storage, the dictionary is stored with the compressed file.
Compression and PDF 
Compression is the reduction in size of data in order to save space or transmission time. For data transmission, compression can be performed on just the data content or on the entire transmission unit depending on a number of factors.
Content compression can be as simple as removing all extra space characters, inserting a single repeat character to indicate a string of repeated characters, and substituting smaller bit strings for frequently occurring characters. This kind of compression can reduce a text file to 50% of its original size. Compression is performed by a program that uses a formula or algorithm to determine how to compress or decompress data. The algorithm is one of the critical factors to determine the compression quality.
To PDF files, compression refers to image compressing. PDF formats are usually designed to compress information as much as possible (since these can tend to become very large files). Compression can be either lossy (some information is permanently lost) or lossless (all information can be restored).
PDF is a page description language, like PostScript but simplified with restricted functionality to be more lightweight, which dues to not only a better data structure but also very efficient compression algorithms to reduce the file size to about half the size of an equivalent PostScript file. PDFs use the following compression algorithms:
  • LZW (Lempel-Ziv-Welch)
  • FLATE (ZIP, in PDF 1.2) 
  • JPEG and JPEG2000 (PDF version 1.5
  • CCITT (the facsimile standard, Group 3 or 4)
  • JBIG2 compression (PDF version 1.4)
  • RLE (Run Length Encoding)
All of these compression filters produce binary data, which can be further converted to ASCII base-85 encoding if a 7-bit ASCII representation is required.
The above algorithms can be divided into two distinct categories: lossless or lossy.
Lossless algorithms do not change the content of a file. If you compress a file and then decompress it, it has not changed. The following algorithms are lossless:
  • CCITT group 3 & 4 compression
  • Flate compression
  • LZW compression
  • RLE compression
  • ZIp
Lossy algorithms achieve better compression ratio's by selectively getting rid of some of the information in the file. Such algorithms can be used for images or sound files but not for text or program data. The following algorithms are lossy:
  • JPEG compression
It is in how well you use these compression techniques, how efficiently the data is described, and the complexity of the document (read number of fonts, forms, images, and multimedia) that ultimately determines how large your resulting PDF file will be.
Compression algorithm introduction
The compression algorithms can be described in detail below.
  • ZIP
ZIP works well on images with large areas of single colors or repeating patterns, such as screen shots and simple images created with paint programs, and for black-and-white images that contain repeating patterns. Acrobat provides 4-bit and 8-bit ZIP compression options. If you use 4-bit ZIP compression with 4-bit images, or 8-bit ZIP with 4-bit or 8-bit images, the ZIP method is lossless, which means it does not remove data to reduce file size and so does not affect an image's quality. However, using 4-bit ZIP compression with 8-bit data can affect the quality, since data is lost.
Note: Adobe implementation of the ZIP filter is derived from the zlib package of Jean-loup Gailly and Mark Adler, whose generous assistance we gratefully acknowledge.
  • CCITT
 (International Coordinating Committee for Telephony and Telegraphy) is appropriate for black-and-white images made by paint programs and any images scanned with an image depth of 1 bit. CCITT is a lossless method. Acrobat provides the CCITT Group 3 and Group 4 compression options. CCITT Group 4 is a general-purpose method that produces good compression for most types of monochrome images. CCITT Group 3, used by most fax machines, compresses monochrome images one row at a time.
  • RLE
RLE (Run Length Encoding) is a lossless compression option that produces the best results for images that contain large areas of solid white or black.
  • JPEG
JPEG stands for Joint Photographic Experts Group, which is a standardization committee. It also stands for the compression algorithm that was invented by this committee.
There are two JPEG compression algorithms: the oldest one is simply referred to as "JPEG" within this page. The newer is JPEG 2000 algorithm
JPEG is a lossy compression algorithm that has been conceived to reduce the file size of natural, photographic-like true-color images as much as possible without affecting the quality of the image as experienced by the human sensory engine. We perceive small changes in brightness more readily than we do small changes in color. It is this aspect of our perception that JPEG compression exploits in an effort to reduce the file size
JPEG is suitable for grayscale or color images, such as continuous-tone photographs that contain more detail than can be reproduced on-screen or in print. JPEG is lossy, which means that it removes image data and may reduce image quality, but it attempts to reduce file size with the minimum loss of information. Because JPEG eliminates data, it can achieve much smaller file sizes than ZIP compression.
Acrobat provides six JPEG options, ranging from Maximum quality (the least compression and the smallest loss of data) to Minimum quality (the most compression and the greatest loss of data). The loss of detail that results from the Maximum and High quality settings is so slight that most people cannot tell an image has been compressed. At Minimum and Low, however, the image may become blocky and acquire a mosaic look. The Medium quality setting usually strikes the best balance in creating a compact file while still maintaining enough information to produce high-quality images.

GRAPHIC FILE FORMAT



When you Save an image for the first time or Save As, you'll notice that you have a wealth of different graphic file formats to choose from. For Photoshop beginners, all these file formats can be rather daunting. The following is just a brief overview of what some of these file formats are, how they are used, and when to use them. Many of the formats, you'll be pleased to know, you will never, ever, EVER use. 

Photoshop (.psd): This is Photoshop's native file format. If you have created a graphic with a multitude of layers (especially type layers), and you want to save these layers for any changes that you intend to make in the future, then it's generally best to save the graphic in Photoshop format. It used to be that you could only save layered files as .psd but now .tif format saves layers as well.
BMP (.bmp): This is Microsoft's native graphic file format, so obviously, it works well with any Microsoft product.
CompuServe GIF (.gif): GIF format is primarily used for creating Web graphics. It only supports 256 colors (which keeps GIF file sizes down) and is widely supported on all computer platforms. However, when creating GIFs, I find that it is far more preferable to go to the File menu and select Save for Web & Devices because this Save option dialog box gives you far more control over the quality of the .gif created.
Dicom (.dcm): Not widely used. According to Adobe: "The DICOM (Digital Imaging and Communications in Medicine) format is commonly used for the transfer and storage of medical images, such as ultrasounds and scans. DICOM files contain both image data and headers, which store information about the patient and the medical image. You can open, edit, and save DICOM files in Photoshop Extended."
Photoshop EPS (.eps): EPS stands for Encapsulated PostScript format, which is based on the PostScript printing language. Most .eps graphics are created and edited in a draw (vector) application like Illustrator, and when you open an Illustrator vector .eps image in Photoshop, Photoshop will still convert it to pixels. As such, an Illustrator .eps doesn't have the same editable properties as a Photoshop .eps graphic so don't confuse the two. Photoshop .eps format is primarily used for creating images with clipping paths and monotone/duotones. It used to be that an image with a clipping path could only be saved as in .eps format in Photoshop. This is no longer true with later versions of Photoshop where you can save graphics with clipping paths in .tif format as well. When you create a monotone or duotone image in Photoshop, it is still best to save it in this .eps graphic file format, although .psd and .pdf options are also available.
JPEG (.jpg): Along with GIF, JPEG is most commonly used for Web graphics. Unlike the GIF format, which only supports 256 colors, JPEG supports millions and allows for graphic compression. Most people use JPEG for Web graphics that contain a multitude of colors and gradations — like photographic images. It's also a handy file format if you frequently switch from Mac to PC platforms because JPEG graphics can be easily opened in both Macintosh and Windows applications. However, as with GIFs, when creating JPEGs, I find that it is far more preferable to go to the File menu and select Save for Web & Devices because this Save option dialog box gives you far more control over the quality of the .jpg created.
Large Document Format (.psb): Not widely used. According to Adobe, "the Large Document Format (PSB) supports documents up to 300,000 pixels in any dimension."
PCX (.pcx): PC Paintbrush's native graphic file format and widely used on IMB PC-compatible computers.
Photoshop PDF (.pdf): Enables you to save graphics in PDF format so they can be opened in Adobe Acrobat. Very handy.
Photoshop 2.0: Use this format to save files so that they can be opened in Photoshop version 2. I'm not kidding.
Photoshop Raw (.raw): This is not the same as Camera Raw from a digital camera. According to Adobe: "The Photoshop Raw format is a flexible file format for transferring images between applications and computer platforms."
PICT File (.pct): Apple Macintosh's native graphic file format. Not really (and shouldn't be) used anymore. Let PICT die, please.
PICT Resource (.pxr): A graphic file format used to create Macintosh startup screens. It serves no other purpose that I know of.
Pixar (.pxr): Pixar is an animation company (most famous as the creator of Toy Story and Bug's Life). Most of Pixar's animation is done on Pixar work stations with Pixar as the native graphic file format. Basically, it's another graphic file format you probably won't use.
PNG (.png): PNG (Portable Network Graphics) was initially developed as a "patent-free alternative to GIF" for web development but it never took. Many browsers don't support PNG so it's not widely used except perhaps as screenshots and in email.
Portable Bit Map (.pbm): Not widely used. According to Adobe: "The Portable Bit Map (PBM) file format, also known as Portable Bitmap Library and Portable Binary Map, supports monochrome bitmaps (1 bit per pixel). The format can be used for lossless data transfer because many applications support this format. You can even edit or create such files within a simple text editor."
Scitex CT (.sct): Another graphic file format that you will probably never use unless you work with Scitex computer systems, scanners and printing devices.
Targa (.tga): Yet another graphic file format that you will probably never use. For use with TrueVision's Targa and NuVista video.
TIFF (.tif): TIFF is the most widely supported graphic file format in existence. It is the best graphic file format for use in layout applications like InDesign and QuarkXPress. Graphics saved in TIFF format can be easily opened on both Macintosh and PC/Windows platforms. When in doubt, use .tif.
Photoshop DCS 1.0 and 2.0 (.eps): Used to make Desktop Color Separations (DCS). I've never used this file format in Photoshop but have when making an eps of a page (File > Save Page as EPS) in QuarkXPress.

Video File Formats



The following is a brief explanation of the different video file formats found commonly online:
Most videos files have at least two types of file formats. First there is the container, and then the codec which is used inside the container.
The container is what describes the whole structure of the file, and specifies which codec’s are being used. The following is a list of some of the more common types of container formats:

Flash Video Format (.flv)
Because of the cross-platform availability of Flash video players, the Flash video format has become increasingly popular. Flash video is playable within Flash movies files, which are supported by practically every browser on every platform

AVI Format (.avi)
The AVI format, which stands for audio video interleave, was developed by Microsoft.
It stores data that can be encoded in a number of different codec’s and can contain both audio and video data. The AVI format usually uses less compression than some similar formats and is a very popular format amongst internet users.

AVI files most commonly contain M-JPEG, or DivX codec’s, but can also contain almost any format.
The AVI format is supported by almost all computers using Windows, and can be played on various players.
Some of the most common players that support the avi format are:

  • Apple QuickTime Player (windows & Mac)
  • Microsoft Windows Media Player (Windows & Mac)
  • VideoLAN VLC media player (Windows & Mac)
  • Nullsoft Winamp
Quicktime Format (.mov)
The QuickTime format was developed by Apple and is a very common one. It is often used on the internet, and for saving movie and video files.

The format contains one or more tracks storing video, audio, text or effects. . It is compatible with both Mac and Windows platforms, and can be played on an Apple Quicktime player.
MP4 Format (.mp4)
This format is mostly used to store audio and visual streams online, most commonly those defined by MPEG. It Expands MPEG-1 to support video/audio "objects", 3D content, low bit rate encoding and support for Digital Rights Management.

The MPEG-4 video format uses separate compression for audio and video tracks; video is compressed with MPEG-4 video encoding; audio is compressed using AAC compression, the same type of audio compression used in .AAC files.
The mp4 can most commonly be played on the Apple QuickTime Player or other movie players. Devices that play p4 are also known as mp4 players.
Mpg Format (.mpg)
Common video format standardized by the Moving Picture Experts Group (MPEG); typically incorporates MPEG-1 or MPEG-2 audio and video compression; often used for creating downloadable movies. It can be played using Apple QuickTime Player or
Microsoft Windows Media Player.

Windows Media Video Format (.wmv)
WMV format, short for Windows Media Video was developed by Microsoft. It was originally designed for internet streaming applications, and can now cater to more specialized content. Windows Media is a common format on the Internet, but Windows Media movies cannot be played on non-Windows computer without an extra (free) component installed. Some later Windows Media movies cannot play at all on non-Windows computers because no player is available.
Videos stored in the Windows Media format have the extension .wmv.
3GP File Extension (.3gp)
The 3gp format is both an audio and video format that was designed as a multimedia format for transmitting audio and video files between 3G cell phones and the internet. It is most commonly used to capture video from your cell phone and place it online.
This format supports both Mac and windows applications and can be commonly played in the following:

  • Apple QuickTime Player
  • RealNetworks RealPlayer
  • VideoLAN VLC media player
  • MPlayer
  • MIKSOFT Mobile 3GP Converter (Windows)
Advances Streaming Format (.asf)
ASF is a subset of the wmv format and was developed by Microsoft. It is intended for streaming and is used to support playback from digital media and HTTP servers, and to support storage devices such as hard disks. It can be compressed using a variety of video codecs.

The most common files types that are contained within an ASF file are Windows Media Audio, and Windows Media video.

Real Media Format (.rm)
RealMedia is a format which was created my RealNetworks. It contains both audio and video data and typically used for streaming media files over the internet.
Realmedia can play on a wide variety of media players for both Mac and Windows platforms. The realplayer is the most compatible.

Flash Movie Format (.swf )
The Flash movie format was developed my Macromedia.

This format can include text, graphics and animation. In order to play in Web Browsers, they must have the Flash Plug-In Installed. The flash plug in comes preinstalled in the latest version of many popular Web Browsers.
The RealVideo Format
The RealVideo format was developed for the Internet by Real Media. The format is used for streaming of video at low bandwidths. This sometimes causes the quality of the videos to be reduced.

Audio File formats


3gp multimedia container format can contain proprietary formats as AMR,
Aac Advanced audio coding is based on mpeg2 and mpeg4
Aiff  standard audio file format used by apple and window
Gsm designed for telephony used in Europe
M4p  a new version of aac in mp4 with digital light management
Mp3  MPEG Layer III Audio. Is the most common sound file format used today.
Mxp4  a Musinaut proprietary format allowing play of different versions (or skins) of the same song. It allows various interactivity scenarios between the artist and the end user.
Raw  a raw file can contain audio in any format but is usually used with PCM audio data. It is rarely used except for technical tests.
Wav   standard audio file container format used mainly in Windows PCs.
Wma the popular Windows Media Audio format owned by Microsoft.
Mmf  a Samsung audio format that is used in ringtones.