
- 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
Scikit Image - Harris Corner Detection
The Harris corner detection is a widely used corner detection operator in computer vision. It was developed by Chris Harris and Mike Stephens in 1988 as an improvement over Moravec's corner detector. The Harris corner detector considers the differential of the corner score concerning direction directly, instead of employing shifting patches for various 45-degree angles. This approach leads to improved accuracy in distinguishing between edges and corners.
This detector has been subsequently enhanced and integrated into various computer vision applications to preprocess images for further processing, making it a valuable tool for feature extraction and image analysis.
The scikit image library offers the corner_harris function within its feature module, allowing users to apply the Harris corner detector to images.
Using the skimage.feature.corner_harris() function
The corner_harris() function is used to compute a Harris corner measure response image.
This corner detector uses information from the auto-correlation matrix A, which is computed as follows −
$$\mathrm{A= \begin{matrix} [(imx^{\ast \ast}2)(imx^{\ast}imy)] = [Axx \: Axy] \\ [(imx^{\ast}imy)(imy{\ast \ast}2)] [Axy \: Ayy] \end{matrix}}$$
Where imx and imy are the first derivatives of the image, typically averaged with a Gaussian filter. This matrix A characterizes the local image structure.
$$\mathrm{det(A)-k^{\ast} trace(A)^{\ast \ast} 2}$$
Or
$$\mathrm{2^{\ast}det(A)/(trace(A)+eps)}$$
Syntax
Following is the syntax of the function −
skimage.feature.corner_harris(image, method='k', k=0.05, eps=1e-06, sigma=1)
image (M, N) ndarray: The input image on which the Harris corner detection is performed.
method (optional): Specifies the method used to compute the response image from the auto-correlation matrix. The available options are: 'k' or 'eps'.
k (optional): A float representing the sensitivity factor to separate corners from edges, typically in range [0, 0.2]. Small values of k result in detection of sharp corners. (used if method is 'k').
eps (optional): A float representing the normalization factor (Noble's corner measure).
sigma (optional): The standard deviation used for the Gaussian kernel, which serves as a weighting function for the auto-correlation matrix.
The function returns a response ndarray, which is the Harris response image.
Example
The following example demonstrates how to use the Harris corner detector to identify corner-like features in a simple binary image and then detect and display the coordinates of these corners using the corner_peaks function.
import numpy as np from skimage.feature import corner_harris, corner_peaks # Create a 10x10 image with a square-shaped region square = np.zeros([10, 10]) square[2:8, 2:8] = 1 # Convert the image to integers square = square.astype(int) # Compute the Harris corner response corner_response = corner_harris(square) # Find and mark the corner peaks with a minimum distance of 1 pixel corners = corner_peaks(corner_response, min_distance=1) # Display the input and output arrays print("The Original array:", square) print('The corner points on the response array:', corners)
Output
The Original array: [[0 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0 0] [0 0 1 1 1 1 1 1 0 0] [0 0 1 1 1 1 1 1 0 0] [0 0 1 1 1 1 1 1 0 0] [0 0 1 1 1 1 1 1 0 0] [0 0 1 1 1 1 1 1 0 0] [0 0 1 1 1 1 1 1 0 0] [0 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0 0]] The corner points on the response array: [[2 2] [2 7] [7 2] [7 7]]
Example
Here's an example that demonstrates the application of the Harris corner detection algorithm (corner_harris) to identify corner-like features within a transformed image.
# Import necessary libraries and modules from matplotlib import pyplot as plt from skimage import data from skimage.feature import corner_harris, corner_subpix, corner_peaks from skimage.transform import warp, AffineTransform from skimage.draw import ellipse # Define a sheared checkerboard pattern by applying a transformation tform = AffineTransform(scale=(1.3, 1.1), rotation=1, shear=0.7, translation=(110, 30)) image = warp(data.checkerboard()[:90, :90], tform.inverse, output_shape=(200, 310)) # Add an elliptical shape to the transformed image rr, cc = ellipse(160, 175, 10, 100) image[rr, cc] = 1 # Add two square shapes to the image image[30:80, 200:250] = 1 image[80:130, 250:300] = 1 # Detect corner coordinates using the Harris corner detector with specified parameters coords = corner_peaks(corner_harris(image), min_distance=5, threshold_rel=0.02) # Refine corner coordinates for subpixel accuracy within a window coords_subpix = corner_subpix(image, coords, window_size=13) # Create a plot to visualize the transformed image and detected corners fig, ax = plt.subplots(figsize=(10,10)) ax.imshow(image, cmap=plt.cm.gray) ax.set_title('Output corners detected image:') # Plot the detected corner coordinates in cyan as circles ax.plot(coords[:, 1], coords[:, 0], color='cyan', marker='o', linestyle='None', markersize=6) # Plot the refined corner coordinates in red ax.plot(coords_subpix[:, 1], coords_subpix[:, 0], '+r', markersize=15) ax.axis((0, 310, 200, 0)) plt.show()
Output
