CSS Prepare

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

TopicFormula
Gray levelsL = 2^k; range 0 … L−1
Storageb = M × N × k bits (× 3 channels for RGB)
Image formationf(x,y) = i(x,y) · r(x,y); 0 < r < 1
Distances p(x,y), q(s,t)De = √((x−s)² + (y−t)²); D4 =
Negatives = L − 1 − r
Log / power-laws = c·log(1 + r); s = c·r^γ (γ < 1 brightens, γ > 1 darkens)
Contrast stretchings = (r − rmin) × (L − 1) / (rmax − rmin)
Histogram equalizations_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
GradientM = √(gx² + gy²) ≈
Laplacian sharpeningg = f − ∇²f (centre coefficient negative)
Unsharp / high-boostg = f + k(f − f_blur); k = 1 unsharp, k > 1 high-boost
RGB ↔ CMYC = 1 − R, M = 1 − G, Y = 1 − B (normalized)
CMY → CMYKK = min(C,M,Y); C' = (C−K)/(1−K), etc.
RGB → HSII = (R+G+B)/3; S = 1 − 3·min/(R+G+B); H = θ if B ≤ G else 360° − θ
LuminanceY = 0.299R + 0.587G + 0.114B
Degradation modelg = h ⋆ f + η; G = H·F + N
Uniform noisemean (a+b)/2; variance (b−a)²/12
Compression ratio / redundancyC = b / b'; R = 1 − 1/C
EntropyH = −Σ p_k log₂ p_k bits/symbol
Average code lengthL_avg = Σ l_k · p_k
PSNR10 log₁₀(255² / MSE) dB
MorphologyOpening = (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

  1. Pixels = 256 × 200 = 51,200
  2. 24 bits = 3 bytes per pixel
  3. 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_kn_kp = n_k / 4096Cumulative ps = 7 × cumulativeRounded s
07900.190.191.331
110230.250.443.083
28500.210.654.555
36560.160.815.676
43290.080.896.236
52450.060.956.657
61220.030.986.867
7810.021.007.007

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)

  1. Storage of a 512 × 512, 12-bit DICOM image in KB?
  2. Rotate (3, 1) by 90° counter-clockwise about (1, 1).
  3. Contrast-stretch r = 90 when the image range is 40–140 (8-bit).
  4. Median and mean of the neighbourhood {10, 12, 11, 255, 13, 12, 0, 11, 12}.
  5. Symbols with p = 0.5, 0.25, 0.125, 0.125: entropy and Huffman L_avg?
  6. Convert normalized RGB (0.6, 0.4, 0.2) to HSI.
  7. D4 and D8 distance between (2, 3) and (5, 7).
  8. Gamma correction s = r^0.5 on normalized r = 0.25.

Answers

  1. 512 × 512 × 12 = 3,145,728 bits = 393,216 bytes = 384 KB
  2. Translate by (−1,−1) → (2, 0); rotate → (0, 2); translate back → (1, 3)
  3. (90 − 40) × 255 / 100 = 127.5 → 128
  4. 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)
  5. 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 ½)
  6. 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
  7. D4 = 3 + 4 = 7; D8 = max(3, 4) = 4 (Euclidean = 5)
  8. 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.