Total Pageviews

Wednesday, December 2, 2026

ENCODER - DECODER MODEL

IMAGE ENCODER AND DECODER MODEL

Image Compression and Reconstruction

Based on Digital Image Processing by Gonzalez and Woods

Image Compression Encoder Decoder Lossless and Lossy

1. Introduction

An Encoder and Decoder Model is an important concept in Digital Image Processing. It is used to reduce the amount of data required to represent an image and reconstruct the image when it is decoded.

A digital image contains a large amount of information. Image compression techniques reduce the data by removing different types of redundancy.

The encoder converts the original image into a compressed representation. The decoder uses the compressed information to reconstruct the image.

Original Image → Encoder → Compressed Data

Compressed Data → Decoder → Reconstructed Image

According to Gonzalez and Woods, a general image compression system consists of three major encoding operations:

  1. Mapper
  2. Quantizer
  3. Symbol Coder

The corresponding decoder contains:

  1. Symbol Decoder
  2. Inverse Mapper
Important: The quantizer is responsible for irreversible information loss in lossy compression. It is omitted in error-free or lossless compression.

2. General Image Compression Model

The general model described by Gonzalez and Woods can be represented as follows.

Encoder Model

Input Image
f(x,y)
→ Mapper → Quantizer → Symbol Coder → Compressed Data

Decoder Model

Compressed Data → Symbol Decoder → Inverse Mapper → Output Image
f̂(x,y)
The encoder removes redundancies and creates a compact representation. The decoder reconstructs the image using the encoded information.

3. Components of an Image Encoder

3.1 Mapper

The mapper converts the original image into a different representation to reduce spatial or interpixel redundancy.

It transforms the image into a format that is more suitable for compression.

Examples:

  • Run-Length Coding (RLC)
  • Differential Pulse Code Modulation (DPCM)
  • Discrete Cosine Transform (DCT)
  • Wavelet Transform
Original Image → Mapper → Transformed Representation
A mapper may be reversible. It can reorganize image data without necessarily reducing the number of bits immediately. For example, a transform can concentrate information into a smaller number of significant coefficients.

3.2 Quantizer

The quantizer reduces the precision of the mapped image values by assigning them to a limited set of representative levels.

It is used to remove psychovisual redundancy by reducing information that is less noticeable to the human visual system.

Example:

Original Value = 127
Quantized Value = 120

The difference between the original and quantized value is the quantization error.

e = Original Value - Quantized Value
e = 127 - 120 = 7
Quantization is generally irreversible. Once information is discarded during quantization, the decoder cannot recover the exact original value.

3.3 Symbol Coder

The symbol coder converts the quantized values into binary codewords for efficient storage or transmission.

It reduces coding redundancy by assigning shorter codewords to frequently occurring symbols.

Examples:

  • Huffman Coding
  • Arithmetic Coding
  • Variable-Length Coding
Quantized Symbols → Binary Codewords
Symbol coding is generally reversible. The original quantized symbols can be recovered from the coded data.

4. Components of an Image Decoder

4.1 Symbol Decoder

The symbol decoder converts the compressed binary codewords back into the corresponding quantized symbols.

It performs the reverse operation of the symbol coder.

Compressed Data → Symbol Decoder → Quantized Symbols

4.2 Inverse Mapper

The inverse mapper converts the decoded representation back into the spatial image domain.

It performs the reverse operation of the mapper. For transform-based compression, it applies the corresponding inverse transform.

Examples:

  • Inverse DCT
  • Inverse Wavelet Transform
  • Inverse Predictive Mapping
  • Reconstruction of image blocks
Decoded Representation → Inverse Mapper → Reconstructed Image
The reconstructed image is represented by f̂(x,y). In lossless compression, it is identical to the original image. In lossy compression, some differences may exist.

5. Channel Encoder and Channel Decoder

In an image transmission system, the compressed data may pass through a communication channel.

To protect the compressed data from transmission errors, additional channel coding can be applied.

Channel Encoder

Adds redundancy to the compressed bitstream to help detect or correct errors during transmission.

Channel

The medium through which the data is transmitted, such as a wireless network, optical fibre or storage link.

Channel Decoder

Uses the added redundancy to detect or correct transmission errors before the image compression decoder processes the compressed data.

Source Encoder → Channel Encoder → Communication Channel → Channel Decoder → Source Decoder
Remember: Source coding performs image compression. Channel coding provides protection against transmission errors. They have different purposes.

6. Lossless and Lossy Compression Models

6.1 Lossless Compression

In lossless compression, the reconstructed image is exactly the same as the original image.

f̂(x,y) = f(x,y)

The quantizer is omitted because no image information should be discarded.

Examples:

  • Huffman Coding
  • Run-Length Coding
  • LZW Coding
Original Image → Reversible Mapper → Symbol Coder → Compressed Data

6.2 Lossy Compression

In lossy compression, some information is discarded during quantization to achieve a higher compression ratio.

f̂(x,y) ≠ f(x,y)

Examples:

  • JPEG compression
  • Transform Coding with Quantization
  • Wavelet-based lossy compression
Original Image → Mapper → Quantizer → Symbol Coder

7. Step-by-Step Numerical Example

Consider a simple grayscale image represented by the following pixel values:

Step 1: Original Image

120125128135
140145150155

Step 2: Mapping Operation

For illustration, consider a simple mapping operation that calculates the difference between consecutive pixel values in a row.

d(i) = f(i) - f(i-1)

For the first row:

120, 125, 128, 135

Mapped Values:
120, 5, 3, 7

For the second row:

140, 145, 150, 155

Mapped Values:
140, 5, 5, 5
120537
140555

The differences are much smaller than many of the original pixel values. This can make subsequent compression more effective.

Step 3: Quantization

Assume a simple quantizer with step size Δ = 4. For this example, quantization is performed using:

q = round(d / 4)

Quantization calculations:

Mapped ValueCalculationQuantized Value
120round(120/4)30
5round(5/4)1
3round(3/4)1
7round(7/4)2
140round(140/4)35
5round(5/4)1
5round(5/4)1
5round(5/4)1

Step 4: Symbol Coding

The quantized symbols can now be represented using binary codewords.

SymbolExample Codeword
10
210
30110
35111

The resulting illustrative compressed bitstream is:

110 | 0 | 0 | 10 | 111 | 0 | 0 | 0
The codewords above are an illustrative prefix code for this small example, not the output of a complete Huffman coding procedure. A real encoder constructs its code according to symbol frequencies.

Step 5: Decoding

The decoder reverses the operations:

  1. Symbol decoder recovers the quantized values.
  2. Inverse quantizer multiplies the values by 4 to obtain reconstructed differences.
  3. Inverse mapper adds the differences cumulatively to reconstruct the pixels.

Step 6: Reconstructed Values

First row:

30 × 4 = 120
1 × 4 = 4
1 × 4 = 4
2 × 4 = 8

Reconstruction:
120, 124, 128, 136

Second row:

35 × 4 = 140
1 × 4 = 4
1 × 4 = 4
1 × 4 = 4

Reconstruction:
140, 144, 148, 152

Original vs Reconstructed Image

Original Reconstructed
120120
125124
128128
135136
140140
145144
150148
155152
The reconstructed image is not exactly equal to the original because quantization has introduced errors. This is an example of lossy image compression.

8. Encoder Algorithm

IMAGE_ENCODER(Original_Image):

1. Read the original image.

2. MAPPED_DATA = MAPPER(Original_Image)

3. QUANTIZED_DATA = QUANTIZER(MAPPED_DATA)

4. COMPRESSED_DATA =
   SYMBOL_ENCODER(QUANTIZED_DATA)

5. Store or transmit COMPRESSED_DATA.

6. END

Decoder Algorithm

IMAGE_DECODER(Compressed_Data):

1. Read compressed data.

2. DECODED_SYMBOLS =
   SYMBOL_DECODER(Compressed_Data)

3. RECONSTRUCTED_IMAGE =
   INVERSE_MAPPER(DECODED_SYMBOLS)

4. Display reconstructed image.

5. END
For lossy compression, the quantization levels must be taken into account during reconstruction. The decoder uses the representative values associated with those quantization levels.

9. Types of Redundancy Removed by Encoder

1. Coding Redundancy

Occurs when more bits are used than necessary to represent the information. Symbol coding reduces this redundancy.

2. Interpixel Redundancy

Neighbouring pixels often have similar intensity values. Mapping operations such as predictive coding help reduce this redundancy.

3. Psychovisual Redundancy

Some image information is less noticeable to human vision. Quantization can remove or reduce this information.

RedundancyOperation
Coding RedundancySymbol Coder
Interpixel RedundancyMapper
Psychovisual RedundancyQuantizer

10. Performance Measurement of Image Compression

Compression Ratio

CR = Original Data Size / Compressed Data Size

For example, if an image requires 800 KB and the compressed image requires 200 KB:

CR = 800 / 200 = 4 : 1

Mean Squared Error (MSE)

MSE = (1/MN) Σ Σ [f(x,y) - f̂(x,y)]²

MSE measures the average squared difference between the original and reconstructed image.

Peak Signal-to-Noise Ratio (PSNR)

PSNR = 10 log10 (MAX² / MSE)

For an 8-bit grayscale image, MAX = 255. A higher PSNR generally indicates lower reconstruction error.

For a perfectly reconstructed image, MSE = 0 and PSNR is theoretically infinite.

11. Advantages of Encoder and Decoder Model

  • Reduced Storage: Compressed images require less storage space.
  • Faster Transmission: Smaller data can be transmitted more efficiently.
  • Flexible Design: Different mapping and coding methods can be combined.
  • Lossless Support: The model can preserve the exact original image.
  • Lossy Support: It can achieve higher compression by controlling image quality.
  • Efficient Processing: Each stage performs a specific operation.
  • Wide Applications: Used in image storage, communication and multimedia systems.

12. Disadvantages of Encoder and Decoder Model

  • Computational Cost: Some transformations and coding operations require significant processing.
  • Quality Loss: Lossy quantization can introduce image distortion.
  • Complexity: Advanced compression methods require more complicated encoding and decoding.
  • Memory Requirements: Intermediate image representations may require additional memory.
  • Encoding Time: Complex coding methods may increase processing time.
  • Compatibility: Encoder and decoder must follow compatible compression formats and parameters.

13. Applications

  • JPEG image compression.
  • Digital photography and image storage.
  • Medical image archiving and transmission.
  • Satellite and remote sensing image transmission.
  • Web image optimization.
  • Video compression systems.
  • Digital multimedia communication.
  • Image databases and cloud storage.

14. Interactive Encoder and Decoder Demonstration

Enter grayscale pixel values and observe the operations of the encoder and decoder. This demonstration uses predictive mapping, scalar quantization and a simple illustrative symbol representation.

Step 1: Input Image Pixel Values

Enter eight grayscale values separated by commas.

Step 2: Select Compression Type

Step 3: Quantization Step Size

The results will appear here after running the model.

15. Conclusion

The Encoder and Decoder Model is the foundation of image compression in Digital Image Processing.

The encoder uses a mapper, quantizer and symbol coder to reduce the amount of data required to represent an image. The decoder uses symbol decoding and inverse mapping to reconstruct the image.

In lossless compression, the reconstructed image is identical to the original. In lossy compression, quantization reduces the data size at the expense of some image quality.

Understanding this model helps students understand JPEG, predictive coding, transform coding and other image compression techniques.

16. References and Study Materials

Primary Textbook:

Rafael C. Gonzalez and Richard E. Woods, Digital Image Processing, 3rd Edition, Prentice Hall, Chapter 8 – Image Compression.

📘 Reference 1: Gonzalez and Woods – Digital Image Processing, 3rd Edition 📗 Reference 2: Chapter 8 – General Image Compression Model 📙 Reference 3: Image Compression – Encoder and Decoder Block Diagram

No comments:

Post a Comment