
- Scikit Image – Introduction
- Scikit Image - Image Processing
- Scikit Image - Numpy Images
- Scikit Image - Image datatypes
- Scikit Image - Using Plugins
- Scikit Image - Image Handlings
- Scikit Image - Reading Images
- Scikit Image - Writing Images
- Scikit Image - Displaying Images
- Scikit Image - Image Collections
- Scikit Image - Image Stack
- Scikit Image - Multi Image
- Scikit Image - Data Visualization
- Scikit Image - Using Matplotlib
- Scikit Image - Using Ploty
- Scikit Image - Using Mayavi
- Scikit Image - Using Napari
- Scikit Image - Color Manipulation
- Scikit Image - Alpha Channel
- Scikit Image - Conversion b/w Color & Gray Values
- Scikit Image - Conversion b/w RGB & HSV
- Scikit Image - Conversion to CIE-LAB Color Space
- Scikit Image - Conversion from CIE-LAB Color Space
- Scikit Image - Conversion to luv Color Space
- Scikit Image - Conversion from luv Color Space
- Scikit Image - Image Inversion
- Scikit Image - Painting Images with Labels
- Scikit Image - Contrast & Exposure
- Scikit Image - Contrast
- Scikit Image - Contrast enhancement
- Scikit Image - Exposure
- Scikit Image - Histogram Matching
- Scikit Image - Histogram Equalization
- Scikit Image - Local Histogram Equalization
- Scikit Image - Tinting gray-scale images
- Scikit Image - Image Transformation
- Scikit Image - Scaling an image
- Scikit Image - Rotating an Image
- Scikit Image - Warping an Image
- Scikit Image - Affine Transform
- Scikit Image - Piecewise Affine Transform
- Scikit Image - ProjectiveTransform
- Scikit Image - EuclideanTransform
- Scikit Image - Radon Transform
- Scikit Image - Line Hough Transform
- Scikit Image - Probabilistic Hough Transform
- Scikit Image - Circular Hough Transforms
- Scikit Image - Elliptical Hough Transforms
- Scikit Image - Polynomial Transform
- Scikit Image - Image Pyramids
- Scikit Image - Pyramid Gaussian Transform
- Scikit Image - Pyramid Laplacian Transform
- Scikit Image - Swirl Transform
- Scikit Image - Morphological Operations
- Scikit Image - Erosion
- Scikit Image - Dilation
- Scikit Image - Black & White Tophat Morphologies
- Scikit Image - Convex Hull
- Scikit Image - Generating footprints
- Scikit Image - Isotopic Dilation & Erosion
- Scikit Image - Isotopic Closing & Opening of an Image
- Scikit Image - Skelitonizing an Image
- Scikit Image - Morphological Thinning
- Scikit Image - Masking an image
- Scikit Image - Area Closing & Opening of an Image
- Scikit Image - Diameter Closing & Opening of an Image
- Scikit Image - Morphological reconstruction of an Image
- Scikit Image - Finding local Maxima
- Scikit Image - Finding local Minima
- Scikit Image - Removing Small Holes from an Image
- Scikit Image - Removing Small Objects from an Image
- Scikit Image - Filters
- Scikit Image - Image Filters
- Scikit Image - Median Filter
- Scikit Image - Mean Filters
- Scikit Image - Morphological gray-level Filters
- Scikit Image - Gabor Filter
- Scikit Image - Gaussian Filter
- Scikit Image - Butterworth Filter
- Scikit Image - Frangi Filter
- Scikit Image - Hessian Filter
- Scikit Image - Meijering Neuriteness Filter
- Scikit Image - Sato Filter
- Scikit Image - Sobel Filter
- Scikit Image - Farid Filter
- Scikit Image - Scharr Filter
- Scikit Image - Unsharp Mask Filter
- Scikit Image - Roberts Cross Operator
- Scikit Image - Lapalace Operator
- Scikit Image - Window Functions With Images
- Scikit Image - Thresholding
- Scikit Image - Applying Threshold
- Scikit Image - Otsu Thresholding
- Scikit Image - Local thresholding
- Scikit Image - Hysteresis Thresholding
- Scikit Image - Li thresholding
- Scikit Image - Multi-Otsu Thresholding
- Scikit Image - Niblack and Sauvola Thresholding
- Scikit Image - Restoring Images
- Scikit Image - Rolling-ball Algorithm
- Scikit Image - Denoising an Image
- Scikit Image - Wavelet Denoising
- Scikit Image - Non-local means denoising for preserving textures
- Scikit Image - Calibrating Denoisers Using J-Invariance
- Scikit Image - Total Variation Denoising
- Scikit Image - Shift-invariant wavelet denoising
- Scikit Image - Image Deconvolution
- Scikit Image - Richardson-Lucy Deconvolution
- Scikit Image - Recover the original from a wrapped phase image
- Scikit Image - Image Inpainting
- Scikit Image - Registering Images
- Scikit Image - Image Registration
- Scikit Image - Masked Normalized Cross-Correlation
- Scikit Image - Registration using optical flow
- Scikit Image - Assemble images with simple image stitching
- Scikit Image - Registration using Polar and Log-Polar
- Scikit Image - Feature Detection
- Scikit Image - Dense DAISY Feature Description
- Scikit Image - Histogram of Oriented Gradients
- Scikit Image - Template Matching
- Scikit Image - CENSURE Feature Detector
- Scikit Image - BRIEF Binary Descriptor
- Scikit Image - SIFT Feature Detector and Descriptor Extractor
- Scikit Image - GLCM Texture Features
- Scikit Image - Shape Index
- Scikit Image - Sliding Window Histogram
- Scikit Image - Finding Contour
- Scikit Image - Texture Classification Using Local Binary Pattern
- Scikit Image - Texture Classification Using Multi-Block Local Binary Pattern
- Scikit Image - Active Contour Model
- Scikit Image - Canny Edge Detection
- Scikit Image - Marching Cubes
- Scikit Image - Foerstner Corner Detection
- Scikit Image - Harris Corner Detection
- Scikit Image - Extracting FAST Corners
- Scikit Image - Shi-Tomasi Corner Detection
- Scikit Image - Haar Like Feature Detection
- Scikit Image - Haar Feature detection of coordinates
- Scikit Image - Hessian matrix
- Scikit Image - ORB feature Detection
- Scikit Image - Additional Concepts
- Scikit Image - Render text onto an image
- Scikit Image - Face detection using a cascade classifier
- Scikit Image - Face classification using Haar-like feature descriptor
- Scikit Image - Visual image comparison
- Scikit Image - Exploring Region Properties With Pandas
Face Detection using a Cascade Classifier
Face detection is the process of identifying faces in an image or video frame. It is a fundamental task in computer vision and it has many applications like face recognition, facial expression analysis, and many more.
One of the most popular methods for face detection is the Cascade Classifier, which was introduced by Viola, P. and Jones, M in 2001. The Cascade Classifier is a machine learning algorithm that uses Haar-like features to detect faces in an image.
Scikit-image provides a versatile method for detecting faces in images using the "Cascade" class. This class is part of the "feature" submodule within the scikit-image library.
Using the skimage.feature.Cascade()
The skimage.feature.Cascade() class is designed for creating cascades of classifiers that are used in object detection. Which is inherited from the "object" class.
The fundamental concept behind a cascade of classifiers is to build multiple classifiers of medium accuracy and then ensemble them to form a single strong classifier. This approach offers several advantages. One of the key benefits is that easy examples can be classified by evaluating only a subset of the classifiers within the cascade. This makes the detection process much faster compared to evaluating one strong classifier for every instance.
It is important to note that, in this implementation, the concept of the cascade approach employed the multi-scale block local binary pattern (MB-LBP) features, instead of using the set of Haar-like features.
Syntax
The following is the syntax of this class −
skimage.feature.Cascade()
The below example demonstrates the process of face detection within an image using an object detection framework based on machine learning.
To begin the detection process, an XML file is required to access the pre-trained data. The framework is designed to work with files that have been trained using Multi-block Local Binary Patterns Features (referred to as MB-LBP) and Gentle Adaboost with an attentional cascade. So, the detection framework will also work with xml files from OpenCV. which contain pre-trained models for various objects, including cat faces and profile faces. If your goal is to detect frontal faces, the corresponding file is already included in the scikit-image library.
The next step involves specifying parameters for the "detect_multi_scale" function. Each parameter has a specific meaning −
scale_ratio: This parameter is responsible for multi-scale search for faces by adjusting the size of the search window. The smallest window size corresponds to the training window size specified in the XML file. This parameter determines the increment ratio for the search window size at each step. Increasing this parameter reduces search time but may affect accuracy, potentially leading to some faces not being detected.
step_ratio: This parameter defines the step of the sliding window used for face detection at various image scales. If set to one, it searches all possible locations. A value greater than one (e.g., two) means the window is moved by a specific number of pixels, reducing the number of locations searched. Increasing this parameter can speed up the algorithm but may impact accuracy.
Min_size and max_size: These parameters specify the minimum and maximum size of the search window during the scale search. If you know the expected size of faces in the images you're working with, you should specify these parameters as precisely as possible, because it can reduce computational time and minimize false detections. Increasing the "min_size" parameter can notably speed up processing because the majority of time is spent searching at the smallest scales.
min_neighbor_number and intersection_score_threshold: These parameters are used to cluster excessive detections of the same face and filter out false detections. True faces often have a lot of detections around them, while false detections typically result in only a single detection.
The algorithm first identifies clusters, where two rectangle detections are placed in the same cluster if their intersection score between them is larger than the intersection_score_threshold. The intersection score is calculated as the intersection area divided by the smaller rectangle's ratio. This approach was chosen over the intersection over union method to handle a corner case where a small rectangle within a larger one has a small intersection score. Then, each cluster is filtered using the "min_neighbor_number" parameter, which retains clusters with an equal or greater number of detections.
It's important to remember that some false detections are inevitable. To create a highly precise detector, you may need to undertake the training process yourself using OpenCV's train cascade utility.
Example
The following example performs face detection using a cascade classifier and displaying the detected faces in an image.
import matplotlib.pyplot as plt from matplotlib import patches from skimage import data, io from skimage.feature import Cascade # Load the pre-trained face cascade classifier. trained_cascade = data.lbp_frontal_face_cascade_filename() # Initialize the face detector. face_detector = Cascade(trained_cascade) # Load an image containing faces. image = io.imread('Images/facedetection_input.jpg') # Detect faces in the image with multiple scales and settings. detected_faces = face_detector.detect_multi_scale(img=image, scale_factor=1.2, step_ratio=1, min_size=(60, 60), max_size=(123, 123)) # Display the original image. plt.imshow(image, cmap='gray') image_description = plt.gca() # Draw rectangles around detected faces. for face in detected_faces: image_description.add_patch( patches.Rectangle( (face['c'], face['r']), face['width'], face['height'], fill=False, color='r', linewidth=2 ) ) plt.show()
Output
On executing the above program, you will get the following output −
