CSS Prepare

optional · CSS study notes

Point, Line, Edge and Boundary Detection

CSS Optional — Paper-II, Section-B · P-II.V.XI · Detection of discontinuities is the first half of segmentation. CSS 2018 set a Sobel gradient numerical — expect mask-based numericals here.

1. The Idea: Detecting Discontinuities

Segmentation uses two intensity properties: discontinuity (abrupt changes — points, lines, edges) and similarity (thresholding, region growing — see Image Segmentation). This page covers discontinuities, detected with derivatives implemented as small masks.

DerivativeBehaviourUsed for
First (gradient)Non-zero along a ramp; produces thick edgesEdge detection (Roberts, Prewitt, Sobel)
Second (Laplacian)Double response (+ then −) at an edge, zero-crossing at its centre; very sensitive to noisePoint detection, fine lines, locating edge centres

Mask response at a pixel: R = Σ w_i · z_i (sum of mask weight × pixel value over the 3 × 3 window).

2. Point Detection

  • Isolated point = pixel very different from its uniform surroundings.
  • Mask (Laplacian): [−1 −1 −1; −1 8 −1; −1 −1 −1]. Weights sum to 0 → response is 0 in flat regions.
  • Rule: point detected where |R| ≥ T (a chosen threshold).

3. Line Detection

Four directional masks; for each pixel pick the mask with the largest |R|:

DirectionMask (row by row)
Horizontal−1 −1 −1 / 2 2 2 / −1 −1 −1
Vertical−1 2 −1 / −1 2 −1 / −1 2 −1
Diagonal ↘ (top-left to bottom-right)2 −1 −1 / −1 2 −1 / −1 −1 2
Diagonal ↗ (bottom-left to top-right)−1 −1 2 / −1 2 −1 / 2 −1 −1

Which diagonal is called "+45°" depends on the axis convention (Gonzalez puts x downward) — in an answer, draw the mask and say which way it runs.

4. Edge Detection

Edge models: step (ideal, sharp), ramp (real, blurred), roof (thin line). Edges are pixels where intensity changes abruptly.

Gradient: ∇f = [gx, gy]; magnitude M = √(gx² + gy²) ≈ |gx| + |gy|; direction α = tan⁻¹(gy / gx). The edge runs perpendicular to the gradient direction.

OperatorSizeKey feature
Roberts2 × 2Diagonal differences; simplest, very noise-sensitive
Prewitt3 × 3gx = [−1 0 1; −1 0 1; −1 0 1]; equal weights
Sobel3 × 3gx = [−1 0 1; −2 0 2; −1 0 1], gy = [−1 −2 −1; 0 0 0; 1 2 1]; centre weight 2 adds smoothing → better noise handling
Laplacian3 × 3Second derivative; isotropic; double edges; rarely used alone
LoG (Marr-Hildreth)n × nGaussian smoothing + Laplacian; edges at zero-crossings
CannyAlgorithmOptimal detector: low error, good localization, single response per edge

Canny algorithm steps (high-yield):

  1. Smooth with a Gaussian filter to suppress noise.
  2. Compute gradient magnitude and direction (e.g. Sobel).
  3. Non-maximum suppression — keep only local maxima along the gradient direction → thin, 1-pixel edges.
  4. Double (hysteresis) thresholding — T_high marks strong edges; T_low marks weak candidates (typical ratio 2:1 or 3:1).
  5. Edge linking — keep weak edges only if connected to strong ones.

5. Boundary Detection (Edge Linking)

Edge detectors give broken, scattered edge pixels; boundary detection links them into closed object outlines.

  • Local processing: link neighbouring edge pixels whose gradient magnitude and direction are similar (within thresholds).
  • Regional processing: fit polygons / curves to known edge points.
  • Global — Hough transform: each edge point (x, y) votes for all lines through it using ρ = x cosθ + y sinθ; each point becomes a sinusoid in (ρ, θ) space; accumulator cells with many votes = lines. Robust to gaps and noise; extends to circles.
  • Boundary following (e.g. Moore tracing) walks around a region's border pixel by pixel.
  • Morphological boundary: β(A) = A − (A ⊖ B).
  • Chain codes (Freeman): describe a boundary as a sequence of directions (4- or 8-direction). The first difference of the code makes it rotation-invariant.

📐 Worked Numericals

N1 — CSS 2018: Sobel on an isolated point. Image: 5 5 5 / 5 50 5 / 5 5 5. Find the gradient magnitude at the centre.

  1. gx = (right column) − (left column), weights 1, 2, 1: (5 + 10 + 5) − (5 + 10 + 5) = 20 − 20 = 0
  2. gy = (bottom row) − (top row), weights 1, 2, 1: (5 + 10 + 5) − (5 + 10 + 5) = 0
  3. M = √(0² + 0²) = 0

Interpretation (the part that earns full marks): Sobel's centre weight is 0, so an isolated point is invisible to it — there is no edge here, only a point. Use the point-detection mask instead:

  1. R = 8 × 50 − (8 × 5) = 400 − 40 = 360 → with any reasonable T (e.g. 100), |R| ≥ T → isolated point detected.

N2 — Sobel on a vertical edge: 10 10 80 / 10 10 80 / 10 10 80.

  1. gx = (80 + 2×80 + 80) − (10 + 2×10 + 10) = 320 − 40 = 280
  2. gy = (10 + 20 + 80) − (10 + 20 + 80) = 0
  3. M = 280; α = tan⁻¹(0/280) = 0° → gradient points along x → the edge itself is vertical. (Prewitt on the same patch gives 240 − 30 = 210.)

N3 — Line detection: patch 10 10 10 / 50 50 50 / 10 10 10.

  • Horizontal mask: (−30) + (2 × 150) + (−30) = 240
  • Vertical mask: each row is (−1·a + 2·a − 1·a) = 0 → 0
  • Diagonal masks: 0 by the same symmetry
  • Max response = horizontal → horizontal line.

N4 — Hough transform: points (1, 1) and (2, 2). At θ = 135°: ρ = x cos135° + y sin135° = −0.707x + 0.707y → (1,1): 0; (2,2): 0. Both vote for cell (ρ = 0, θ = 135°) → they lie on one line through the origin (y = x).

N5 — Chain code: a 2 × 2 square traced clockwise from its top-left corner (4-direction code: 0 = right, 1 = up, 2 = left, 3 = down) → 0 0 3 3 2 2 1 1. First difference (counter-clockwise changes, mod 4, circular) → 3 0 3 0 3 0 3 0.


🎯 CSS Exam Angle

For any mask numerical: write the mask, lay it over the image, show each multiplication, then the sum. Always add one line of interpretation (what the number means) — the 2018 Sobel question is a trap whose answer is 0, and the marks are in explaining why. For theory questions, a gradient vs Laplacian comparison table plus the Canny steps covers most variants.

📌 Past CSS Paper Frequency

YearQuestion
2018Apply horizontal and vertical Sobel operators to a 3 × 3 image; compute gradient magnitude at the centre pixel (value 50)
SyllabusPoint, line, edge and boundary detection named explicitly — short notes and mask numericals are both fair game

⚠️ MCQ Traps

  • Masks for point/line/edge detection have weights that sum to zero (smoothing masks sum to one).
  • The edge is perpendicular to the gradient direction.
  • The Laplacian produces double edges and is very noise-sensitive; it is not directional.
  • Sobel ≠ Prewitt: Sobel weights the centre row/column by 2 (built-in smoothing).
  • Canny's thin edges come from non-maximum suppression; broken edges are fixed by hysteresis.
  • Hough transform uses the (ρ, θ) form, not slope-intercept, because vertical lines have infinite slope.

✅ Self-Check (with Answers)

Q1. Why do detection masks have coefficients that sum to zero?

Ans: So the response is zero in regions of constant intensity — the mask reacts only where intensity changes (points, lines, edges).

Q2. Compare first- and second-derivative edge detection.

Ans: First derivative (gradient: Sobel, Prewitt) gives thick edges along ramps and its magnitude shows edge strength. Second derivative (Laplacian) gives a double response with a zero-crossing at the edge centre — better for localization and fine detail, but much more noise-sensitive and has no direction information.

Q3. Apply Sobel to the patch 10 10 10 / 10 10 10 / 90 90 90.

Ans: gx = (10 + 20 + 90) − (10 + 20 + 90) = 0. gy = (bottom − top) = (90 + 180 + 90) − (10 + 20 + 10) = 360 − 40 = 320. M = 320, α = 90° → gradient points down, so the edge is horizontal.

Q4. Why does Sobel handle noise better than Prewitt?

Ans: Sobel weights the centre row/column by 2, which acts as built-in smoothing perpendicular to the derivative direction, reducing noise response.

Q5. What do non-maximum suppression and hysteresis do in Canny?

Ans: Non-maximum suppression keeps only pixels that are local maxima along the gradient direction, thinning edges to one pixel. Hysteresis thresholding keeps strong edges (> T_high) and keeps weak edges (between T_low and T_high) only if connected to strong ones — removing noise while avoiding broken edges.

Q6. Why does the Hough transform use ρ = x cosθ + y sinθ instead of y = mx + c?

Ans: In slope-intercept form, vertical lines have infinite slope. The normal (ρ, θ) form is bounded for every line, so the accumulator array is finite.

📜 Past-Paper Questions & MCQs (CSS 2016–2026)

2018 · Paper-II · Q7(B) · 6 marks

Q. For the 3 × 3 image [5 5 5; 5 50 5; 5 5 5], apply the horizontal and vertical Sobel operators and compute the magnitude of the gradient at the central pixel.

Ans.

  • Sobel masks: Gx = [−1 0 1; −2 0 2; −1 0 1] and Gy = [−1 −2 −1; 0 0 0; 1 2 1].
  • Gx = (5 + 2·5 + 5) − (5 + 2·5 + 5) = 20 − 20 = 0.
  • Gy = (5 + 2·5 + 5) − (5 + 2·5 + 5) = 20 − 20 = 0.
  • Magnitude = √(Gx² + Gy²) = √(0 + 0) = 0.
  • Why: the central pixel's own weight is 0 in both Sobel masks, and the surrounding pixels are all equal (5), so the operator sees no change. (A Laplacian mask, by contrast, would respond strongly to this isolated bright point.)

2024 · Paper-II · Q7(a) · 7 marks

Q. Explain the algorithms used for point detection, line detection, edge detection and boundary detection in digital images. Discuss their strengths and limitations.

Ans.

  • Point detection: a Laplacian-type mask (8 around a centre of −8 or the reverse) responds strongly at an isolated point, and the response is thresholded. Strength: simple. Limit: very noise sensitive.
  • Line detection: four masks (horizontal, vertical, +45°, −45°) or the Hough transform. Strength: Hough finds lines even with gaps. Limit: mask size and orientation limits, and the Hough transform is costly.
  • Edge detection:
    • Gradient-based (Roberts, Prewitt, Sobel): first derivative, with edges at high gradient magnitude. Simple, but gives thick edges and is noise sensitive.
    • Laplacian of Gaussian (LoG): smooths, then finds zero crossings of the second derivative.
    • Canny: Gaussian smoothing, gradient, non-maximum suppression and hysteresis thresholding. It gives thin, well-localised, low-noise edges but needs tuning of parameters.
  • Boundary detection: edge linking and boundary tracing (chain codes), morphological boundary extraction and contour following. Limit: gaps and noise break contours.

2026 · Paper-II · Q8 · 20 marks

Q. Feature extraction is central to computer vision. Describe how edge detection techniques differ in their response to noise, texture and illumination variations. Compare the boundary localisation accuracy among the classical detectors Sobel, Canny and Laplacian-based methods.

Ans.

  • Edges are sharp intensity changes found with derivatives. The first derivative has a peak at an edge, and the second derivative has a zero crossing.
  • Response to noise: differentiation amplifies noise.
    • Sobel: built-in small smoothing (the 1-2-1 weights), so moderately robust.
    • Laplacian: second derivative, so very noise sensitive. Needs prior Gaussian smoothing (LoG).
    • Canny: Gaussian smoothing with a chosen σ, so the most noise robust.
  • Response to texture: fine texture (fabric, grass) produces many small gradients that appear as false edges. Sobel and Laplacian respond to all of them, while Canny with a larger σ and hysteresis thresholds suppresses weak texture edges but may also lose fine real edges.
  • Response to illumination variation: gradient-magnitude detectors scale with brightness, so shadows and gradual shading can create or hide edges. Zero-crossing detectors (LoG) are less affected by slowly varying illumination. Canny's two thresholds partly adapt, and local or adaptive thresholds help.
DetectorNoiseEdge width and localisationNotes
SobelModerateThick edges, moderate localisation, and it gives directionFast and simple
Laplacian / LoGPoor (Laplacian), good with smoothing (LoG)Zero crossings are well located and form closed contours, but they also give spurious edgesNo direction information
CannyBestThin (1 pixel) edges and the best localisation (non-maximum suppression)Slower and needs parameters (σ and two thresholds)
  • Boundary localisation accuracy (best to worst): Canny > LoG (zero crossings) > Sobel.
  • Conclusion: choose Sobel for speed on clean images, Laplacian-based methods when closed contours and illumination robustness are needed (with smoothing), and Canny for the most accurate, low-noise boundaries.

MCQs

2024 P-II · Q16. SIFT is:

  • (A) An image deblurring algorithm
  • (B) A basic edge detection algorithm
  • (C) Used to identify and define local features ✅
  • (D) None of these
  • Answer: (C).
  • Why: the Scale-Invariant Feature Transform finds keypoints and describes them with local descriptors that stay stable under changes of scale and rotation, for matching and recognition. It is not a deblurring or edge detection method.

2024 P-II · Q19. Which of the following is true about the Wiener filter?

  • (A) It is a deterministic algorithm
  • (B) It minimizes the quadratic error ✅
  • (C) It uses the binary cross entropy
  • (D) None of these
  • Answer: (B).
  • Why: the Wiener filter is the linear filter that minimises the mean-square (quadratic) error between the restored and the original image, using the statistics of the signal and the noise. It is statistical, not deterministic, and cross entropy belongs to classification models.

2026 P-II · Q7. The main purpose of using a Laplacian of Gaussian (LoG) operator in image analysis is to:

  • (A) Detect extremely low-frequency patterns
  • (B) Identify regions of uniform colour
  • (C) Localise edges by combining smoothing and second-order derivatives ✅
  • (D) None of these
  • Answer: (C).
  • Why: LoG first smooths the image with a Gaussian to suppress noise, then applies the Laplacian (second derivative). Edges appear as zero crossings of the result, so they are well localised.