← CV vault · solved paper · mid-sem

Computer Vision — mid-sem paper, fully solved.

cv solved-paper mid-sem image-processing

The full Computer Vision mid-semester paper, every question worked end-to-end. Each question sits in a box and its full solution is one click away in a collapsible panel. At the end is a makeup-exam study guide — the makeup tests the same concepts with new numbers, so learn the method.

How to use this. Try each boxed question on paper first, then expand “Show worked solution”. Final answers are in accent colour.

Q1 — Sampling, quantization & contrast stretching 2 + 3 marks

(a) Explain “Sampling” and “Quantization” in digital image processing. (b) An image has pixel values in [50, 150]. Apply contrast stretching to the full 8-bit range [0, 255]. What is the new value of a pixel with original intensity 100?

Show worked solution

(a) Sampling vs Quantization.

  • Sampling = discretizing the spatial coordinates (x, y). It decides how many pixels the image has — i.e. the spatial resolution. Coarser sampling → fewer pixels → blocky image.
  • Quantization = discretizing the intensity/amplitude into a finite number of levels (e.g. \(2^8 = 256\) gray levels for 8-bit). It sets the gray-level resolution. Fewer levels → false contouring.

(b) Contrast stretching. Linear map from [50, 150] to [0, 255]:

\[ s = \frac{(r - r_{min})}{(r_{max}-r_{min})}\,(L-1) = \frac{(100-50)}{(150-50)}\times 255 = \frac{50}{100}\times 255 = 127.5 \]

New value \(\approx\) 127.5 ≈ 128.

Q2 — Intensity transforms, Hough mapping, Gaussian vs average 2 + 2 + 1 marks

(a) An image has low contrast and noise. How would you combine two intensity-transformation techniques to improve it? Justify. (b) A point \((x_0,y_0)=(3,4)\) maps to a Hough-space line \(b=-x_0 m + y_0\). Compute \(b\) for \(m=2\) and \(m=-1\). (c) Why is a Gaussian filter often preferred over a simple averaging filter?

Show worked solution

(a) Apply them in the right order: first denoise (e.g. Gaussian smoothing, or a median filter for salt-and-pepper noise), then enhance contrast (histogram equalization or contrast stretching). Justification: enhancing first would amplify the noise; smoothing first removes noise but slightly lowers contrast, which the stretching/equalization step then restores.

(b) \(b = -x_0 m + y_0 = -3m + 4\).

\(m=2:\ b = -3(2)+4 = \) −2.
\(m=-1:\ b = -3(-1)+4 = \) 7.

(c) Gaussian over averaging. The Gaussian weights nearby pixels more than distant ones (distance-weighted), giving a smooth, isotropic blur that preserves edges better and produces no ringing. A box (averaging) filter weights all pixels equally; its frequency response is a sinc, causing ringing artifacts and a harsher, blockier blur. The Gaussian is also separable (fast) and has no preferred direction.

Q3 — Edge-detection kernel & convolution 1 + 2 marks

A simplified edge-detection kernel \(\begin{bmatrix}-1&0&1\\-1&0&1\\-1&0&1\end{bmatrix}\). (a) What edges does it primarily detect? (b) Apply it to the central pixel of the patch \(\begin{bmatrix}12&15&18\\15&10&15\\18&15&12\end{bmatrix}\).

Show worked solution

(a) This is a Prewitt horizontal-gradient operator: it differences the right column minus the left column, so it responds to horizontal intensity changes → it detects vertical edges.

(b) Response at the centre = (right column sum) − (left column sum):

\[ R = (18+15+12) - (12+15+18) = 45 - 45 = \] 0

The patch is left–right symmetric, so there is no horizontal gradient → the vertical-edge detector outputs 0 (no vertical edge here).

Q4 — RGB vs CMYK; Laplacian kernels 2 + 3 marks

Compare RGB and CMYK colour models and why each is used. Then for the 5×5 image (left three columns = 150, right two columns = 50), compute the Laplacian at an edge location using kernels \(\begin{bmatrix}0&1&0\\1&-4&1\\0&1&0\end{bmatrix}\) and \(\begin{bmatrix}1&1&1\\1&-8&1\\1&1&1\end{bmatrix}\), and compare their performance.

Show worked solution

RGB vs CMYK. RGB is additive (red+green+blue light add to white) — used by emissive displays (monitors, cameras, phones). CMYK is subtractive (cyan, magenta, yellow inks absorb light; K = black for depth/economy) — used for printing. They differ because screens emit light while paper reflects it; CMYK also has a smaller gamut, so colours are converted when printing.

Laplacian at the edge (boundary between the 150-region col 3 and 50-region col 4). Take a centre pixel on the 150 side (value 150, left/up/down = 150, right = 50):

4-neighbour: \(L = (150+150+150+50) - 4(150) = 500-600 = \) −100
8-neighbour: \(L = (150{+}150{+}50{+}150{+}50{+}150{+}150{+}50) - 8(150) = 900-1200 = \) −300

On the 50 side (centre 50, left = 150, others 50): 4-nbr \(L=(50{+}50{+}150{+}50)-4(50)=+100\); 8-nbr \(L=+300\).

Comparison. Both give zero in flat regions and a strong response across the edge. The 8-neighbour kernel gives a larger magnitude (includes diagonals → stronger, captures diagonal edges) but is more sensitive to noise; the 4-neighbour kernel is weaker but more noise-robust. The sign flips across the edge (the zero-crossing marks the edge location).

Q5 — Hough parameter spaces; edge vs corner 3 + 2 marks

(a) In the Hough transform, give the \(m\text{-}c\) and \(r\text{-}\theta\) representations of points \((2,0)\) and \((2,5)\). (b) Differentiate between an edge and a corner.

Show worked solution

(a) In slope–intercept (m-c) space a point \((x,y)\) maps to the line \(c = -x\,m + y\):

\((2,0):\ c = -2m + 0 \Rightarrow c = -2m\)
\((2,5):\ c = -2m + 5\)

These two lines have the same slope (−2) → parallel → no intersection, which means the two points lie on a vertical line (\(m=\infty\)). This is exactly why m-c space fails for vertical lines and motivates the normal form.

In normal (r-θ) space, \(r = x\cos\theta + y\sin\theta\):

\((2,0):\ r = 2\cos\theta\)
\((2,5):\ r = 2\cos\theta + 5\sin\theta\)

These two sinusoids intersect at a finite \((r,\theta)\), correctly representing the vertical line — no infinite slope problem.

(b) Edge vs corner. An edge is an intensity discontinuity in one direction (high gradient across the edge, ~zero along it) — it is localizable in one direction only (aperture problem). A corner is where intensity changes significantly in two directions (the gradient varies along both axes); it is a distinctive, well-localized feature (Harris/Shi-Tomasi), ideal for matching and tracking.

Q6 — HOG binning & RANSAC 3 + 2 marks

(a) In the 9-bin HOG histogram, determine the bin boundaries and compute the histogram contribution for a pixel with gradient direction 57°. (b) What is the RANSAC algorithm and a few of its applications?

Show worked solution

(a) HOG, 9 bins, unsigned gradients over [0°, 180°), bin width \(180/9 = 20°\). Using bin centres at 10, 30, 50, 70, 90, 110, 130, 150, 170 (or boundaries 0–20, 20–40, …). A direction of 57° falls between the centres 50° and 70°, so its magnitude \(m\) is split by linear interpolation:

to 50°-bin: \(m\times\dfrac{70-57}{20} = 0.65\,m\)
to 70°-bin: \(m\times\dfrac{57-50}{20} = 0.35\,m\)

So 65% of the magnitude votes to the 50° bin and 35% to the 70° bin (if you index bins by lower boundary 40–60 and 60–80, 57° is in the 40–60 bin and is shared with 60–80 by the same interpolation). Soft binning avoids aliasing.

(b) RANSAC = RANdom SAmple Consensus, a robust model-fitting method that tolerates many outliers. Loop: (1) randomly pick the minimal sample needed to fit the model; (2) fit the model; (3) count inliers (points within a threshold); (4) repeat for N iterations and keep the model with the most inliers; (5) refit using all inliers. Applications: line/plane fitting, homography and fundamental/essential matrix estimation, image stitching/panoramas, feature-match outlier rejection, and 3-D point-cloud registration.


Makeup exam — what to study study guide

The makeup paper tests the same concepts with new numbers. Drill the methods below.

Concept (revise this)Tested inWhat to be able to do
Sampling, quantization, intensity transformsQ1, Q2a, Q4Define sampling vs quantization; apply contrast stretching / histogram equalization; order denoise-then-enhance and justify.
Spatial filtering (smoothing)Q2c, Q4Compare Gaussian vs box/median filters; compute a Laplacian with 4- and 8-neighbour kernels and read the zero-crossing.
Edge detection & convolutionQ3, Q4, Q5bIdentify Sobel/Prewitt/Laplacian kernels; convolve a 3×3 patch by hand; distinguish edges vs corners.
Hough transformQ2b, Q5aMap points to m-c and r-θ space; explain why r-θ handles vertical lines; compute b or r for given m/θ.
Colour modelsQ4Contrast additive RGB vs subtractive CMYK and their use cases.
Feature descriptors & robust fittingQ6Compute HOG bin votes with interpolation; describe the RANSAC loop and its CV applications.
Fast revision path: the CV cheatsheet and formula sheet for the transforms and kernels, then re-drill convolution and Hough on the question bank.
← CV vault CV cheatsheet →
© cvam — written in plaintext, served warm