This document provides a deeper look into the algorithms implemented in the ComputerVisionLab project.
- Face Detection (Haar Cascades)
- Canny Edge Detection
- Image Segmentation (Watershed)
- ORB Keypoint Detection
- Contour Analysis (Coin Counting)
- Image Thresholding
Face detection is implemented using the Haar Feature-based Cascade Classifiers. It is a machine learning based approach where a cascade function is trained from a lot of positive and negative images.
- Classifier:
haarcascade_frontalface_default.xml - Logic:
detector = cv2.CascadeClassifier(FACE_DETECTOR_PATH) rects = detector.detectMultiScale( image, scaleFactor=1.1, minNeighbors=5, minSize=(30, 30), flags=cv2.CASCADE_SCALE_IMAGE )
The Canny edge detector is an edge detection operator that uses a multi-stage algorithm to detect a wide range of edges in images.
- Noise Reduction: Apply Gaussian filter to smooth the image.
- Finding Intensity Gradient: Find the intensity gradients of the image.
- Non-maximum Suppression: Get rid of spurious response to edge detection.
- Hysteresis Thresholding: Final step to decide which are all edges are actually edges and which are not.
The Watershed algorithm is a classic algorithm used for segmentation, especially when you have touching objects in an image.
- Thresholding: Find approximate foreground and background.
- Distance Transform: Calculate the distance from each foreground pixel to the nearest background pixel.
- Marker Creation: Use the peaks of the distance transform as markers for the objects.
- Watershed: "Fill" the markers with color until they meet at the boundaries.
ORB (Oriented FAST and Rotated BRIEF) is a fast robust local feature detector, first presented by Ethan Rublee et al. in 2011. It is based on the FAST keypoint detector and a modified version of the visual descriptor BRIEF (Binary Robust Independent Elementary Features).
- It is a great alternative to SIFT and SURF.
- It is computationally efficient and free from patent restrictions.
Contours can be explained simply as a curve joining all the continuous points (along the boundary), having same color or intensity.
- Grayscale conversion.
- Gaussian Blur to reduce noise.
- Canny edge detection.
cv2.findContours()to extract object boundaries.
Thresholding is the simplest method of image segmentation. From a grayscale image, thresholding can be used to create binary images.
- Global Thresholding: A fixed value is used as a threshold.
- Adaptive Mean Thresholding: The threshold value is the mean of the neighborhood area.
- Adaptive Gaussian Thresholding: The threshold value is the weighted sum of neighborhood values where weights are a Gaussian window.