Noel Jeffrey Pinton
Department of Computer Science
University of the Philippines Cebu
Noel Jeffrey Pinton
Department of Computer Science
University of the Philippines Cebu
By the end of this module, you will be able to:
Finding boundaries in images
[[-1,0,1],
[-2,0,2],
[-1,0,1]][[-1,0,1],
[-1,0,1],
[-1,0,1]]Sobel, Prewitt, Roberts, and Canny edge detectors
Canny Edge Detection - The "optimal" edge detector:
What is the purpose of non-maximum suppression in Canny edge detection?
Non-maximum suppression thins the edges to 1 pixel wide by keeping only the local maxima along the gradient direction, removing pixels that are not at the peak of the edge response.
Click the blurred area to reveal the answer
Interest points for matching
Harris Corner Response:
$$R = \det(M) - k \cdot \text{trace}(M)^2$$
where M is the structure tensor. R > 0 indicates a corner.
Good features are:
Detecting lines and shapes
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.
How does the Hough transform detect lines even with gaps or noise?
Each edge point independently votes in parameter space. Even if the line is broken by gaps or noise, enough points along the line will vote for the same (ρ, θ) parameters, creating a peak that can be detected.
Click the blurred area to reveal the answer
Describing local image regions
SIFT (Scale-Invariant Feature Transform):
Robust to scale, rotation, and illumination changes.
HOG (Histogram of Oriented Gradients):
Captures edge direction distribution in cells. Excellent for pedestrian detection and object recognition.
LBP and other texture descriptors capture local patterns
Finding correspondences between images
What is Lowe's ratio test and why is it effective?
The ratio test compares the distance to the best match vs the second-best match. If the ratio is below a threshold (e.g., 0.75), the match is accepted. This rejects ambiguous matches where multiple features look similar.
Click the blurred area to reveal the answer
Matched features showing correspondence between two views
Bag of Visual Words:
Real-world feature extraction applications
Feature extraction for tumor detection and tissue analysis
OCR preprocessing and layout analysis using edge and corner detection
Fingerprint and face feature extraction for identification
Defect detection in manufacturing using feature analysis
Lane detection, obstacle recognition, and scene understanding
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)
Key Takeaways
Thank you for your attention!
Next: Module 08 - Segmentation and Morphology
Questions?