Computer Vision Interview
20 essential Q&A
Updated 2026
morphology
Morphological Operations: 20 Essential Q&A
Set-based operations on binary and grayscale images—building blocks for cleanup and shape analysis.
~11 min read
20 questions
Intermediate
erosiondilationopeningSE
Quick Navigation
1
What is mathematical morphology?
⚡ easy
Answer: Non-linear image ops based on set theory with a structuring element—shape analysis, denoising binary masks, and extracting boundaries.
2
Define erosion (binary).
📊 medium
Answer: SE fits inside foreground: output pixel on only if SE fully contained in foreground—shrinks objects, removes thin protrusions, separates touching objects if SE sized right.
3
Define dilation (binary).
📊 medium
Answer: SE hits foreground: output on if SE overlaps foreground—grows objects, fills small holes and gaps, reconnects broken strokes.
4
What is opening?
📊 medium
Answer: Erosion then dilation with same SE—removes small bright noise (pepper) and smooths boundaries without changing coarse size as much as raw erosion.
5
What is closing?
📊 medium
Answer: Dilation then erosion—fills small dark holes (salt holes in foreground), connects nearby components, smooths inward concavities.
6
What is a structuring element (SE)?
⚡ easy
Answer: Small binary mask defining neighborhood shape—disk is isotropic; rectangle aligns to axes; size controls scale of effect.
7
Disk vs square SE?
⚡ easy
Answer: Disk gives isotropic rounding; axis-aligned square can preserve Manhattan geometry—choice affects anisotropy of shrink/grow.
8
State duality between erosion and dilation.
🔥 hard
Answer: Erosion of foreground equals dilation of background complement (with reflected SE)—lets derive properties and implement efficiently.
9
Extract boundary with morphology?
📊 medium
Answer: Boundary ≈ original − eroded (or XOR variants)—gives outer contour ring depending on SE.
10
What is morphological gradient?
📊 medium
Answer: Dilation − erosion—edge strength similar to gradient magnitude on binary shapes; outer/inner gradients are variants.
11
What is white top-hat?
🔥 hard
Answer: Image − opening—extracts bright small details larger than SE removed by opening; black top-hat is closing − image for dark details.
12
What is hit-or-miss?
🔥 hard
Answer: Template matching for specific pixel configurations—detects corners, endpoints, pruned skeletons using paired SE foreground/background patterns.
13
Grayscale erosion/dilation?
📊 medium
Answer: Min/max filter over SE neighborhood—useful for texture and background estimation; different from binary set interpretation but analogous.
14
Does order of opening and closing commute?
⚡ easy
Answer: No—generally opening∘closing ≠ closing∘opening. Order matters for pipeline design.
15
Clean scanned text binary mask?
📊 medium
Answer: Opening removes speckle; closing fills letter breaks—tune SE smaller than stroke width to avoid destroying characters.
16
Larger SE effect?
⚡ easy
Answer: Removes/fills larger features; too large destroys valid structure—scale SE to minimum noise size you want removed.
17
Fill holes in binary objects?
📊 medium
Answer: Geodesic reconstruction, conditional dilation from border, or flood-fill tricks—classic interview “beyond closing” answer.
18
What is skeletonization?
📊 medium
Answer: Reduce foreground to 1-pixel-wide medial axis preserving topology—sequential morphological thinning or distance-transform methods.
19
OpenCV
morphologyEx types?
⚡ easy
Answer:
MORPH_OPEN, CLOSE, GRADIENT, TOPHAT, BLACKHAT, HITMISS—single API with MORPH_ERODE/DILATE base.
kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (5, 5))
clean = cv2.morphologyEx(mask, cv2.MORPH_OPEN, kernel)
20
Morphology vs linear convolution?
📊 medium
Answer: Morphology is min/max (nonlinear); convolution is weighted sum. Morphology preserves sharp extrema semantics for shapes.
Morphology Cheat Sheet
Core
- Erode / dilate
- Open / close
SE
- Shape + size
- Reflect for theory
Extras
- Gradient / tophat
- Hit-miss
💡 Pro tip: Opening removes pepper; closing fills holes—memorize order.
Full tutorial track
Go deeper with the matching tutorial chapter and code examples.