optional · CSS study notes
Image Transformations
CSS Optional — Paper-II, Section-B · P-II.V.V · Syllabus names Translation, Scaling, Rotation and Shear. Asked in CSS 2017 ("briefly explain geometric transformations"). Matrix-based numericals are quick marks.
1. What Is a Geometric Transformation?
A geometric (spatial) transformation changes where pixels are, not their intensity. It has two steps:
- Coordinate transformation — map each (x, y) to a new (x', y').
- Intensity interpolation — new positions rarely land exactly on the grid, so values are estimated (nearest-neighbour, bilinear, bicubic).
Contrast with intensity transformations (negative, gamma, histogram equalization), which change pixel values but not positions.
2. Homogeneous Coordinates — Why a 3 × 3 Matrix?
Scaling, rotation and shear are linear and fit a 2 × 2 matrix, but translation is an addition, not a multiplication. Writing a point as [x, y, 1] lets every transformation be a 3 × 3 matrix, so a whole chain of transformations collapses into one matrix product.
[x' y' 1]ᵀ = T · [x y 1]ᵀ
3. The Four Basic Transformations
| Transformation | Equations | Matrix T (row by row) | Effect |
|---|---|---|---|
| Translation | x' = x + tx; y' = y + ty | 1 0 tx / 0 1 ty / 0 0 1 | Shifts position; shape and size unchanged |
| Scaling | x' = sx·x; y' = sy·y | sx 0 0 / 0 sy 0 / 0 0 1 | Enlarges (s > 1) or shrinks (s < 1); sx ≠ sy distorts shape; area × sx·sy |
| Rotation (CCW by θ) | x' = x cosθ − y sinθ; y' = x sinθ + y cosθ | cosθ −sinθ 0 / sinθ cosθ 0 / 0 0 1 | Turns about the origin; distances and angles preserved |
| Shear (horizontal) | x' = x + shx·y; y' = y | 1 shx 0 / 0 1 0 / 0 0 1 | Slants along x; rectangles become parallelograms; area preserved (det = 1) |
| Shear (vertical) | x' = x; y' = y + shy·x | 1 0 0 / shy 1 0 / 0 0 1 | Slants along y |
Reflection (bonus): about the x-axis → y' = −y; about the y-axis → x' = −x; it is scaling with s = −1.
4. Composite Transformations
- Rotation and scaling as written act about the origin. To rotate about a point (xc, yc): translate (−xc, −yc) → rotate → translate (+xc, +yc), i.e.
T = T(xc,yc) · R(θ) · T(−xc,−yc). - Matrix multiplication is not commutative: rotate-then-translate ≠ translate-then-rotate. The rightmost matrix acts first.
5. Forward vs Inverse Mapping
| Approach | How | Problem / advantage |
|---|---|---|
| Forward mapping | For each input pixel, compute where it lands in the output | Leaves HOLES (unassigned outputs) and overlaps |
| Inverse mapping | For each output pixel, apply T⁻¹ to find its source location, then interpolate | No holes — used in practice (e.g. MATLAB imwarp, OpenCV warpAffine) |
6. Hierarchy — What Each Class Preserves
| Class | Includes | Preserves |
|---|---|---|
| Rigid (Euclidean) | Translation + rotation | Distances, angles, area |
| Similarity | Rigid + uniform scaling | Angles, shape |
| Affine | All of the above + non-uniform scaling + shear | Parallel lines, ratios along a line |
| Projective (perspective) | Affine + perspective effects | Straight lines only |
7. Applications
Image registration (aligning medical scans or satellite images taken at different times), correcting lens and perspective distortion, document de-skewing before OCR, data augmentation for deep learning, zoom and rotate in photo apps.
📐 Worked Numericals
N1 — Translation: (2, 3) by (tx, ty) = (5, −1) → (7, 2)
N2 — Scaling: (2, 3) with sx = 2, sy = 0.5 → (4, 1.5)
N3 — Rotation about origin: (4, 3) by 90° CCW (cos = 0, sin = 1): x' = 4·0 − 3·1 = −3; y' = 4·1 + 3·0 = 4 → (−3, 4)
N4 — Shear: unit square (0,0), (1,0), (1,1), (0,1) with shx = 1 → (0,0), (1,0), (2,1), (1,1) — a parallelogram with the same area (1), since det = 1.
N5 — Rotation about a pivot: rotate (4, 3) by 90° CCW about (2, 2).
- Translate by (−2, −2): (2, 1)
- Rotate 90°: (−1, 2)
- Translate back by (+2, +2): (1, 4)
N6 — Scaling a triangle: A(0,0), B(4,0), C(0,3), scale by 2 about the origin → (0,0), (8,0), (0,6). Area goes from 6 to 24 (× sx·sy = 4).
N7 — Composite matrix: scale by 2 then translate by (3, 1): T = [1 0 3; 0 1 1; 0 0 1] · [2 0 0; 0 2 0; 0 0 1] = [2 0 3; 0 2 1; 0 0 1]. Point (1, 1) → (2·1 + 3, 2·1 + 1) = (5, 3).
🎯 CSS Exam Angle
For "explain geometric transformations" (2017): define the two steps (mapping + interpolation), give the four matrices in homogeneous form, and add one small worked example per transformation — examiners like seeing the matrix applied. Mention inverse mapping and one application (registration or OCR de-skew) to lift the answer above textbook recall.
📌 Past CSS Paper Frequency
| Year | Question |
|---|---|
| 2017 | Briefly explain geometric transformations |
⚠️ MCQ Traps
- Translation needs homogeneous coordinates to be a matrix multiplication; a plain 2 × 2 matrix cannot translate.
- Composite order matters — the rightmost matrix is applied first.
- Shear preserves area (det = 1); scaling changes area by sx·sy.
- Rotation matrix for clockwise rotation swaps the signs of the sin terms.
- Because image y (row) axis points down, a mathematically CCW rotation can look clockwise on screen.
- Geometric transforms move pixels; intensity transforms change values — different syllabus items.
✅ Self-Check (with Answers)
Q1. Why are homogeneous coordinates used?
Ans: Translation is an addition, not a matrix multiplication, in 2-D. Writing points as [x, y, 1] makes translation (and all affine transformations) a 3 × 3 matrix multiplication, so any chain of transformations combines into one matrix.
Q2. Rotate (2, 0) by 90° counter-clockwise about the origin.
Ans: x' = 2·0 − 0·1 = 0; y' = 2·1 + 0·0 = 2 → (0, 2).
Q3. Apply a vertical shear shy = 2 to the point (1, 1).
Ans: x' = x = 1; y' = y + shy·x = 1 + 2 = 3 → (1, 3).
Q4. Why is inverse mapping preferred over forward mapping?
Ans: Forward mapping sends input pixels to non-integer output positions, leaving holes and overlaps. Inverse mapping visits every output pixel, computes its source location with T⁻¹ and interpolates, so every output pixel gets a value.
Q5. Does scale-then-translate give the same result as translate-then-scale? Check with point (1, 1), scale 2, translate (3, 0).
Ans: Scale then translate: (2, 2) → (5, 2). Translate then scale: (4, 1) → (8, 2). Different → transformations are not commutative.
Q6. Which transformations preserve area?
Ans: Translation, rotation, reflection and shear (all have |det| = 1). Scaling changes area by a factor of sx·sy.
📜 Past-Paper Questions & MCQs (CSS 2016–2026)
2017 · Paper-II · Q7(c) and 2020 · Paper-II · Q7(c) · 6 marks each
Q. Briefly explain geometric transformations. What is translation and scaling?
Ans.
- Geometric transformations change the positions of pixels (not their values) through a coordinate mapping, usually with a 3 × 3 homogeneous matrix. Two steps: a spatial transformation of coordinates and an intensity interpolation (nearest-neighbour, bilinear, bicubic) to fill the output pixels.
- Translation: moves every pixel by (tₓ, t_y): x′ = x + tₓ, y′ = y + t_y.
- Scaling: enlarges or shrinks by factors (sₓ, s_y): x′ = sₓ·x, y′ = s_y·y (a factor above 1 enlarges, below 1 shrinks).
- Others: rotation (x′ = x cos θ − y sin θ, y′ = x sin θ + y cos θ), shear and reflection.
- Matrix form: [x′ y′ 1]ᵀ = T [x y 1]ᵀ. Several transformations can be combined by multiplying their matrices.
- Uses: image alignment (registration), resizing, correcting distortion and graphics.
MCQs
2026 P-II · Q5. When applying a 2D Fourier Transform to an image, shifting the image spatially causes which corresponding effect in the frequency domain?
- (A) Phase modulation ✅
- (B) Amplitude scaling
- (C) Frequency doubling
- (D) None of these
- Answer: (A) Phase modulation.
- Why: by the shift property, f(x − x₀, y − y₀) has the transform F(u, v) · e^(−j2π(ux₀/M + vy₀/N)). The magnitude |F(u, v)| does not change, and only the phase is modified by a linear phase term. So the spectrum is not scaled (B), and no frequency is doubled (C).