Back to Course
CMSC 178IP

Module 07: Feature Extraction

1 / --

Feature Extraction

CMSC 178IP - Module 07

Noel Jeffrey Pinton
Department of Computer Science
University of the Philippines Cebu

Feature Extraction

CMSC 178IP - Module 07

Noel Jeffrey Pinton
Department of Computer Science
University of the Philippines Cebu

Learning Objectives

By the end of this module, you will be able to:

  1. Detect edges using gradient-based methods
  2. Find corners and interest points
  3. Apply the Hough transform for line/circle detection
  4. Understand feature descriptors (SIFT, ORB)
  5. Perform feature matching between images

Edge Detection

Finding boundaries in images

Gradient Operators

Gradient Operators
Sobel
[[-1,0,1],
 [-2,0,2],
 [-1,0,1]]
Prewitt
[[-1,0,1],
 [-1,0,1],
 [-1,0,1]]

Edge Detection Comparison

Edge Detection Comparison

Sobel, Prewitt, Roberts, and Canny edge detectors

Canny Edge Detector

Canny Edge Detection - The "optimal" edge detector:

  1. Gaussian smoothing - Reduce noise
  2. Gradient computation - Find edge strength and direction
  3. Non-maximum suppression - Thin edges to 1 pixel
  4. Hysteresis thresholding - Connect strong and weak edges
Produces thin, well-connected edges with good noise rejection.

Knowledge Check

Think About It

What is the purpose of non-maximum suppression in Canny edge detection?

Click the blurred area to reveal the answer

Corner Detection

Interest points for matching

Harris Corner Detection

Corner Detection

Harris Corner Response:

$$R = \det(M) - k \cdot \text{trace}(M)^2$$

where M is the structure tensor. R > 0 indicates a corner.

What Makes a Good Feature?

Good features are:

  • Repeatable - Found in both images
  • Distinctive - Unique in neighborhood
  • Localized - Precise position
  • Efficient - Fast to compute
Flat Region
No change in any direction
❌ Bad feature
Corner
Change in all directions
✓ Good feature

Hough Transform

Detecting lines and shapes

Hough Transform

Hough Transform

Hough Transform: Convert from image space to parameter space.

$$\rho = x \cos\theta + y \sin\theta$$

Each edge point votes for all lines passing through it. Peaks indicate detected lines.

Knowledge Check

Think About It

How does the Hough transform detect lines even with gaps or noise?

Click the blurred area to reveal the answer

Feature Descriptors

Describing local image regions

SIFT Features

SIFT Features

SIFT (Scale-Invariant Feature Transform):

  • Scale-space extrema detection
  • Keypoint localization
  • Orientation assignment
  • 128-dimensional descriptor

Robust to scale, rotation, and illumination changes.

ORB Features

ORB Features
ORB (Oriented FAST and Rotated BRIEF):
  • Fast keypoint detection (FAST)
  • Binary descriptor (BRIEF)
  • Rotation invariant
  • Free alternative to SIFT
  • Much faster than SIFT

HOG Features

HOG Features

HOG (Histogram of Oriented Gradients):

Captures edge direction distribution in cells. Excellent for pedestrian detection and object recognition.

Texture Features

Texture Analysis

LBP and other texture descriptors capture local patterns

Advanced LBP

Advanced LBP
Local Binary Patterns: Compare center pixel to neighbors, encode as binary number. Fast, robust texture descriptor.

Feature Matching

Finding correspondences between images

Feature Matching

Feature Matching
Matching strategies:
  • Brute-force: Compare all pairs
  • FLANN: Fast approximate matching
  • Ratio test: Reject ambiguous matches

Knowledge Check

Think About It

What is Lowe's ratio test and why is it effective?

Click the blurred area to reveal the answer

Line Feature Matching

Line Matching

Matched features showing correspondence between two views

Bag of Features

Bag of Features

Bag of Visual Words:

  1. Extract features from training images
  2. Cluster into visual vocabulary
  3. Represent images as histograms of visual words
  4. Use for image classification/retrieval

Applications

Real-world feature extraction applications

Medical Imaging

Medical Imaging

Feature extraction for tumor detection and tissue analysis

Document Analysis

Document Analysis

OCR preprocessing and layout analysis using edge and corner detection

Biometric Analysis

Biometrics

Fingerprint and face feature extraction for identification

Industrial Inspection

Industrial Inspection

Defect detection in manufacturing using feature analysis

Autonomous Vehicles

Autonomous Vehicles

Lane detection, obstacle recognition, and scene understanding

Implementation

import cv2
import numpy as np

img = cv2.imread('image.jpg', 0)

# Canny edge detection
edges = cv2.Canny(img, 100, 200)

# Harris corners
corners = cv2.cornerHarris(img, 2, 3, 0.04)

# ORB features
orb = cv2.ORB_create()
keypoints, descriptors = orb.detectAndCompute(img, None)

# Feature matching
bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)
matches = bf.match(desc1, desc2)

Summary

Key Takeaways

Key Takeaways

  1. Edge detection: Sobel, Canny - find boundaries
  2. Corner detection: Harris - find interest points
  3. Hough transform: Detect lines and shapes in parameter space
  4. SIFT/ORB: Scale and rotation invariant descriptors
  5. HOG/LBP: Gradient and texture features
  6. Feature matching: Brute-force, FLANN, ratio test

Questions?

Thank you for your attention!


Next: Module 08 - Segmentation and Morphology

End of Module 07

Feature Extraction

Questions?