optional · CSS study notes
Image Sampling and Quantization
CSS Optional — Paper-II, Section-B · P-II.V.III · Asked directly in CSS 2018 (differentiate sampling vs quantization and relate them to spatial and intensity resolution). Also the base formula for every storage/size numerical.
1. Why Digitize at All?
A sensor produces a continuous signal — continuous in space (x, y) and continuous in amplitude (brightness). A computer can only store a finite grid of finite numbers, so two independent discretizations are needed:
| Aspect | Sampling | Quantization |
|---|---|---|
| What is digitized | Spatial coordinates (x, y) | Amplitude / intensity value f(x, y) |
| Result | An M × N grid of pixels | Each pixel restricted to L = 2^k gray levels |
| Controls | Spatial resolution (detail per unit distance) | Intensity (gray-level) resolution |
| Too little causes | Pixelation / checkerboard effect; aliasing (jaggies, moiré) | False contouring (visible bands in smooth areas) |
| On a 1-D scan-line plot | Horizontal axis chopped into intervals | Vertical axis chopped into levels |
| Hardware analogy | Number / density of sensor elements | Bit depth of the analog-to-digital converter |
| Reversible? | Yes, if Nyquist is satisfied | No — rounding error is permanently lost |
One-line answer: sampling decides where we measure; quantization decides how precisely we record each measurement.
2. The Digitization Pipeline
graph LR
A["Continuous scene"] --> B["Optics / lens"]
B --> C["Sensor array"]
C --> D["Sampling: x,y grid"]
D --> E["Quantization: ADC, k bits"]
E --> F["Digital image M x N x k"]
3. Spatial Resolution
- The smallest discernible detail, stated as pixels per unit distance (dpi / ppi). A pixel count alone ("1024 × 1024") is meaningful only relative to the physical size it covers.
- Example: a 4 × 6 inch photo scanned at 300 dpi → (4 × 300) × (6 × 300) = 1200 × 1800 pixels.
- Reducing spatial resolution at the same display size → blocky checkerboard look; thin lines and text break up.
4. Intensity Resolution
- The smallest discernible change in intensity; set by bits per pixel k → L = 2^k levels, range 0 … L − 1.
- Reducing k in smooth regions → false contouring: ridge-like bands appear, usually visible at 16 levels (k = 4) or fewer in an ordinary photo.
| k (bits) | L (levels) | Typical use |
|---|---|---|
| 1 | 2 | Binary images, scanned documents, fax |
| 4 | 16 | False contouring clearly visible |
| 8 | 256 | Standard grayscale; each channel of 24-bit colour |
| 12–16 | 4,096–65,536 | Medical (CT/X-ray DICOM), astronomy, camera RAW |
5. Nyquist Sampling Theorem and Aliasing
- A band-limited signal can be perfectly reconstructed if sampled at at least twice its highest frequency (the Nyquist rate).
- Undersampling makes high-frequency content masquerade as lower frequencies — aliasing. In images: jagged edges ("jaggies") and moiré patterns (e.g. photographing a striped shirt or a screen).
- Anti-aliasing: blur (low-pass filter) the image before sampling. Aliasing cannot be removed after sampling — this is the key exam point.
6. Isopreference Curves (Huang, 1965)
Experiments varying N (spatial) and k (intensity) together showed:
- Images with a lot of detail (e.g. a crowd) tolerate fewer gray levels — their curves become nearly vertical.
- Images with little detail (e.g. a face) are more sensitive to gray-level reduction, because false contouring shows up on smooth skin.
- Takeaway: spatial and intensity resolution trade off, and the right k depends on image content.
7. Uniform vs Non-Uniform
- Uniform: equal spacing in space and in levels — simple and standard.
- Non-uniform sampling: denser samples where detail is high (edges), coarser in flat regions.
- Non-uniform quantization: finer levels where most pixel values lie or where the eye is most sensitive (e.g. logarithmic companding, Lloyd-Max quantizer).
8. Zooming, Shrinking and Interpolation
Resizing is resampling, so values at non-grid positions must be interpolated:
| Method | Neighbours used | Quality / speed |
|---|---|---|
| Nearest neighbour | 1 | Fastest; blocky, jagged edges |
| Bilinear | 4 (2 × 2) | Smoother; slight blur |
| Bicubic | 16 (4 × 4) | Sharpest; standard in photo editors and printers; slowest |
Bilinear formula (a, b = fractional offsets in x and y): f(x,y) = (1−a)(1−b)·f00 + a(1−b)·f10 + (1−a)b·f01 + ab·f11
📐 Worked Numericals
N1 — Storage (the core formula): bits b = M × N × k. For 1024 × 1024, 8-bit: b = 1024 × 1024 × 8 = 8,388,608 bits = 1,048,576 bytes = 1 MB.
N2 — Gray levels: a 6-bit image has L = 2^6 = 64 levels, range 0 to 63.
N3 — Transmission time: the same 1 MB image over a 1 Mbps link (10^6 bits/s): 8,388,608 ÷ 10^6 ≈ 8.39 s. Over a 56 kbps modem where each byte is framed by 1 start + 1 stop bit (10 bits per byte): 1,048,576 × 10 = 10,485,760 bits ÷ 56,000 ≈ 187.2 s ≈ 3.1 min.
N4 — Video storage: 1920 × 1080, 24-bit colour, 30 fps, 1 minute.
- Bits per frame = 1920 × 1080 × 24 = 49,766,400 bits = 6,220,800 bytes (≈ 5.93 MB).
- Per second = 6,220,800 × 30 = 186,624,000 bytes ≈ 186.6 MB/s (≈ 1.49 Gbps).
- Per minute = 186,624,000 × 60 ≈ 11.2 GB uncompressed — which is why video compression is unavoidable.
N5 — Nyquist: the finest stripe pattern on a document repeats 2 times per mm (2 cycles/mm). Required sampling rate ≥ 2 × 2 = 4 samples/mm → pixel pitch ≤ 0.25 mm (≈ 100 dpi).
N6 — Bilinear interpolation: f(0,0)=10, f(1,0)=20, f(0,1)=30, f(1,1)=40. Find f(0.25, 0.5).
- Along x at y = 0: 10 + 0.25 × (20 − 10) = 12.5
- Along x at y = 1: 30 + 0.25 × (40 − 30) = 32.5
- Along y between them: 12.5 + 0.5 × (32.5 − 12.5) = 22.5
🎯 CSS Exam Angle
Answer template for the 2018-type question: define both → difference table → sketch one scan line showing the x-axis sampled and the y-axis quantized → link sampling ↔ spatial resolution and quantization ↔ intensity resolution → effect of reducing each (checkerboard vs false contouring) → close with Nyquist/aliasing. The labelled scan-line sketch is quick and earns easy marks.
📌 Past CSS Paper Frequency
| Year | Question |
|---|---|
| 2018 | Differentiate image sampling and quantization; relate them to spatial and intensity resolution |
| 2017 | Storage in bytes of a 256 × 200 RGB image at 24-bit depth (uses b = M × N × k) |
⚠️ MCQ Traps
- Sampling ↔ spatial resolution; quantization ↔ intensity resolution — don't swap them.
- L = 2^k levels, but the maximum value is 2^k − 1 (8-bit max = 255, not 256).
- False contouring is a quantization artefact; aliasing / moiré is a sampling artefact.
- The anti-aliasing filter goes before sampling, never after.
- Quantization is the irreversible step — the same idea reappears as the lossy step in compression.
- More pixels ≠ more detail unless the physical size is fixed — resolution is per unit distance.
✅ Self-Check (with Answers)
Q1. Differentiate sampling and quantization in one line each.
Ans: Sampling digitizes the spatial coordinates (where we measure) and fixes spatial resolution; quantization digitizes the intensity values (how precisely we record) and fixes intensity resolution.
Q2. What is false contouring and how is it avoided?
Ans: Ridge-like bands in smooth regions caused by too few gray levels (typically ≤ 16, k ≤ 4). Avoid it by using more bits per pixel (e.g. 8) or by dithering/adding slight noise before quantizing.
Q3. State the Nyquist theorem and what happens if it is violated.
Ans: A band-limited signal must be sampled at least twice its highest frequency to be reconstructed. Violation causes aliasing — jagged edges and moiré patterns. Aliasing must be prevented by low-pass filtering before sampling; it cannot be removed afterwards.
Q4. How many bits are needed to store a 256 × 256 image with 16 gray levels?
Ans: 16 levels → k = 4. b = 256 × 256 × 4 = 262,144 bits = 32,768 bytes = 32 KB.
Q5. What do isopreference curves show?
Ans: For equal perceived quality, images with lots of detail need fewer gray levels, while low-detail images (e.g. faces) need more — spatial and intensity resolution trade off depending on image content.
Q6. Rank nearest-neighbour, bilinear and bicubic interpolation by quality and speed.
Ans: Quality: bicubic (16 neighbours) > bilinear (4) > nearest (1). Speed: exactly the reverse. Nearest gives blocky results; bilinear slight blur; bicubic the sharpest.
📜 Past-Paper Questions & MCQs (CSS 2016–2026)
2018 · Paper-II · Q6(A) · 8 marks
Q. Differentiate between image sampling and quantisation. Discuss how these concepts relate to spatial and intensity resolution.
Ans.
| Basis | Sampling | Quantisation |
|---|---|---|
| What is digitised | The coordinates (x, y) | The amplitude (intensity) values |
| Result | A grid of M × N pixels | L discrete grey levels (L = 2ᵏ) |
| Controls | Spatial resolution (how much detail in space) | Intensity resolution (how many shades) |
| Too little | Pixelation, checkerboard effect, lost small detail | False contouring (visible bands) |
| Memory | Bits = M × N × k, so both raise the storage needed |
- Relation: spatial resolution is set by the sampling density (pixels per inch). Intensity resolution is set by the number of bits per pixel (8 bits give 256 levels). Better quality needs more of both, at the cost of more storage.