Skip to content
Tutorials Center
My learning

Topics

Lesson 45 of 46 ยท Practice and Review

Computer Vision Interview Questions

Prepare for computer vision interviews: convolution vs correlation, Otsu, Canny, receptive field, IoU and NMS, overfitting and bias, with short answers and code.

Computer vision interviews rarely ask for obscure formulas. They check whether you understand a handful of ideas well enough to explain them in your own words and to reason about what happens when something goes wrong: why a filter behaves as it does, how an algorithm chooses its parameters, how a network sees an image, and how you would know whether a model can be trusted. Good candidates give a short definition first and then back it up with a small example or a number.

This page collects the questions that come up most often, with answers short enough to say aloud. Several answers come with runnable code, because "let me show you with a five-line experiment" is a strong move in an interview. Related lessons are linked so you can revisit any topic that feels shaky.

flowchart LR
    A["Vision interview"] --> B["Pixels and filters<br/>arrays, convolution"]
    A --> C["Classical algorithms<br/>Otsu, Canny, corners"]
    A --> D["Deep learning<br/>CNNs, receptive field"]
    A --> E["Evaluation<br/>IoU, NMS, bias"]

The four areas that most questions fall into.

Pixels and filters

1. How is a digital image represented, and what are the usual pitfalls?

As a NumPy-style array of shape (height, width) for grayscale or (height, width, channels) for color, indexed [row, column]. The classic pitfalls are mixing up row/column with x/y, assuming RGB order when a library returns BGR, and uint8 arithmetic that wraps around (250 + 10 gives 4) instead of saturating. See Images as Arrays and Brightness, Contrast and Gamma.

2. What is the difference between convolution and correlation?

Both slide a kernel over the image and sum products. Correlation uses the kernel as written; convolution first flips it in both directions. For a symmetric kernel (a box or Gaussian blur) they give identical results. For an asymmetric kernel they differ, and the easiest way to remember is the impulse test: convolving an image that contains a single bright pixel stamps the kernel itself into the output, while correlation stamps it rotated by 180 degrees.

Python The impulse test

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Follow-up you should expect: what do deep learning libraries do? Most of them actually compute correlation and call it convolution. It does not matter, because the kernel values are learned, so the network simply learns the flipped version. See Convolution and Correlation.

3. When would you use a median filter instead of a Gaussian blur?

A Gaussian averages neighbours, so a bright outlier is smeared into its surroundings. A median takes the middle value of the window, so isolated outliers (salt-and-pepper noise) vanish completely and edges stay sharper. The Gaussian is better for smooth sensor noise, and it is separable, so a large blur costs two 1D passes instead of one big 2D one. See Blurring and Denoising.

4. Why are separable kernels useful?

A 2D kernel that is the outer product of two 1D vectors can be applied as one horizontal and one vertical pass. A k by k window costs 2k multiplications per pixel instead of k*k. Gaussian and box kernels are separable; a Sobel kernel is too (a smoothing vector times a difference vector).

Classical algorithms

5. How does Otsu's method choose a threshold?

It tries every possible cutoff on the histogram, splits the pixels into a dark and a bright class, and keeps the cutoff that maximizes the between-class variance w0 * w1 * (m0 - m1)^2, which is equivalent to minimizing the variance inside the classes. It assumes the histogram has two roughly separated modes, so it struggles with three regions, with a tiny object on a large background, and with uneven lighting (use an adaptive threshold there). See Thresholding.

6. Walk me through the Canny edge detector.

Five steps. (1) Smooth the image with a Gaussian to suppress noise. (2) Compute the gradient magnitude and direction, typically with Sobel. (3) Non-maximum suppression: keep a pixel only if its magnitude is the largest along the gradient direction, which thins edges to one pixel. (4) Double threshold: pixels above the high threshold are strong edges, those below the low threshold are discarded, and the rest are weak. (5) Hysteresis: keep a weak pixel only if it connects to a strong edge. Step 5 is easy to demonstrate with connected components:

Python Hysteresis in a few lines

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The connected weak segment survives (9 pixels kept in total) while the isolated one is dropped. That is exactly why Canny edges are long and continuous instead of speckled. More detail in Gradients and Edge Detection.

7. What makes a good corner, and how does Harris detect it?

A corner is a point where the image changes strongly in every direction when you shift a small window; an edge changes in only one direction, and a flat patch in none. Harris builds the 2 by 2 structure tensor from the gradients in the window. Two large eigenvalues mean a corner, one large and one small mean an edge, two small mean a flat region. The response det(M) - k * trace(M)^2 summarizes this without computing eigenvalues. See Corner Detection.

8. Why is scale a problem for features, and how is it handled?

The same object looks different at different distances, and a fixed window sees different content. Detectors search over a scale space (a pyramid of progressively blurred and smaller images) and keep the scale where a response such as the Laplacian of Gaussian peaks. See Image Pyramids and Scale Space.

9. How does RANSAC help when matching keypoints?

Descriptor matching always contains wrong matches (outliers). RANSAC repeatedly picks a minimal random set of matches, fits a transform to it, counts how many other matches agree (the inliers), and finally keeps the transform with the most inliers. Outliers cannot agree on one transform, so they get voted out. See Keypoint Descriptors and Matching.

Neural networks for vision

10. Why use convolutional layers instead of fully connected layers for images?

Weight sharing and locality. A kernel is applied at every position, so the layer needs far fewer parameters and detects a pattern wherever it appears (translation equivariance). A fully connected layer from a 224 by 224 by 3 image to just 1,000 units would need about 150 million weights; a 3 by 3 convolution with 64 filters needs 1,728. See The Convolutional Layer.

11. What is the receptive field, and how do you compute it?

The region of the input image that can influence one output unit. Track two numbers while walking through the layers: the receptive field rf and the jump (distance in input pixels between neighbouring units). For each layer with kernel k and stride s: rf += (k - 1) * jump, then jump *= s.

Python Receptive field calculator

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Two stacked 3 by 3 convolutions see 5 by 5 pixels and three see 7 by 7, but use fewer weights than one big kernel (18 versus 25 for the 5 by 5 case) and add an extra non-linearity. Pooling or stride doubles the jump, so layers after it grow the receptive field faster (the fourth line reaches 10, the fifth 18). See Pooling and CNN Architectures.

12. What is transfer learning, and when would you fine-tune instead of only extracting features?

You reuse a network trained on a large dataset. With feature extraction you freeze the backbone and train only a new head; it is fast and safe when your data is small and similar to the original. With fine-tuning you also update some or all backbone weights at a small learning rate; it pays off with more data or a different domain (medical, satellite). See Transfer Learning and Modern Vision Models.

Detection and evaluation

13. What is IoU, and how does non-maximum suppression use it?

Intersection over union is the area where two regions overlap divided by the area they cover together: 1 for identical boxes, 0 for disjoint ones. A detector emits many overlapping boxes for one object. NMS sorts boxes by score, keeps the best, discards every remaining box whose IoU with it exceeds a threshold (commonly 0.5), and repeats. A threshold that is too low removes boxes of nearby distinct objects (crowds); too high leaves duplicates. See Object Detection Basics.

14. What do precision, recall and mAP mean for detection?

A detection counts as a true positive when its IoU with an unmatched ground-truth box passes a threshold such as 0.5. Precision is the fraction of detections that are correct; recall is the fraction of real objects found. Sweeping the score threshold traces a precision-recall curve; its area is the average precision (AP) of one class, and mAP averages AP over classes (and often over several IoU thresholds).

15. Why can accuracy be misleading, and what do you report instead?

With imbalanced classes, predicting the majority class already scores high. Report per-class precision and recall, the confusion matrix, and for segmentation IoU or Dice. Also slice the results: one overall number can hide a failing subgroup.

Python One number hides a weak slice

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The overall score of 0.94 looks fine, but night images reach only 0.73. If your product runs at night, you ship a broken system without noticing. See Evaluating Vision Models.

Generalization, bias and data

16. How do you recognize and reduce overfitting?

Training performance keeps improving while validation performance stalls or drops. The gap is the signal. Remedies: more data, data augmentation, a smaller model or stronger regularization (weight decay, dropout), early stopping, and cross-validation to measure honestly.

Python A growing train/test gap

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The unlimited tree memorizes the training set (train 1.000) but scores 0.843 on unseen digits, a gap of 16 points. The shallow trees underfit, with both scores low. Good models sit between the two extremes.

17. What is data leakage in vision projects?

Information from the test data influencing training. Typical cases: near-duplicate frames of one video split across train and test, several photos of the same patient or object in both sets, tuning hyperparameters on the test set, and computing normalization statistics on all data. Split by group (video, patient, scene), not by image.

18. Where does bias in a vision system come from, and what would you do about it?

From the data (unrepresentative skin tones, regions, cameras, lighting), from labels (annotator assumptions), and from deployment (a different population than the training set). Measure performance per subgroup, collect data to cover the weak slices, document the dataset and its limits, and keep monitoring after launch. See Pitfalls, Ethics and Deployment.

19. How would you debug a model that works in the lab but fails in production?

Check for distribution shift first: camera, resolution, compression, lighting, orientation, background. Compare pixel statistics and a sample of production images with the training set, confirm the preprocessing code is identical (RGB versus BGR, scaling, resize method), and collect failure cases into a labeled slice you can measure.

How to answer well

State the idea in one sentence, give a tiny example or a number, and name a limitation. "Otsu picks the cutoff that best separates two classes in the histogram; on a bimodal image it finds the valley; it fails with uneven lighting" is a complete answer. If you do not remember a detail, say how you would check it, for example "I would run the impulse test" or "I would plot the histogram".

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. You convolve an image containing a single bright pixel with an asymmetric kernel. What does the output look like?

    True convolution flips the kernel, so an impulse reproduces the kernel as written. Correlation would give the kernel rotated by 180 degrees.
  2. 2. In Canny edge detection, what does hysteresis thresholding do?

    Weak pixels are retained when they are linked to a strong edge, which produces continuous edges and discards isolated noise.
  3. 3. A network has layers (kernel, stride): (3, 1), (2, 2), (3, 1). What is the receptive field of an output unit?

    Start at 1. The first layer gives 3 (jump 1). The pooling layer gives 4 (jump 2). The last 3x3 layer adds 2 * 2 = 4, so the receptive field is 8.
  4. 4. Which statement about overfitting is correct?

    The model memorizes the training data, so the training score is high while the score on unseen data is clearly lower. Any flexible model can do this.
  5. 5. Why should you split a video dataset by video rather than by frame?

    If frames of the same video land in both train and test, the test score measures memorization of that video rather than generalization.

Summary

  • Convolution flips the kernel, correlation does not; they match for symmetric kernels, and the impulse test shows the difference.
  • Otsu maximizes between-class variance; Canny = smooth, gradient, non-maximum suppression, double threshold, hysteresis.
  • Harris finds points where both structure-tensor eigenvalues are large; scale space handles size changes; RANSAC votes out bad matches.
  • Receptive field grows by (k - 1) * jump per layer, and strides multiply the jump.
  • IoU measures overlap, NMS removes duplicate boxes, mAP averages precision over recall levels and classes.
  • Look at train/test gaps, per-slice metrics and group-wise splits to catch overfitting, hidden bias and leakage.

Next up: keep the formulas and shape rules at hand in the Computer Vision Cheat Sheet.