72 min total

Computer Vision & OpenCV

Features and template matching

Features and template matching

Feature: representation of image that contains key patterns/structures extracted from images/video

Feature creation methods:

  • Hand crafted features (HOG, SIFT)
  • Learned features (CNNs)

Types of features:

  • Global Features: computed using entire image (e.g. template matching, HOG)
  • Region-based Features: computed from localized windows (e.g. Sliding window)
  • Local Features: computed

using specific point and utilizing regions of interest (e.g. SIFT, SURF)

Uses of features:

  • Detection
  • Recognition
  • Tracking
  • Stereo estimation
  • Template matching
  • Panorama stitching
  • Structure from motion

Characteristics of Good Features:

  • Distinctiveness: each feature should be unique and distinguishable from other features
  • Repeatability: each feature should be detectable across different images under transformations (rotation, scaling, translation, lighting changes, reflectance, illumination)
  • Compactness and efficiency:

each feature should be small compared to original image

interest point: point in an image that exhibits distinct characteristics useful for detection and matching. or a point that conveys strong texture information or location where the direction of object boundary shifts suddenly.

properties of interest points:

  • points must be uniquely detectable
  • points must be well localized (accurately positioned)
  • points must be detectable in noisy images
  • point detection should be computationally cheaper

corner detection methods:

  • Brightness/intensity based method
  • boundary extraction based method (curvature analysis)

how to do corner detection: sliding a window in any direction should result in large intensity change

Template matching searches for image regions resembling a template. Rotating a template creates orientation-specific detectors; 90-degree increments give four orientations. A zero-sum filter rejects a constant brightness offset and responds to local intensity variation.

Comparing shifted or rotated neighborhoods helps distinguish a corner from a straight edge.

Corner template and its ninety-degree rotation, clean redraw

This clean redraw makes the 90° rotation explicit. The notebook illustrated the same corner-pattern comparison with colored annotations.

Corner detection by Auto correlation: corner detection approach that analyzes change in intensity when shifting a small window. Measures how similar a small patch of the image is to itself when it’s slightly shifted in different directions. In a flat or uniform region, if you shift the patch a little bit in any direction, the intensity doesn’t change much. Along an edge, a shift parallel to the edge won’t change the patch much, but a shift perpendicular to the edge will show a significant change. At a corner, shifting the patch in any direction causes a noticeable change in the pixel intensities

E measures how much image intensity changes when a window is shifted. A binary window assigns weight 1 inside the window and 0 outside. A Gaussian window gives more weight to pixels near its center.

w(x,y) labels the spatial weighting window; I(x,y) labels image intensity. A binary window is one inside the selected patch and zero outside. A Gaussian window weights central pixels more strongly; its multiplicative normalization must be handled consistently when comparing response thresholds.

A shifted image window and its matching cost
Matching costs for flat, edge, and corner regions

At a corner, the matching cost rises sharply for small shifts in every direction; it has a local minimum at zero displacement.

In the cost maps, white represents a large matching error and black represents a small matching error.

Corner detection by auto correlation is computationally expensive

For an N×N image, a naive comparison over a W×W window and S×S candidate shifts has this approximate computational cost.

Taylor series: approximates a very curvy, complex equation in a specified region using a sum of polynomial terms based on function's derivatives at those specific points. If we approximate the intensity curve of E(u, v) using taylor series we can save a lot of compute.

Quadratic approximation simplifies to

Example

Structure-tensor example

Structure-tensor arithmetic

Harris Corner Detector (1988)

Advancement over auto correlation equation.

  • We want to reduce the noise by applying gaussian smoothing and then computing image derivatives in x and y axis
  • Smooth the gradient-product maps with a Gaussian to aggregate local evidence for the structure tensor.
  • We compute Cornerness score using ~

A typical Harris response parameter k is between 0.04 and 0.06.

  • Apply thresholding to eliminate weak signals
  • Apply non-maximal suppression to remove weak corners and retain local maxima.

Properties of M

  • Flat region - eigen value of M are small
  • Corner region - both eigen value are large and positive
  • Edge region - one eigen value is large one is small