optional · CSS study notes
DIP — Solved Numericals & Formula Sheet
CSS Optional — Paper-II, Section-B · P-II.V (numericals) · Every DIP numerical CSS has set (2017, 2018), fully worked, plus a one-page formula sheet and a practice set. Topic pages carry more examples; this page is for last-week revision.
🧾 Formula Sheet
| Topic | Formula |
|---|---|
| Gray levels | L = 2^k; range 0 … L−1 |
| Storage | b = M × N × k bits (× 3 channels for RGB) |
| Image formation | f(x,y) = i(x,y) · r(x,y); 0 < r < 1 |
| Distances p(x,y), q(s,t) | De = √((x−s)² + (y−t)²); D4 = |
| Negative | s = L − 1 − r |
| Log / power-law | s = c·log(1 + r); s = c·r^γ (γ < 1 brightens, γ > 1 darkens) |
| Contrast stretching | s = (r − rmin) × (L − 1) / (rmax − rmin) |
| Histogram equalization | s_k = (L − 1) × Σ(j=0..k) n_j / MN, then round |
| Rotation (CCW by θ) | x' = x cosθ − y sinθ; y' = x sinθ + y cosθ |
| Shear (x) | x' = x + shx·y; y' = y |
| Gradient | M = √(gx² + gy²) ≈ |
| Laplacian sharpening | g = f − ∇²f (centre coefficient negative) |
| Unsharp / high-boost | g = f + k(f − f_blur); k = 1 unsharp, k > 1 high-boost |
| RGB ↔ CMY | C = 1 − R, M = 1 − G, Y = 1 − B (normalized) |
| CMY → CMYK | K = min(C,M,Y); C' = (C−K)/(1−K), etc. |
| RGB → HSI | I = (R+G+B)/3; S = 1 − 3·min/(R+G+B); H = θ if B ≤ G else 360° − θ |
| Luminance | Y = 0.299R + 0.587G + 0.114B |
| Degradation model | g = h ⋆ f + η; G = H·F + N |
| Uniform noise | mean (a+b)/2; variance (b−a)²/12 |
| Compression ratio / redundancy | C = b / b'; R = 1 − 1/C |
| Entropy | H = −Σ p_k log₂ p_k bits/symbol |
| Average code length | L_avg = Σ l_k · p_k |
| PSNR | 10 log₁₀(255² / MSE) dB |
| Morphology | Opening = (A ⊖ B) ⊕ B; Closing = (A ⊕ B) ⊖ B; Boundary = A − (A ⊖ B) |
| Hough line | ρ = x cosθ + y sinθ |
📝 Past-Paper Numericals — Fully Solved
CSS 2017 — Storage of a 256 × 200 RGB image, 24-bit
- Pixels = 256 × 200 = 51,200
- 24 bits = 3 bytes per pixel
- Storage = 51,200 × 3 = 153,600 bytes = 150 KB
CSS 2018 — Histogram equalization of an 8-bit image
The paper's Figure 2 isn't reproduced online, so here is the method on the standard textbook data (a 64 × 64, 3-bit image, L = 8, MN = 4096). The steps are identical for any figure.
| r_k | n_k | p = n_k / 4096 | Cumulative p | s = 7 × cumulative | Rounded s |
|---|---|---|---|---|---|
| 0 | 790 | 0.19 | 0.19 | 1.33 | 1 |
| 1 | 1023 | 0.25 | 0.44 | 3.08 | 3 |
| 2 | 850 | 0.21 | 0.65 | 4.55 | 5 |
| 3 | 656 | 0.16 | 0.81 | 5.67 | 6 |
| 4 | 329 | 0.08 | 0.89 | 6.23 | 6 |
| 5 | 245 | 0.06 | 0.95 | 6.65 | 7 |
| 6 | 122 | 0.03 | 0.98 | 6.86 | 7 |
| 7 | 81 | 0.02 | 1.00 | 7.00 | 7 |
New histogram: s=1: 790 · s=3: 1023 · s=5: 850 · s=6: 656 + 329 = 985 · s=7: 245 + 122 + 81 = 448 (total 4096 ✓). The output spreads over a wider range → higher contrast. It is not perfectly flat, because discrete levels can only merge, never split — state this in your answer.
CSS 2018 — Sobel at the centre of 5 5 5 / 5 50 5 / 5 5 5
- gx = (5 + 10 + 5) − (5 + 10 + 5) = 0; gy = 0 → M = 0
- Reason: Sobel ignores the centre pixel, so an isolated bright point produces no gradient. The Laplacian point mask gives R = 8 × 50 − 40 = 360 → point detected.
CSS 2018 — Morphology with zero padding
The paper's Figure 1 isn't reproduced online; method shown on this 5 × 5 image X (rows top to bottom):
0 0 0 0 0 / 0 1 1 0 0 / 0 1 1 1 0 / 0 0 1 0 0 / 0 0 0 0 0
(i) Dilation by [1 1 1] (horizontal, origin at centre) — output is 1 if any of left/self/right is 1:
0 0 0 0 0 / 1 1 1 1 0 / 1 1 1 1 1 / 0 1 1 1 0 / 0 0 0 0 0
(ii) Erosion by [1 1 1]ᵀ (vertical) — output is 1 only if above/self/below are all 1. Only column 2 has three stacked 1s (rows 1–3):
0 0 0 0 0 / 0 0 0 0 0 / 0 0 1 0 0 / 0 0 0 0 0 / 0 0 0 0 0
(iii) Dilation by 3 × 3 all-ones — output is 1 if any pixel in the 3 × 3 window is 1:
1 1 1 1 0 / 1 1 1 1 1 / 1 1 1 1 1 / 1 1 1 1 1 / 0 1 1 1 0
Observation to write: dilation grows the object in the directions of the SE; erosion keeps only pixels where the whole SE fits.
🏋️ Practice Set (answers at the end)
- Storage of a 512 × 512, 12-bit DICOM image in KB?
- Rotate (3, 1) by 90° counter-clockwise about (1, 1).
- Contrast-stretch r = 90 when the image range is 40–140 (8-bit).
- Median and mean of the neighbourhood {10, 12, 11, 255, 13, 12, 0, 11, 12}.
- Symbols with p = 0.5, 0.25, 0.125, 0.125: entropy and Huffman L_avg?
- Convert normalized RGB (0.6, 0.4, 0.2) to HSI.
- D4 and D8 distance between (2, 3) and (5, 7).
- Gamma correction s = r^0.5 on normalized r = 0.25.
Answers
- 512 × 512 × 12 = 3,145,728 bits = 393,216 bytes = 384 KB
- Translate by (−1,−1) → (2, 0); rotate → (0, 2); translate back → (1, 3)
- (90 − 40) × 255 / 100 = 127.5 → 128
- Sorted: 0, 10, 11, 11, 12, 12, 12, 13, 255 → median 12; mean 336/9 ≈ 37.3 (the impulse drags the mean — median wins for salt-and-pepper)
- H = 0.5(1) + 0.25(2) + 0.125(3) × 2 = 1.75 bits; Huffman codes 0, 10, 110, 111 → L_avg = 1.75 (100% efficient, since all p are powers of ½)
- I = 0.4; S = 1 − 3(0.2)/1.2 = 0.5; θ = cos⁻¹(0.3/√0.12) = cos⁻¹(0.866) = 30°, B ≤ G → H = 30°, S = 0.5, I = 0.4
- D4 = 3 + 4 = 7; D8 = max(3, 4) = 4 (Euclidean = 5)
- s = √0.25 = 0.5 → a dark value is brightened
🎯 CSS Exam Angle
DIP numericals in CSS have come from a small, predictable set: storage size, histogram equalization, Sobel/mask responses, morphology on a small binary image. Always show the table or grid step by step — partial marks are given for method even if one arithmetic step slips. When a question gives a figure, copy the grid into your answer before operating on it.