---
title: "JPEG compression process steps"
subject: "Multimedia System"
chapter: 5
key: "semester_8/multimedia_system:jpeg-compression-steps"
source: https://www.bctengineer.com/q/semester_8/multimedia_system/jpeg-compression-steps
site: BCT Engineering
---

# JPEG compression process steps

Multimedia System · Chapter 5: Data Compression

- Asked in: 2076 Bhadra, 9 marks; 2074 Bhadra, 9 marks; 2074 Magh, 9 marks (asked 3 times)
- Video: [JPEG Compression | CG | Computer Graphics | Lec-71 | Bhanu Priya](https://www.youtube.com/watch?v=p_YYAb0Fkuw) — Education 4u
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_8/multimedia_system/jpeg-compression-steps
- Whole chapter: https://www.bctengineer.com/md/semester_8/multimedia_system/chapter-5

## Question

Explain the steps of the JPEG compression process in detail (with example).

## Short answer

JPEG compresses by preparing the image (YCbCr conversion, chroma subsampling, 8x8 blocks, level shift), applying DCT, quantizing coefficients (the lossy step), then zig-zag scanning with DPCM, RLE, and Huffman coding. Decoding reverses these steps; typical compression is 10:1 to 20:1.

## Answer

JPEG (Joint Photographic Experts Group) is a standard for compressing continuous-tone still images. The baseline (lossy, DCT-based) method has four main stages: preparation, DCT, quantization and entropy coding.

```text
Image -> Preparation -> DCT -> Quantization
      -> Zig-zag + DPCM/RLE -> Huffman -> JPEG file
```

#### 1. Image preparation
- The image is split into components. An RGB image is usually converted to YCbCr (luminance Y and chrominance Cb, Cr).
- **Chroma subsampling:** the eye is less sensitive to colour than brightness, so Cb and Cr are reduced, for example 4:2:0 (one chroma sample per 2x2 block of pixels). This alone halves the data.
- Each component is divided into **8 x 8 blocks** of pixels, and 128 is subtracted from each value (level shift) so values range from -128 to 127.

#### 2. Discrete Cosine Transform (DCT)
- A 2-D DCT is applied to each 8 x 8 block. It converts spatial pixel values into 64 frequency coefficients.
- The top-left coefficient is the **DC coefficient** (average of the block); the other 63 are **AC coefficients**, growing in frequency toward the bottom-right.
- DCT itself is nearly lossless; it only makes the data easier to compress, since most energy gathers in few low-frequency coefficients.

#### 3. Quantization (the lossy step)
- Each coefficient is divided by the matching entry of a quantization table and rounded to the nearest integer.
- High-frequency entries have large divisors, so they become zero. Example: a coefficient 52 divided by 16 gives 3.25, rounded to 3; a high-frequency coefficient 7 divided by 99 rounds to 0.
- A larger divisor means more compression and lower quality. This is the "quality" setting.

#### 4. Entropy coding
- **Zig-zag scan:** the 8 x 8 matrix is read in zig-zag order, giving a 1-D list with non-zero values first and a long tail of zeros.
- **DC coefficients** are coded by DPCM: only the difference from the previous block's DC value is stored.
- **AC coefficients** are coded by run-length encoding as (zeros-run, value) pairs, ending with an end-of-block (EOB) code.
- The result is compressed with **Huffman coding** (or arithmetic coding), and written with headers to the JPEG file.

**Mini example:** after quantization a block's zig-zag list is 15, -2, 3, 0, 0, 1, 0, ... 0. It is stored as DC = 15 (as a difference), then (0,-2), (0,3), (2,1), EOB. Sixty-four values reduce to a few symbols.

**Decoding** reverses the steps: Huffman decode, de-quantize (multiply), inverse DCT, add 128, upsample chroma, convert to RGB. The quantization loss cannot be recovered. Typical compression is 10:1 to 20:1 with good quality.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What are the main stages of baseline JPEG?
   A. Preparation, DCT, quantization, entropy coding
   B. Quantization, preparation, motion compensation, DCT
   C. DCT, motion estimation, B-frames, Huffman
   D. Zig-zag, scanning, DCT, preparation
   Answer: A. Baseline JPEG is image preparation, DCT, quantization and entropy coding. (Key point: Stages of JPEG)

2. Which step is the lossy step in JPEG?
   A. Huffman coding
   B. Zig-zag scan
   C. DCT
   D. Quantization
   Answer: D. Coefficients are divided by quantization-table entries and rounded; this loss cannot be recovered. DCT itself is nearly lossless. (Key point: Lossy step)

3. Why do high-frequency coefficients mostly become zero?
   A. They have large divisors in the quantization table, so they round to zero
   B. They are removed by zig-zag scanning
   C. The DC coefficient replaces them
   D. Chroma subsampling deletes them
   Answer: A. e.g. 7 divided by 99 rounds to 0. A larger divisor means more compression and lower quality. (Key point: Quantization effect)

4. How are DC and AC coefficients coded?
   A. DC by run-length, AC by DPCM
   B. Both by DPCM only
   C. Both are stored as raw values
   D. DC by DPCM (difference from previous block), AC by run-length (zeros-run, value) pairs ending with EOB
   Answer: D. DC is the block average, coded as a difference from the previous block; AC coefficients are run-length coded then Huffman coded. (Key point: DC and AC coding)

## Related in Multimedia System

- [Image recognition steps](https://www.bctengineer.com/question.md?key=semester_8%2Fmultimedia_system%3Aimage-recognition-steps) — Multimedia System, chapter 3, asked 2×
- [Multimedia user interface design process](https://www.bctengineer.com/question.md?key=semester_8%2Fmultimedia_system%3Aui-design-process) — Multimedia System, chapter 6, asked 2×

## Related in other subjects

- [Capital budgeting needs, steps, process](https://www.bctengineer.com/question.md?key=semester_7%2Fproject_engineering%3Acapital-budgeting-needs-steps-process) — Project Engineering, chapter 6
- [Steps in the design and synthesis process](https://www.bctengineer.com/question.md?key=semester_6%2Fmachine_design_i%3Adesign-process-steps) — Machine Design I, chapter 1
- [Steps of photolithography process](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3Aphotolithography-steps) — Embedded System, chapter 8, asked 4×
- [Steps in the entrepreneurial process](https://www.bctengineer.com/question.md?key=semester_7%2Fentrepreneurship_development%3Aentrepreneurial-process-steps) — Entrepreneurship Development, chapter 1
