Other Free Encyclopedias » Online Encyclopedia » Encyclopedia - Featured Articles » Contributed Topics from F-J

Image Data Representations - Binary (1-bit) images, Gray-level (8-bit) images

format file color compression

Oge Marques
Department of Computer Science & Engineering
Florida Atlantic University, Boca Raton, FL, USA

Definition: At the most basic level, there are two different ways of encoding the contents of a 2-D image in digital format: raster (also known as bitmap) and vector.

Images are represented in digital format in a wide variety of ways. At the most basic level, there are two different ways of encoding the contents of a 2-D image in digital format: raster (also known as bitmap) and vector. Bitmap representations use one or more two-dimensional arrays of pixels (picture elements), whereas vector representations use a series of drawing commands to represent an image. Each encoding method has its pros and cons: the greatest advantages of bitmap graphics are their quality and display speed; its main disadvantages include larger memory storage requirements and size dependence (e.g., enlarging a bitmap image may lead to noticeable artifacts). In either case, there is no such a thing as a perfect digital representation of an image. Artifacts due to finite resolution, color mapping, and many others will always be present. The key in selecting an adequate representation is to find a suitable compromise between size (in Bytes), subjective quality, and universality / interoperability of the adopted format or standard. We will review several different image representations used by some of the most common file formats currently available.

Binary (1-bit) images

Binary images are encoded as a 2-D array, using one bit per pixel, where a 0 usually means ‘black’ and a 1 means ‘white’ (even though there is no universal agreement on that). The main advantage of this representation (Figure l(b)) – usually suitable for images containing simple graphics, text or line art – is its small size.

Gray-level (8-bit) images

Gray-level (also referred to as monochrome ) images are also encoded as a 2-D array of pixels, using eight bits per pixel, where a pixel value of 0 usually means ‘black’ and a pixel value of 255 means ‘white’, with intermediate values corresponding to varying shades of gray. The total number of gray-levels is larger than the human visual system requirements, making this format a good compromise between subjective visual quality and relatively compact representation and storage. An 8-bit monochrome image (Figure 1(a)) can also be thought of as a collection of bit-planes, where each plane contains a 1-bit representation of the image at different levels of detail.

Color images

Representation of color images is significantly more complex and varied. The two most common ways of storing color image contents are: RGB representation – in which each pixel is usually represented by a 24-bit number containing the amount of its Red®, Green (G), and Blue (B) components – and indexed representation – where a 2-D array contains indices to a color palette (or look-up table – LUT).

24-bit (RGB) color images

Color images can be represented using three 2-D arrays of same size, one for each color channel: Red®, Green (G), and Blue (B) (Figure 2). Each array element contains an 8-bit value indicating the amount of red, green, or blue at that point, in a 0 to 255 scale. The combination of the three 8-bit values into a 24-bit number allows for 2 24 (16,777,216, usually referred to as 16 million or 16 M) color combinations. An alternative representation uses 32 bits and includes a fourth channel, called the alpha channel, which provides a measure of transparency for each pixel and is widely used in image editing effects.

Indexed color images

A problem with 24-bit color representations is backward compatibility with older hardware which may not be able to display the 16 million colors simultaneously. A solution devised before 24-bit color displays and video cards were widely accessible was to adopt an indexed representation, in which a 2-D array of the same size as the image contains indices (pointers) to a color palette (or look-up table – LUT) of fixed maximum size (usually 256 colors) (see Figure 3).

Other color models

The RGB color model is one of the most popular and straightforward methods for representing the contents of a digital color image, but there are several alternative models, such as: YCbCr – adopted in the JPEG standard – and the CMYK – used to encode color information for printing purposes –, among many others.


Since raw image representations usually require a large amount of storage space (and proportionally long transmission times in the case of file uploads/downloads), most image file formats employ some type of compression. Compression methods can be lossy – when a tolerable degree of deterioration in the visual quality of the resulting image is acceptable – or lossless – when the image is encoded in its full quality. The overall results of the compression process, both in terms of storage savings – usually expressed as compression ratio – as well as resulting quality loss (for the case of lossy techniques) may vary depending on the technique, format, options (such as the quality setting for JPEG), and the image contents. As a general guideline, lossy compression should be used for general purpose photographic images, whereas lossless compression should be preferred when dealing with line art, drawings, facsimiles, or images in which no loss of detail may be tolerable (most notably, space images and medical images).

Popular file formats

The selected file formats described below represent some of the most widely used formats at the present time. Research in the field of image compression and encoding remains active and it is possible that other formats may appear and become popular in the future.

Windows BMP

Windows BMP is the native image format in the Windows platform. It is one of the simplest image formats and supports images with 1, 4, 8, 16, 24, and 32 bits per pixel. BMP files are usually uncompressed. Multi-byte integers are stored with the least significant bytes first. The BMP file structure (Figure 4) contains:

• A file header, implemented as a BITMAPFILEHEADER structure, serves as the signature that identifies the file format (the first two bytes must contain the ASCII characters ‘B’ followed by ‘M’).

• An image header, which may come in two different formats: BITMAPCOREHEADER (for the old OS/2 BMP format) and BITMAPINFOHEADER (for the much more popular Windows format). This header stores the images width, height, compression method, and number of bits per pixel, among other things.

• A color palette, which contains values for R, G, B, and an additional (‘reserved’) channel for each pixel.

• The actual pixel data, ordered in rows, from bottom to top. The exact format of the pixel data depends on the number of bits per pixel.

The main advantages of the BMP format are its simplicity, widespread distribution (with Windows) and popularity. Moreover, it is a well-documented patent-free format. Because it is usually uncompressed, its main disadvantage is the resulting file size (in Bytes).


Graphic Interchange Format (GIF) was originally devised by CompuServe in 1987. It soon became the most widely used format for image storage. The GIF format became popular because it used LZW (Lempel-Ziv-Welch) data compression, a lossless compression algorithm which was more efficient than the run-length encoding (RLE) compression used by (at that time) competing formats such as PCX and MacPaint. Thanks to its improved compression scheme, reasonably large images could be downloaded in a reasonable amount of time, even with very slow modems. GIF’s optional interlacing feature, which allows storing image scan lines out of order in such a fashion that even a partially downloaded image is somewhat recognizable, also helped GIF’s popularity, allowing a user to stop the download if it was not what was expected.

The first GIF specification was called GIF87a. In 1989, CompuServe released an enhanced version, called GIF89a, which added support for multiple images in a stream and storage of application-specific metadata. The two versions can be distinguished by looking at the first six bytes of the file, whose ASCII characters are ‘GIF87a’ and ‘GIF89a’, respectively.

The LZW compression algorithm on which GIF is based, was covered by U.S. Patent 4,558,302, owned by Unisys, which has led to a legal battle that started when Unisys discovered that GIF used the LZW and announced that they would be seeking royalties on that patent. This led to the development of a patent-free alternative format (PNG, described in a short article) with similar technical characteristics. That patent expired on June 20, 2003, which means that Unisys and CompuServe can no longer collect royalties for use of the GIF format in the United States.

The GIF file structure in Figure 5 contains:

  • A GIF header , required, always present at the beginning of the file. It contains a 6-byte signature, either ‘GIF87a’ or ‘GIF89a’.
  • A 7-byte global screen descriptor , which specifies the dimensions and background color of the logical screen area in which the individual images in the GIF file are displayed.
  • A global color table , an array of structures containing values for R, G, and B for each pixel.
  • One or more images , each of which may contain:

    An image header

    An optional local color table

    A collection of data blocks

    A terminator block

  • A trailer .

The GIF89a feature of storing multiple images in one file, accompanied by control data, is used extensively on the Web to produce simple animations and short, low-resolution films, the so-called animated GIF . GIF is palette-based, which limits the maximum number of colors to 256. This limitation is usually not an issue for web page logos and design elements such as buttons or banners. For digital photographs, the JPEG format (described in a short article) is preferred.


The PNG (Portable Network Graphics) format was originally designed to replace the GIF format. It is described in more detail in a separate short article.


The JPEG format was originally published as a standard (ISO IS 10918-1) by The Joint Photographic Experts Group in 1994. It has become the most widely used format for storing digital photographs ever since. The JPEG specification defines how an image is transformed into a stream of bytes, but not how those bytes are encapsulated in any particular storage medium. Another standard, created by the Independent JPEG Group, called JFIF (JPEG File Interchange Format) specifies how to produce a file suitable for computer storage and transmission from a JPEG stream. JFIF is described in a separate short article.

Even though the original JPEG specification defined four compression modes (sequential, hierarchical, progressive, and lossless), most JPEG files used today employ the sequential mode. The JPEG encoder (Figure 6) consists of the following main stages:

  1. The original RGB color image is converted to an alternative color model (YCbCr) and the color information is subsampled.
  2. The image is divided into 8 × 8 blocks.
  3. The 2-D Discrete Cosine Transform (DCT) is applied to each block image; the resulting 64 values are referred to as DCT coefficients .
  4. DCT coefficients are quantized according to a quantization table; this is the step where acceptable loss is introduced.
  5. Quantized DCT coefficients are scanned in a zigzag fashion (from top-left to bottom-right). The resulting sequence is run-length encoded, in preparation for the entropy encoding step.
  6. The run-length encoded sequences are converted to variable-length binary codewords using Huffman encoding.

At the decoder side, the process is reversed; it should be noted that the loss introduced at the quantizer stage in the encoder cannot be canceled at the ‘dequantizer’ stage in the decoder.

JPEG 2000

The JPEG 2000 format is a wavelet-based image compression standard (ISO/IEC 15444-1:2000), created by the Joint Photographic Experts Group committee with the intention of superseding their original DCT-based JPEG standard. The usual file extension is .jp2. It addresses several well-known limitations of the original JPEG algorithm and prepares the way for next-generation imagery applications. Some of its advertised advantages are:

  1. Low bitrate compression
  2. Superior lossless and lossy compression in a single bitstream
  3. Ability to handle very large images without need for tiling
  4. Single decompression architecture
  5. Error resilience for transmission in noisy environments, such as wireless and the Internet
  6. Region of Interest (ROI) coding
  7. Metadata mechanisms for incorporating additional non-image data as part of the file

JPEG 2000 is not yet widely supported in web browsers, and hence is not generally used on the World Wide Web.


TIFF (Tagged Image File Format) is another popular image file format, developed in the 1980s by Aldus Corp. The TIFF format includes a number of options that can be used to attach additional information (such as images encoded in another file format); these options can be exercised by including specific “tags” in the header. Many of these tags convey basic image information, such as its size, but others define how the data is arranged and various image compression options. As a result, TIFF can be used as a container for JPEG compressed images, and in this respect is completely universal. However, because of the complexity involved in supporting all of its options, a lowest common denominator variant became “the” TIFF, and even today the vast majority of TIFF files, and the programs that read them, are based on a simple 32-bit uncompressed image.


Digital Negative Specification (DNG) is a recently announced royalty-free raw image file format introduced by Adobe Systems as a response to demand for a unifying digital camera raw file format.

Other formats

It is virtually impossible to cover all image file formats. Other image formats not described here include: ANIM, ART, CGM, CIN, DjVu, DPX, EPS, EXIF, GDF, ILBM, MNG, PCX, PICT, PSD, PSP, XBM, and XPM, among many others. Please refer to for an updated list and useful links.

Image Formation - Introduction, Illuminants and light, Radiometry, Photometry, Illuminants, Reflectance, Sensors, Sensors of the Human Visual System [next] [back] Image Compression and Coding - Fundamentals of visual data compression, Redundancy, models, Error-free compression, Variable Length Coding (VLC)

User Comments

Your email address will be altered so spam harvesting bots can't read it easily.
Hide my email completely instead?

Cancel or

Vote down Vote up

over 4 years ago

tell more about these book

Vote down Vote up

over 6 years ago

Excellent site. And vary helpful data. Thank you dude. I will attach the links on my site. Would you please send the linking script for different new tech. I will link it on my side. Thanks dude.