feature
¶

Edge filter an image using the Canny algorithm. 

Extract DAISY feature descriptors densely for the given image. 

Extract Histogram of Oriented Gradients (HOG) for a given image. 

Calculate the greylevel cooccurrence matrix. 

Calculate texture properties of a GLCM. 

Gray scale and rotation invariant LBP (Local Binary Patterns). 

Multiblock local binary pattern (MBLBP). 

Multiblock local binary pattern visualization. 

Find peaks in an image as coordinate list or boolean mask. 

Compute structure tensor using sum of squared differences. 
Compute Eigen values of structure tensor. 


Compute Hessian matrix. 

Compute the approximate Hessian Determinant over an image. 
Compute Eigenvalues of Hessian matrix. 


Compute the shape index. 
Compute Kitchen and Rosenfeld corner measure response image. 


Compute Harris corner measure response image. 

Compute ShiTomasi (KanadeTomasi) corner measure response image. 

Compute Foerstner corner measure response image. 

Determine subpixel position of corners. 

Find corners in corner measure response image. 

Compute Moravec corner measure response image. 

Extract FAST corners for a given image. 

Compute the orientation of corners. 

Match a template to a 2D or 3D image using normalized correlation. 
Efficient subpixel image translation registration by crosscorrelation. 

Masked image translation registration by masked normalized crosscorrelation. 

Bruteforce matching of descriptors. 


Plot matched features. 

Finds blobs in the given grayscale image. 

Finds blobs in the given grayscale image. 

Finds blobs in the given grayscale image. 

Compute the Haarlike features for a region of interest (ROI) of an integral image. 
Compute the coordinates of Haarlike features. 

Visualization of Haarlike features. 

Class for cascade of classifiers that is used for object detection. 


BRIEF binary descriptor extractor. 

CENSURE keypoint detector. 

Oriented FAST and rotated BRIEF feature detector and binary descriptor extractor. 
skimage.feature.
canny
(image, sigma=1.0, low_threshold=None, high_threshold=None, mask=None, use_quantiles=False)[source]¶Edge filter an image using the Canny algorithm.
Grayscale input image to detect edges on; can be of any dtype.
Standard deviation of the Gaussian filter.
Lower bound for hysteresis thresholding (linking edges). If None, low_threshold is set to 10% of dtype’s max.
Upper bound for hysteresis thresholding (linking edges). If None, high_threshold is set to 20% of dtype’s max.
Mask to limit the application of Canny to a certain area.
If True then treat low_threshold and high_threshold as quantiles of the edge magnitude image, rather than absolute edge magnitude values. If True then the thresholds must be in the range [0, 1].
The binary edge map.
See also
skimage.sobel
Notes
The steps of the algorithm are as follows:
Smooth the image using a Gaussian with sigma
width.
Apply the horizontal and vertical Sobel operators to get the gradients within the image. The edge strength is the norm of the gradient.
Thin potential edges to 1pixel wide curves. First, find the normal to the edge at each point. This is done by looking at the signs and the relative magnitude of the XSobel and YSobel to sort the points into 4 categories: horizontal, vertical, diagonal and antidiagonal. Then look in the normal and reverse directions to see if the values in either of those directions are greater than the point in question. Use interpolation to get a mix of points instead of picking the one that’s the closest to the normal.
Perform a hysteresis thresholding: first label all points above the high threshold as edges. Then recursively label any point above the low threshold that is 8connected to a labeled point as an edge.
References
Canny, J., A Computational Approach To Edge Detection, IEEE Trans. Pattern Analysis and Machine Intelligence, 8:679714, 1986
William Green’s Canny tutorial http://dasl.unlv.edu/daslDrexel/alumni/bGreen/www.pages.drexel.edu/_weg22/can_tut.html
Examples
>>> from skimage import feature
>>> # Generate noisy image of a square
>>> im = np.zeros((256, 256))
>>> im[64:64, 64:64] = 1
>>> im += 0.2 * np.random.rand(*im.shape)
>>> # First trial with the Canny filter, with the default smoothing
>>> edges1 = feature.canny(im)
>>> # Increase the smoothing for better results
>>> edges2 = feature.canny(im, sigma=3)
skimage.feature.
daisy
(image, step=4, radius=15, rings=3, histograms=8, orientations=8, normalization='l1', sigmas=None, ring_radii=None, visualize=False)[source]¶Extract DAISY feature descriptors densely for the given image.
DAISY is a feature descriptor similar to SIFT formulated in a way that allows for fast dense extraction. Typically, this is practical for bagoffeatures image representations.
The implementation follows Tola et al. [1] but deviate on the following points:
Histogram bin contribution are smoothed with a circular Gaussian window over the tonal range (the angular range).
The sigma values of the spatial Gaussian smoothing in this code do not match the sigma values in the original code by Tola et al. [2]. In their code, spatial smoothing is applied to both the input image and the center histogram. However, this smoothing is not documented in [1] and, therefore, it is omitted.
Input image (grayscale).
Distance between descriptor sampling points.
Radius (in pixels) of the outermost ring.
Number of rings.
Number of histograms sampled per ring.
Number of orientations (bins) per histogram.
How to normalize the descriptors
‘l1’: L1normalization of each descriptor.
‘l2’: L2normalization of each descriptor.
‘daisy’: L2normalization of individual histograms.
‘off’: Disable normalization.
Standard deviation of spatial Gaussian smoothing for the center histogram and for each ring of histograms. The array of sigmas should be sorted from the center and out. I.e. the first sigma value defines the spatial smoothing of the center histogram and the last sigma value defines the spatial smoothing of the outermost ring. Specifying sigmas overrides the following parameter.
rings = len(sigmas)  1
Radius (in pixels) for each ring. Specifying ring_radii overrides the following two parameters.
rings = len(ring_radii)
radius = ring_radii[1]
If both sigmas and ring_radii are given, they must satisfy the following predicate since no radius is needed for the center histogram.
len(ring_radii) == len(sigmas) + 1
Generate a visualization of the DAISY descriptors
Grid of DAISY descriptors for the given image as an array dimensionality (P, Q, R) where
P = ceil((M  radius*2) / step)
Q = ceil((N  radius*2) / step)
R = (rings * histograms + 1) * orientations
Visualization of the DAISY descriptors.
References
skimage.feature.daisy
¶skimage.feature.
hog
(image, orientations=9, pixels_per_cell=(8, 8), cells_per_block=(3, 3), block_norm='L2Hys', visualize=False, transform_sqrt=False, feature_vector=True, multichannel=None)[source]¶Extract Histogram of Oriented Gradients (HOG) for a given image.
Compute a Histogram of Oriented Gradients (HOG) by
(optional) global image normalization
computing the gradient image in row and col
computing gradient histograms
normalizing across blocks
flattening into a feature vector
Input image.
Number of orientation bins.
Size (in pixels) of a cell.
Number of cells in each block.
Block normalization method:
L1
Normalization using L1norm.
L1sqrt
Normalization using L1norm, followed by square root.
L2
Normalization using L2norm.
L2Hys
Normalization using L2norm, followed by limiting the maximum values to 0.2 (Hys stands for hysteresis) and renormalization using L2norm. (default) For details, see [3], [4].
Also return an image of the HOG. For each cell and orientation bin, the image contains a line segment that is centered at the cell center, is perpendicular to the midpoint of the range of angles spanned by the orientation bin, and has intensity proportional to the corresponding histogram value.
Apply power law compression to normalize the image before processing. DO NOT use this if the image contains negative values. Also see notes section below.
Return the data as a feature vector by calling .ravel() on the result just before returning.
If True, the last image dimension is considered as a color channel, otherwise as spatial.
HOG descriptor for the image. If feature_vector is True, a 1D (flattened) array is returned.
A visualisation of the HOG image. Only provided if visualize is True.
Notes
The presented code implements the HOG extraction method from [2] with the following changes: (I) blocks of (3, 3) cells are used ((2, 2) in the paper; (II) no smoothing within cells (Gaussian spatial window with sigma=8pix in the paper); (III) L1 block normalization is used (L2Hys in the paper).
Power law compression, also known as Gamma correction, is used to reduce
the effects of shadowing and illumination variations. The compression makes
the dark regions lighter. When the kwarg transform_sqrt is set to
True
, the function computes the square root of each color channel
and then applies the hog algorithm to the image.
References
https://en.wikipedia.org/wiki/Histogram_of_oriented_gradients
Dalal, N and Triggs, B, Histograms of Oriented Gradients for Human Detection, IEEE Computer Society Conference on Computer Vision and Pattern Recognition 2005 San Diego, CA, USA, https://lear.inrialpes.fr/people/triggs/pubs/Dalalcvpr05.pdf, DOI:10.1109/CVPR.2005.177
Lowe, D.G., Distinctive image features from scaleinvatiant keypoints, International Journal of Computer Vision (2004) 60: 91, http://www.cs.ubc.ca/~lowe/papers/ijcv04.pdf, DOI:10.1023/B:VISI.0000029664.99615.94
Dalal, N, Finding People in Images and Videos, HumanComputer Interaction [cs.HC], Institut National Polytechnique de Grenoble  INPG, 2006, https://tel.archivesouvertes.fr/tel00390303/file/NavneetDalalThesis.pdf
skimage.feature.hog
¶skimage.feature.
greycomatrix
(image, distances, angles, levels=None, symmetric=False, normed=False)[source]¶Calculate the greylevel cooccurrence matrix.
A grey level cooccurrence matrix is a histogram of cooccurring greyscale values at a given offset over an image.
Integer typed input image. Only positive valued images are supported. If type is other than uint8, the argument levels needs to be set.
List of pixel pair distance offsets.
List of pixel pair angles in radians.
The input image should contain integers in [0, levels1], where levels indicate the number of greylevels counted (typically 256 for an 8bit image). This argument is required for 16bit images or higher and is typically the maximum of the image. As the output matrix is at least levels x levels, it might be preferable to use binning of the input image rather than large values for levels.
If True, the output matrix P[:, :, d, theta] is symmetric. This is accomplished by ignoring the order of value pairs, so both (i, j) and (j, i) are accumulated when (i, j) is encountered for a given offset. The default is False.
If True, normalize each matrix P[:, :, d, theta] by dividing by the total number of accumulated cooccurrences for the given offset. The elements of the resulting matrix sum to 1. The default is False.
The greylevel cooccurrence histogram. The value P[i,j,d,theta] is the number of times that greylevel j occurs at a distance d and at an angle theta from greylevel i. If normed is False, the output is of type uint32, otherwise it is float64. The dimensions are: levels x levels x number of distances x number of angles.
References
The GLCM Tutorial Home Page, http://www.fp.ucalgary.ca/mhallbey/tutorial.htm
Pattern Recognition Engineering, Morton Nadler & Eric P. Smith
Wikipedia, https://en.wikipedia.org/wiki/Cooccurrence_matrix
Examples
Compute 2 GLCMs: One for a 1pixel offset to the right, and one for a 1pixel offset upwards.
>>> image = np.array([[0, 0, 1, 1],
... [0, 0, 1, 1],
... [0, 2, 2, 2],
... [2, 2, 3, 3]], dtype=np.uint8)
>>> result = greycomatrix(image, [1], [0, np.pi/4, np.pi/2, 3*np.pi/4],
... levels=4)
>>> result[:, :, 0, 0]
array([[2, 2, 1, 0],
[0, 2, 0, 0],
[0, 0, 3, 1],
[0, 0, 0, 1]], dtype=uint32)
>>> result[:, :, 0, 1]
array([[1, 1, 3, 0],
[0, 1, 1, 0],
[0, 0, 0, 2],
[0, 0, 0, 0]], dtype=uint32)
>>> result[:, :, 0, 2]
array([[3, 0, 2, 0],
[0, 2, 2, 0],
[0, 0, 1, 2],
[0, 0, 0, 0]], dtype=uint32)
>>> result[:, :, 0, 3]
array([[2, 0, 0, 0],
[1, 1, 2, 0],
[0, 0, 2, 1],
[0, 0, 0, 0]], dtype=uint32)
skimage.feature.greycomatrix
¶skimage.feature.
greycoprops
(P, prop='contrast')[source]¶Calculate texture properties of a GLCM.
Compute a feature of a grey level cooccurrence matrix to serve as a compact summary of the matrix. The properties are computed as follows:
‘contrast’: \(\sum_{i,j=0}^{levels1} P_{i,j}(ij)^2\)
‘dissimilarity’: \(\sum_{i,j=0}^{levels1}P_{i,j}ij\)
‘homogeneity’: \(\sum_{i,j=0}^{levels1}\frac{P_{i,j}}{1+(ij)^2}\)
‘ASM’: \(\sum_{i,j=0}^{levels1} P_{i,j}^2\)
‘energy’: \(\sqrt{ASM}\)
Each GLCM is normalized to have a sum of 1 before the computation of texture properties.
Input array. P is the greylevel cooccurrence histogram for which to compute the specified property. The value P[i,j,d,theta] is the number of times that greylevel j occurs at a distance d and at an angle theta from greylevel i.
The property of the GLCM to compute. The default is ‘contrast’.
2dimensional array. results[d, a] is the property ‘prop’ for the d’th distance and the a’th angle.
References
The GLCM Tutorial Home Page, http://www.fp.ucalgary.ca/mhallbey/tutorial.htm
Examples
Compute the contrast for GLCMs with distances [1, 2] and angles [0 degrees, 90 degrees]
>>> image = np.array([[0, 0, 1, 1],
... [0, 0, 1, 1],
... [0, 2, 2, 2],
... [2, 2, 3, 3]], dtype=np.uint8)
>>> g = greycomatrix(image, [1, 2], [0, np.pi/2], levels=4,
... normed=True, symmetric=True)
>>> contrast = greycoprops(g, 'contrast')
>>> contrast
array([[ 0.58333333, 1. ],
[ 1.25 , 2.75 ]])
skimage.feature.greycoprops
¶skimage.feature.
local_binary_pattern
(image, P, R, method='default')[source]¶Gray scale and rotation invariant LBP (Local Binary Patterns).
LBP is an invariant descriptor that can be used for texture classification.
Graylevel image.
Number of circularly symmetric neighbour set points (quantization of the angular space).
Radius of circle (spatial resolution of the operator).
Method to determine the pattern.
rotation invariant.
rotation invariant.
finer quantization of the angular space which is gray scale and rotation invariant.
which is only gray scale invariant [2].
image texture which is rotation but not gray scale invariant.
LBP image.
References
Multiresolution GrayScale and Rotation Invariant Texture Classification with Local Binary Patterns. Timo Ojala, Matti Pietikainen, Topi Maenpaa. http://www.ee.oulu.fi/research/mvmp/mvg/files/pdf/pdf_94.pdf, 2002.
Face recognition with local binary patterns. Timo Ahonen, Abdenour Hadid, Matti Pietikainen, http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.214.6851, 2004.
skimage.feature.local_binary_pattern
¶skimage.feature.
multiblock_lbp
(int_image, r, c, width, height)[source]¶Multiblock local binary pattern (MBLBP).
The features are calculated similarly to local binary patterns (LBPs),
(See local_binary_pattern()
) except that summed blocks are
used instead of individual pixel values.
MBLBP is an extension of LBP that can be computed on multiple scales in constant time using the integral image. Nine equallysized rectangles are used to compute a feature. For each rectangle, the sum of the pixel intensities is computed. Comparisons of these sums to that of the central rectangle determine the feature, similarly to LBP.
Integral image.
Rowcoordinate of top left corner of a rectangle containing feature.
Columncoordinate of top left corner of a rectangle containing feature.
Width of one of the 9 equal rectangles that will be used to compute a feature.
Height of one of the 9 equal rectangles that will be used to compute a feature.
8bit MBLBP feature descriptor.
References
Face Detection Based on MultiBlock LBP Representation. Lun Zhang, Rufeng Chu, Shiming Xiang, Shengcai Liao, Stan Z. Li http://www.cbsr.ia.ac.cn/users/scliao/papers/ZhangICB07MBLBP.pdf
skimage.feature.multiblock_lbp
¶skimage.feature.
draw_multiblock_lbp
(image, r, c, width, height, lbp_code=0, color_greater_block=(1, 1, 1), color_less_block=(0, 0.69, 0.96), alpha=0.5)[source]¶Multiblock local binary pattern visualization.
Blocks with higher sums are colored with alphablended white rectangles, whereas blocks with lower sums are colored alphablended cyan. Colors and the alpha parameter can be changed.
Image on which to visualize the pattern.
Rowcoordinate of top left corner of a rectangle containing feature.
Columncoordinate of top left corner of a rectangle containing feature.
Width of one of 9 equal rectangles that will be used to compute a feature.
Height of one of 9 equal rectangles that will be used to compute a feature.
The descriptor of feature to visualize. If not provided, the descriptor with 0 value will be used.
Floats specifying the color for the block that has greater intensity value. They should be in the range [0, 1]. Corresponding values define (R, G, B) values. Default value is white (1, 1, 1).
Floats specifying the color for the block that has greater intensity value. They should be in the range [0, 1]. Corresponding values define (R, G, B) values. Default value is cyan (0, 0.69, 0.96).
Value in the range [0, 1] that specifies opacity of visualization. 1  fully transparent, 0  opaque.
Image with MBLBP visualization.
References
Face Detection Based on MultiBlock LBP Representation. Lun Zhang, Rufeng Chu, Shiming Xiang, Shengcai Liao, Stan Z. Li http://www.cbsr.ia.ac.cn/users/scliao/papers/ZhangICB07MBLBP.pdf
skimage.feature.draw_multiblock_lbp
¶skimage.feature.
peak_local_max
(image, min_distance=1, threshold_abs=None, threshold_rel=None, exclude_border=True, indices=True, num_peaks=inf, footprint=None, labels=None, num_peaks_per_label=inf)[source]¶Find peaks in an image as coordinate list or boolean mask.
Peaks are the local maxima in a region of 2 * min_distance + 1 (i.e. peaks are separated by at least min_distance).
If there are multiple local maxima with identical pixel intensities inside the region defined with min_distance, the coordinates of all such pixels are returned.
If both threshold_abs and threshold_rel are provided, the maximum of the two is chosen as the minimum intensity threshold of peaks.
Input image.
Minimum number of pixels separating peaks in a region of 2 * min_distance + 1 (i.e. peaks are separated by at least min_distance). To find the maximum number of peaks, use min_distance=1.
Minimum intensity of peaks. By default, the absolute threshold is the minimum intensity of the image.
Minimum intensity of peaks, calculated as max(image) * threshold_rel.
If nonzero int, exclude_border excludes peaks from within exclude_borderpixels of the border of the image. If True, takes the min_distance parameter as value. If zero or False, peaks are identified regardless of their distance from the border.
If True, the output will be an array representing peak coordinates. If False, the output will be a boolean array shaped as image.shape with peaks present at True elements.
Maximum number of peaks. When the number of peaks exceeds num_peaks, return num_peaks peaks based on highest peak intensity.
If provided, footprint == 1 represents the local region within which to search for peaks at every point in image. Overrides min_distance (also for exclude_border).
If provided, each unique region labels == value represents a unique region to search for peaks. Zero is reserved for background.
Maximum number of peaks for each label.
If indices = True : (row, column, …) coordinates of peaks.
If indices = False : Boolean array shaped like image, with peaks represented by True values.
Notes
The peak local maximum function returns the coordinates of local peaks (maxima) in an image. A maximum filter is used for finding local maxima. This operation dilates the original image. After comparison of the dilated and original image, this function returns the coordinates or a mask of the peaks where the dilated image equals the original image.
Examples
>>> img1 = np.zeros((7, 7))
>>> img1[3, 4] = 1
>>> img1[3, 2] = 1.5
>>> img1
array([[ 0. , 0. , 0. , 0. , 0. , 0. , 0. ],
[ 0. , 0. , 0. , 0. , 0. , 0. , 0. ],
[ 0. , 0. , 0. , 0. , 0. , 0. , 0. ],
[ 0. , 0. , 1.5, 0. , 1. , 0. , 0. ],
[ 0. , 0. , 0. , 0. , 0. , 0. , 0. ],
[ 0. , 0. , 0. , 0. , 0. , 0. , 0. ],
[ 0. , 0. , 0. , 0. , 0. , 0. , 0. ]])
>>> peak_local_max(img1, min_distance=1)
array([[3, 4],
[3, 2]])
>>> peak_local_max(img1, min_distance=2)
array([[3, 2]])
>>> img2 = np.zeros((20, 20, 20))
>>> img2[10, 10, 10] = 1
>>> peak_local_max(img2, exclude_border=0)
array([[10, 10, 10]])
skimage.feature.
structure_tensor
(image, sigma=1, mode='constant', cval=0)[source]¶Compute structure tensor using sum of squared differences.
The structure tensor A is defined as:
A = [Axx Axy]
[Axy Ayy]
which is approximated by the weighted sum of squared differences in a local window around each pixel in the image.
Input image.
Standard deviation used for the Gaussian kernel, which is used as a weighting function for the local summation of squared differences.
How to handle values outside the image borders.
Used in conjunction with mode ‘constant’, the value outside the image boundaries.
Element of the structure tensor for each pixel in the input image.
Element of the structure tensor for each pixel in the input image.
Element of the structure tensor for each pixel in the input image.
Examples
>>> from skimage.feature import structure_tensor
>>> square = np.zeros((5, 5))
>>> square[2, 2] = 1
>>> Axx, Axy, Ayy = structure_tensor(square, sigma=0.1)
>>> Axx
array([[ 0., 0., 0., 0., 0.],
[ 0., 1., 0., 1., 0.],
[ 0., 4., 0., 4., 0.],
[ 0., 1., 0., 1., 0.],
[ 0., 0., 0., 0., 0.]])
skimage.feature.
structure_tensor_eigvals
(Axx, Axy, Ayy)[source]¶Compute Eigen values of structure tensor.
Element of the structure tensor for each pixel in the input image.
Element of the structure tensor for each pixel in the input image.
Element of the structure tensor for each pixel in the input image.
Larger eigen value for each input matrix.
Smaller eigen value for each input matrix.
Examples
>>> from skimage.feature import structure_tensor, structure_tensor_eigvals
>>> square = np.zeros((5, 5))
>>> square[2, 2] = 1
>>> Axx, Axy, Ayy = structure_tensor(square, sigma=0.1)
>>> structure_tensor_eigvals(Axx, Axy, Ayy)[0]
array([[ 0., 0., 0., 0., 0.],
[ 0., 2., 4., 2., 0.],
[ 0., 4., 0., 4., 0.],
[ 0., 2., 4., 2., 0.],
[ 0., 0., 0., 0., 0.]])
skimage.feature.
hessian_matrix
(image, sigma=1, mode='constant', cval=0, order=None)[source]¶Compute Hessian matrix.
The Hessian matrix is defined as:
H = [Hrr Hrc]
[Hrc Hcc]
which is computed by convolving the image with the second derivatives of the Gaussian kernel in the respective x and ydirections.
Input image.
Standard deviation used for the Gaussian kernel, which is used as weighting function for the autocorrelation matrix.
How to handle values outside the image borders.
Used in conjunction with mode ‘constant’, the value outside the image boundaries.
This parameter allows for the use of reverse or forward order of the image axes in gradient computation. ‘xy’ indicates the usage of the last axis initially (Hxx, Hxy, Hyy), whilst ‘rc’ indicates the use of the first axis initially (Hrr, Hrc, Hcc).
Element of the Hessian matrix for each pixel in the input image.
Element of the Hessian matrix for each pixel in the input image.
Element of the Hessian matrix for each pixel in the input image.
Examples
>>> from skimage.feature import hessian_matrix
>>> square = np.zeros((5, 5))
>>> square[2, 2] = 4
>>> Hrr, Hrc, Hcc = hessian_matrix(square, sigma=0.1, order = 'rc')
>>> Hrc
array([[ 0., 0., 0., 0., 0.],
[ 0., 1., 0., 1., 0.],
[ 0., 0., 0., 0., 0.],
[ 0., 1., 0., 1., 0.],
[ 0., 0., 0., 0., 0.]])
skimage.feature.
hessian_matrix_det
(image, sigma=1, approximate=True)[source]¶Compute the approximate Hessian Determinant over an image.
The 2D approximate method uses box filters over integral images to compute the approximate Hessian Determinant, as described in [1].
The image over which to compute Hessian Determinant.
Standard deviation used for the Gaussian kernel, used for the Hessian matrix.
If True
and the image is 2D, use a much faster approximate
computation. This argument has no effect on 3D and higher images.
The array of the Determinant of Hessians.
Notes
For 2D images when approximate=True
, the running time of this method
only depends on size of the image. It is independent of sigma as one
would expect. The downside is that the result for sigma less than 3
is not accurate, i.e., not similar to the result obtained if someone
computed the Hessian and took its determinant.
References
Herbert Bay, Andreas Ess, Tinne Tuytelaars, Luc Van Gool, “SURF: Speeded Up Robust Features” ftp://ftp.vision.ee.ethz.ch/publications/articles/eth_biwi_00517.pdf
skimage.feature.
hessian_matrix_eigvals
(H_elems, Hxy=None, Hyy=None, Hxx=None)[source]¶Compute Eigenvalues of Hessian matrix.
The upperdiagonal elements of the Hessian matrix, as returned by hessian_matrix.
Element of the Hessian matrix for each pixel in the input image.
Element of the Hessian matrix for each pixel in the input image.
Element of the Hessian matrix for each pixel in the input image.
The eigenvalues of the Hessian matrix, in decreasing order. The
eigenvalues are the leading dimension. That is, eigs[i, j, k]
contains the ithlargest eigenvalue at position (j, k).
Examples
>>> from skimage.feature import hessian_matrix, hessian_matrix_eigvals
>>> square = np.zeros((5, 5))
>>> square[2, 2] = 4
>>> H_elems = hessian_matrix(square, sigma=0.1, order='rc')
>>> hessian_matrix_eigvals(H_elems)[0]
array([[ 0., 0., 2., 0., 0.],
[ 0., 1., 0., 1., 0.],
[ 2., 0., 2., 0., 2.],
[ 0., 1., 0., 1., 0.],
[ 0., 0., 2., 0., 0.]])
skimage.feature.
shape_index
(image, sigma=1, mode='constant', cval=0)[source]¶Compute the shape index.
The shape index, as defined by Koenderink & van Doorn [1], is a single valued measure of local curvature, assuming the image as a 3D plane with intensities representing heights.
It is derived from the eigen values of the Hessian, and its value ranges from 1 to 1 (and is undefined (=NaN) in flat regions), with following ranges representing following shapes:
Interval (s in …) 
Shape 

[ 1, 7/8) 
Spherical cup 
[7/8, 5/8) 
Through 
[5/8, 3/8) 
Rut 
[3/8, 1/8) 
Saddle rut 
[1/8, +1/8) 
Saddle 
[+1/8, +3/8) 
Saddle ridge 
[+3/8, +5/8) 
Ridge 
[+5/8, +7/8) 
Dome 
[+7/8, +1] 
Spherical cap 
Input image.
Standard deviation used for the Gaussian kernel, which is used for smoothing the input data before Hessian eigen value calculation.
How to handle values outside the image borders
Used in conjunction with mode ‘constant’, the value outside the image boundaries.
Shape index
References
Koenderink, J. J. & van Doorn, A. J., “Surface shape and curvature scales”, Image and Vision Computing, 1992, 10, 557564. DOI:10.1016/02628856(92)90076F
Examples
>>> from skimage.feature import shape_index
>>> square = np.zeros((5, 5))
>>> square[2, 2] = 4
>>> s = shape_index(square, sigma=0.1)
>>> s
array([[ nan, nan, 0.5, nan, nan],
[ nan, 0. , nan, 0. , nan],
[0.5, nan, 1. , nan, 0.5],
[ nan, 0. , nan, 0. , nan],
[ nan, nan, 0.5, nan, nan]])
skimage.feature.shape_index
¶skimage.feature.
corner_kitchen_rosenfeld
(image, mode='constant', cval=0)[source]¶Compute Kitchen and Rosenfeld corner measure response image.
The corner measure is calculated as follows:
(imxx * imy**2 + imyy * imx**2  2 * imxy * imx * imy)
/ (imx**2 + imy**2)
Where imx and imy are the first and imxx, imxy, imyy the second derivatives.
Input image.
How to handle values outside the image borders.
Used in conjunction with mode ‘constant’, the value outside the image boundaries.
Kitchen and Rosenfeld response image.
skimage.feature.
corner_harris
(image, method='k', k=0.05, eps=1e06, sigma=1)[source]¶Compute Harris corner measure response image.
This corner detector uses information from the autocorrelation matrix A:
A = [(imx**2) (imx*imy)] = [Axx Axy]
[(imx*imy) (imy**2)] [Axy Ayy]
Where imx and imy are first derivatives, averaged with a gaussian filter. The corner measure is then defined as:
det(A)  k * trace(A)**2
or:
2 * det(A) / (trace(A) + eps)
Input image.
Method to compute the response image from the autocorrelation matrix.
Sensitivity factor to separate corners from edges, typically in range [0, 0.2]. Small values of k result in detection of sharp corners.
Normalisation factor (Noble’s corner measure).
Standard deviation used for the Gaussian kernel, which is used as weighting function for the autocorrelation matrix.
Harris response image.
References
Examples
>>> from skimage.feature import corner_harris, corner_peaks
>>> square = np.zeros([10, 10])
>>> square[2:8, 2:8] = 1
>>> square.astype(int)
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]])
>>> corner_peaks(corner_harris(square), min_distance=1)
array([[2, 2],
[2, 7],
[7, 2],
[7, 7]])
skimage.feature.
corner_shi_tomasi
(image, sigma=1)[source]¶Compute ShiTomasi (KanadeTomasi) corner measure response image.
This corner detector uses information from the autocorrelation matrix A:
A = [(imx**2) (imx*imy)] = [Axx Axy]
[(imx*imy) (imy**2)] [Axy Ayy]
Where imx and imy are first derivatives, averaged with a gaussian filter. The corner measure is then defined as the smaller eigenvalue of A:
((Axx + Ayy)  sqrt((Axx  Ayy)**2 + 4 * Axy**2)) / 2
Input image.
Standard deviation used for the Gaussian kernel, which is used as weighting function for the autocorrelation matrix.
ShiTomasi response image.
References
Examples
>>> from skimage.feature import corner_shi_tomasi, corner_peaks
>>> square = np.zeros([10, 10])
>>> square[2:8, 2:8] = 1
>>> square.astype(int)
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]])
>>> corner_peaks(corner_shi_tomasi(square), min_distance=1)
array([[2, 2],
[2, 7],
[7, 2],
[7, 7]])
skimage.feature.
corner_foerstner
(image, sigma=1)[source]¶Compute Foerstner corner measure response image.
This corner detector uses information from the autocorrelation matrix A:
A = [(imx**2) (imx*imy)] = [Axx Axy]
[(imx*imy) (imy**2)] [Axy Ayy]
Where imx and imy are first derivatives, averaged with a gaussian filter. The corner measure is then defined as:
w = det(A) / trace(A) (size of error ellipse)
q = 4 * det(A) / trace(A)**2 (roundness of error ellipse)
Input image.
Standard deviation used for the Gaussian kernel, which is used as weighting function for the autocorrelation matrix.
Error ellipse sizes.
Roundness of error ellipse.
References
Examples
>>> from skimage.feature import corner_foerstner, corner_peaks
>>> square = np.zeros([10, 10])
>>> square[2:8, 2:8] = 1
>>> square.astype(int)
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]])
>>> w, q = corner_foerstner(square)
>>> accuracy_thresh = 0.5
>>> roundness_thresh = 0.3
>>> foerstner = (q > roundness_thresh) * (w > accuracy_thresh) * w
>>> corner_peaks(foerstner, min_distance=1)
array([[2, 2],
[2, 7],
[7, 2],
[7, 7]])
skimage.feature.
corner_subpix
(image, corners, window_size=11, alpha=0.99)[source]¶Determine subpixel position of corners.
A statistical test decides whether the corner is defined as the intersection of two edges or a single peak. Depending on the classification result, the subpixel corner location is determined based on the local covariance of the greyvalues. If the significance level for either statistical test is not sufficient, the corner cannot be classified, and the output subpixel position is set to NaN.
Input image.
Corner coordinates (row, col).
Search window size for subpixel estimation.
Significance level for corner classification.
Subpixel corner positions. NaN for “not classified” corners.
References
http://www.ipb.unibonn.de/uploads/tx_ikgpublication/ foerstner87.fast.pdf
Examples
>>> from skimage.feature import corner_harris, corner_peaks, corner_subpix
>>> img = np.zeros((10, 10))
>>> img[:5, :5] = 1
>>> img[5:, 5:] = 1
>>> img.astype(int)
array([[1, 1, 1, 1, 1, 0, 0, 0, 0, 0],
[1, 1, 1, 1, 1, 0, 0, 0, 0, 0],
[1, 1, 1, 1, 1, 0, 0, 0, 0, 0],
[1, 1, 1, 1, 1, 0, 0, 0, 0, 0],
[1, 1, 1, 1, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 1, 1, 1, 1],
[0, 0, 0, 0, 0, 1, 1, 1, 1, 1],
[0, 0, 0, 0, 0, 1, 1, 1, 1, 1],
[0, 0, 0, 0, 0, 1, 1, 1, 1, 1],
[0, 0, 0, 0, 0, 1, 1, 1, 1, 1]])
>>> coords = corner_peaks(corner_harris(img), min_distance=2)
>>> coords_subpix = corner_subpix(img, coords, window_size=7)
>>> coords_subpix
array([[ 4.5, 4.5]])
skimage.feature.
corner_peaks
(image, min_distance=1, threshold_abs=None, threshold_rel=0.1, exclude_border=True, indices=True, num_peaks=inf, footprint=None, labels=None)[source]¶Find corners in corner measure response image.
This differs from skimage.feature.peak_local_max in that it suppresses multiple connected peaks with the same accumulator value.
Examples
>>> from skimage.feature import peak_local_max
>>> response = np.zeros((5, 5))
>>> response[2:4, 2:4] = 1
>>> response
array([[ 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0.],
[ 0., 0., 1., 1., 0.],
[ 0., 0., 1., 1., 0.],
[ 0., 0., 0., 0., 0.]])
>>> peak_local_max(response)
array([[3, 3],
[3, 2],
[2, 3],
[2, 2]])
>>> corner_peaks(response)
array([[2, 2]])
skimage.feature.
corner_moravec
(image, window_size=1)[source]¶Compute Moravec corner measure response image.
This is one of the simplest corner detectors and is comparatively fast but has several limitations (e.g. not rotation invariant).
Input image.
Window size.
Moravec response image.
References
Examples
>>> from skimage.feature import corner_moravec
>>> square = np.zeros([7, 7])
>>> square[3, 3] = 1
>>> square.astype(int)
array([[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0]])
>>> corner_moravec(square).astype(int)
array([[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 1, 1, 0, 0],
[0, 0, 1, 2, 1, 0, 0],
[0, 0, 1, 1, 1, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0]])
skimage.feature.
corner_fast
(image, n=12, threshold=0.15)[source]¶Extract FAST corners for a given image.
Input image.
Minimum number of consecutive pixels out of 16 pixels on the circle that should all be either brighter or darker w.r.t testpixel. A point c on the circle is darker w.r.t test pixel p if Ic < Ip  threshold and brighter if Ic > Ip + threshold. Also stands for the n in FASTn corner detector.
Threshold used in deciding whether the pixels on the circle are brighter, darker or similar w.r.t. the test pixel. Decrease the threshold when more corners are desired and viceversa.
FAST corner response image.
References
Edward Rosten and Tom Drummond “Machine Learning for highspeed corner detection”, http://www.edwardrosten.com/work/rosten_2006_machine.pdf
Wikipedia, “Features from accelerated segment test”, https://en.wikipedia.org/wiki/Features_from_accelerated_segment_test
Examples
>>> from skimage.feature import corner_fast, corner_peaks
>>> square = np.zeros((12, 12))
>>> square[3:9, 3:9] = 1
>>> square.astype(int)
array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 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, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0],
[0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0],
[0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0],
[0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 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, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]])
>>> corner_peaks(corner_fast(square, 9), min_distance=1)
array([[3, 3],
[3, 8],
[8, 3],
[8, 8]])
skimage.feature.
corner_orientations
(image, corners, mask)[source]¶Compute the orientation of corners.
The orientation of corners is computed using the first order central moment i.e. the center of mass approach. The corner orientation is the angle of the vector from the corner coordinate to the intensity centroid in the local neighborhood around the corner calculated using first order central moment.
Input grayscale image.
Corner coordinates as (row, col)
.
Mask defining the local neighborhood of the corner used for the calculation of the central moment.
Orientations of corners in the range [pi, pi].
References
Ethan Rublee, Vincent Rabaud, Kurt Konolige and Gary Bradski “ORB : An efficient alternative to SIFT and SURF” http://www.vision.cs.chubu.ac.jp/CVR/pdf/Rublee_iccv2011.pdf
Paul L. Rosin, “Measuring Corner Properties” http://users.cs.cf.ac.uk/Paul.Rosin/corner2.pdf
Examples
>>> from skimage.morphology import octagon
>>> from skimage.feature import (corner_fast, corner_peaks,
... corner_orientations)
>>> square = np.zeros((12, 12))
>>> square[3:9, 3:9] = 1
>>> square.astype(int)
array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 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, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0],
[0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0],
[0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0],
[0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 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, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]])
>>> corners = corner_peaks(corner_fast(square, 9), min_distance=1)
>>> corners
array([[3, 3],
[3, 8],
[8, 3],
[8, 8]])
>>> orientations = corner_orientations(square, corners, octagon(3, 2))
>>> np.rad2deg(orientations)
array([ 45., 135., 45., 135.])
skimage.feature.
match_template
(image, template, pad_input=False, mode='constant', constant_values=0)[source]¶Match a template to a 2D or 3D image using normalized correlation.
The output is an array with values between 1.0 and 1.0. The value at a given position corresponds to the correlation coefficient between the image and the template.
For pad_input=True matches correspond to the center and otherwise to the topleft corner of the template. To find the best match you must search for peaks in the response (output) image.
2D or 3D input image.
Template to locate. It must be (m <= M, n <= N[, d <= D]).
If True, pad image so that output is the same size as the image, and output values correspond to the template center. Otherwise, the output is an array with shape (M  m + 1, N  n + 1) for an (M, N) image and an (m, n) template, and matches correspond to origin (topleft corner) of the template.
Padding mode.
Constant values used in conjunction with mode='constant'
.
Response image with correlation coefficients.
Notes
Details on the crosscorrelation are presented in [1]. This implementation uses FFT convolutions of the image and the template. Reference [2] presents similar derivations but the approximation presented in this reference is not used in our implementation.
References
J. P. Lewis, “Fast Normalized CrossCorrelation”, Industrial Light and Magic.
Briechle and Hanebeck, “Template Matching using Fast Normalized Cross Correlation”, Proceedings of the SPIE (2001). DOI:10.1117/12.421129
Examples
>>> template = np.zeros((3, 3))
>>> template[1, 1] = 1
>>> template
array([[ 0., 0., 0.],
[ 0., 1., 0.],
[ 0., 0., 0.]])
>>> image = np.zeros((6, 6))
>>> image[1, 1] = 1
>>> image[4, 4] = 1
>>> image
array([[ 0., 0., 0., 0., 0., 0.],
[ 0., 1., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 1., 0.],
[ 0., 0., 0., 0., 0., 0.]])
>>> result = match_template(image, template)
>>> np.round(result, 3)
array([[ 1. , 0.125, 0. , 0. ],
[0.125, 0.125, 0. , 0. ],
[ 0. , 0. , 0.125, 0.125],
[ 0. , 0. , 0.125, 1. ]])
>>> result = match_template(image, template, pad_input=True)
>>> np.round(result, 3)
array([[0.125, 0.125, 0.125, 0. , 0. , 0. ],
[0.125, 1. , 0.125, 0. , 0. , 0. ],
[0.125, 0.125, 0.125, 0. , 0. , 0. ],
[ 0. , 0. , 0. , 0.125, 0.125, 0.125],
[ 0. , 0. , 0. , 0.125, 1. , 0.125],
[ 0. , 0. , 0. , 0.125, 0.125, 0.125]])
skimage.feature.match_template
¶skimage.feature.
register_translation
(src_image, target_image, upsample_factor=1, space='real', return_error=True)[source]¶Efficient subpixel image translation registration by crosscorrelation.
This code gives the same precision as the FFT upsampled crosscorrelation in a fraction of the computation time and with reduced memory requirements. It obtains an initial estimate of the crosscorrelation peak by an FFT and then refines the shift estimation by upsampling the DFT only in a small neighborhood of that estimate by means of a matrixmultiply DFT.
Reference image.
Image to register. Must be same dimensionality as src_image
.
Upsampling factor. Images will be registered to within
1 / upsample_factor
of a pixel. For example
upsample_factor == 20
means the images will be registered
within 1/20th of a pixel. Default is 1 (no upsampling)
Defines how the algorithm interprets input data. “real” means data will be FFT’d to compute the correlation, while “fourier” data will bypass FFT of input data. Case insensitive.
Returns error and phase difference if on, otherwise only shifts are returned
Shift vector (in pixels) required to register target_image
with
src_image
. Axis ordering is consistent with numpy (e.g. Z, Y, X)
Translation invariant normalized RMS error between src_image
and
target_image
.
Global phase difference between the two images (should be zero if images are nonnegative).
References
Manuel GuizarSicairos, Samuel T. Thurman, and James R. Fienup, “Efficient subpixel image registration algorithms,” Optics Letters 33, 156158 (2008). DOI:10.1364/OL.33.000156
James R. Fienup, “Invariant error metrics for image reconstruction” Optics Letters 36, 83528357 (1997). DOI:10.1364/AO.36.008352
skimage.feature.register_translation
¶skimage.feature.
masked_register_translation
(src_image, target_image, src_mask, target_mask=None, overlap_ratio=0.3)[source]¶Masked image translation registration by masked normalized crosscorrelation.
Reference image.
Image to register. Must be same dimensionality as src_image
,
but not necessarily the same size.
Boolean mask for src_image
. The mask should evaluate to True
(or 1) on valid pixels. src_mask
should have the same shape
as src_mask
.
Boolean mask for target_image
. The mask should evaluate to True
(or 1) on valid pixels. target_mask
should have the same shape
as target_image
. If None
, src_mask
will be used.
Minimum allowed overlap ratio between images. The correlation for translations corresponding with an overlap ratio lower than this threshold will be ignored. A lower overlap_ratio leads to smaller maximum translation, while a higher overlap_ratio leads to greater robustness against spurious matches due to small overlap between masked images.
Shift vector (in pixels) required to register target_image
with
src_image
. Axis ordering is consistent with numpy (e.g. Z, Y, X)
References
Dirk Padfield. Masked Object Registration in the Fourier Domain. IEEE Transactions on Image Processing, vol. 21(5), pp. 27062718 (2012). DOI:10.1109/TIP.2011.2181402
D. Padfield. “Masked FFT registration”. In Proc. Computer Vision and Pattern Recognition, pp. 29182925 (2010). DOI:10.1109/CVPR.2010.5540032
skimage.feature.masked_register_translation
¶skimage.feature.
match_descriptors
(descriptors1, descriptors2, metric=None, p=2, max_distance=inf, cross_check=True, max_ratio=1.0)[source]¶Bruteforce matching of descriptors.
For each descriptor in the first set this matcher finds the closest descriptor in the second set (and viceversa in the case of enabled crosschecking).
Binary descriptors of size P about M keypoints in the first image.
Binary descriptors of size P about N keypoints in the second image.
The metric to compute the distance between two descriptors. See scipy.spatial.distance.cdist for all possible types. The hamming distance should be used for binary descriptors. By default the L2norm is used for all descriptors of dtype float or double and the Hamming distance is used for binary descriptors automatically.
The pnorm to apply for metric='minkowski'
.
Maximum allowed distance between descriptors of two keypoints in separate images to be regarded as a match.
If True, the matched keypoints are returned after cross checking i.e. a matched pair (keypoint1, keypoint2) is returned if keypoint2 is the best match for keypoint1 in second image and keypoint1 is the best match for keypoint2 in first image.
Maximum ratio of distances between first and second closest descriptor in the second set of descriptors. This threshold is useful to filter ambiguous matches between the two descriptor sets. The choice of this value depends on the statistics of the chosen descriptor, e.g., for SIFT descriptors a value of 0.8 is usually chosen, see D.G. Lowe, “Distinctive Image Features from ScaleInvariant Keypoints”, International Journal of Computer Vision, 2004.
Indices of corresponding matches in first and second set of
descriptors, where matches[:, 0]
denote the indices in the first
and matches[:, 1]
the indices in the second set of descriptors.
skimage.feature.
plot_matches
(ax, image1, image2, keypoints1, keypoints2, matches, keypoints_color='k', matches_color=None, only_matches=False, alignment='horizontal')[source]¶Plot matched features.
Matches and image are drawn in this ax.
First grayscale or color image.
Second grayscale or color image.
First keypoint coordinates as (row, col)
.
Second keypoint coordinates as (row, col)
.
Indices of corresponding matches in first and second set of
descriptors, where matches[:, 0]
denote the indices in the first
and matches[:, 1]
the indices in the second set of descriptors.
Color for keypoint locations.
Color for lines which connect keypoint matches. By default the color is chosen randomly.
Whether to only plot matches and not plot the keypoint locations.
Whether to show images side by side, 'horizontal'
, or one above
the other, 'vertical'
.
skimage.feature.
blob_dog
(image, min_sigma=1, max_sigma=50, sigma_ratio=1.6, threshold=2.0, overlap=0.5, *, exclude_border=False)[source]¶Finds blobs in the given grayscale image.
Blobs are found using the Difference of Gaussian (DoG) method [1]. For each blob found, the method returns its coordinates and the standard deviation of the Gaussian kernel that detected the blob.
Input grayscale image, blobs are assumed to be light on dark background (white on black).
The minimum standard deviation for Gaussian kernel. Keep this low to detect smaller blobs. The standard deviations of the Gaussian filter are given for each axis as a sequence, or as a single number, in which case it is equal for all axes.
The maximum standard deviation for Gaussian kernel. Keep this high to detect larger blobs. The standard deviations of the Gaussian filter are given for each axis as a sequence, or as a single number, in which case it is equal for all axes.
The ratio between the standard deviation of Gaussian Kernels used for computing the Difference of Gaussians
The absolute lower bound for scale space maxima. Local maxima smaller than thresh are ignored. Reduce this to detect blobs with less intensities.
A value between 0 and 1. If the area of two blobs overlaps by a fraction greater than threshold, the smaller blob is eliminated.
If nonzero int, exclude_border excludes blobs from within exclude_borderpixels of the border of the image.
A 2d array with each row representing 2 coordinate values for a 2D
image, and 3 coordinate values for a 3D image, plus the sigma(s) used.
When a single sigma is passed, outputs are:
(r, c, sigma)
or (p, r, c, sigma)
where (r, c)
or
(p, r, c)
are coordinates of the blob and sigma
is the standard
deviation of the Gaussian kernel which detected the blob. When an
anisotropic gaussian is used (sigmas per dimension), the detected sigma
is returned for each dimension.
Notes
The radius of each blob is approximately \(\sqrt{2}\sigma\) for a 2D image and \(\sqrt{3}\sigma\) for a 3D image.
References
Examples
>>> from skimage import data, feature
>>> feature.blob_dog(data.coins(), threshold=.5, max_sigma=40)
array([[ 267. , 359. , 16.777216],
[ 267. , 115. , 10.48576 ],
[ 263. , 302. , 16.777216],
[ 263. , 245. , 16.777216],
[ 261. , 173. , 16.777216],
[ 260. , 46. , 16.777216],
[ 198. , 155. , 10.48576 ],
[ 196. , 43. , 10.48576 ],
[ 195. , 102. , 16.777216],
[ 194. , 277. , 16.777216],
[ 193. , 213. , 16.777216],
[ 185. , 347. , 16.777216],
[ 128. , 154. , 10.48576 ],
[ 127. , 102. , 10.48576 ],
[ 125. , 208. , 10.48576 ],
[ 125. , 45. , 16.777216],
[ 124. , 337. , 10.48576 ],
[ 120. , 272. , 16.777216],
[ 58. , 100. , 10.48576 ],
[ 54. , 276. , 10.48576 ],
[ 54. , 42. , 16.777216],
[ 52. , 216. , 16.777216],
[ 52. , 155. , 16.777216],
[ 45. , 336. , 16.777216]])
skimage.feature.blob_dog
¶skimage.feature.
blob_doh
(image, min_sigma=1, max_sigma=30, num_sigma=10, threshold=0.01, overlap=0.5, log_scale=False)[source]¶Finds blobs in the given grayscale image.
Blobs are found using the Determinant of Hessian method [1]. For each blob found, the method returns its coordinates and the standard deviation of the Gaussian Kernel used for the Hessian matrix whose determinant detected the blob. Determinant of Hessians is approximated using [2].
Input grayscale image.Blobs can either be light on dark or vice versa.
The minimum standard deviation for Gaussian Kernel used to compute Hessian matrix. Keep this low to detect smaller blobs.
The maximum standard deviation for Gaussian Kernel used to compute Hessian matrix. Keep this high to detect larger blobs.
The number of intermediate values of standard deviations to consider between min_sigma and max_sigma.
The absolute lower bound for scale space maxima. Local maxima smaller than thresh are ignored. Reduce this to detect less prominent blobs.
A value between 0 and 1. If the area of two blobs overlaps by a fraction greater than threshold, the smaller blob is eliminated.
If set intermediate values of standard deviations are interpolated using a logarithmic scale to the base 10. If not, linear interpolation is used.
A 2d array with each row representing 3 values, (y,x,sigma)
where (y,x)
are coordinates of the blob and sigma
is the
standard deviation of the Gaussian kernel of the Hessian Matrix whose
determinant detected the blob.
Notes
The radius of each blob is approximately sigma.
Computation of Determinant of Hessians is independent of the standard
deviation. Therefore detecting larger blobs won’t take more time. In
methods line blob_dog()
and blob_log()
the computation
of Gaussians for larger sigma takes more time. The downside is that
this method can’t be used for detecting blobs of radius less than 3px
due to the box filters used in the approximation of Hessian Determinant.
References
https://en.wikipedia.org/wiki/Blob_detection#The_determinant_of_the_Hessian
Herbert Bay, Andreas Ess, Tinne Tuytelaars, Luc Van Gool, “SURF: Speeded Up Robust Features” ftp://ftp.vision.ee.ethz.ch/publications/articles/eth_biwi_00517.pdf
Examples
>>> from skimage import data, feature
>>> img = data.coins()
>>> feature.blob_doh(img)
array([[ 270. , 363. , 30. ],
[ 265. , 113. , 23.55555556],
[ 262. , 243. , 23.55555556],
[ 260. , 173. , 30. ],
[ 197. , 153. , 20.33333333],
[ 197. , 44. , 20.33333333],
[ 195. , 100. , 23.55555556],
[ 193. , 275. , 23.55555556],
[ 192. , 212. , 23.55555556],
[ 185. , 348. , 30. ],
[ 156. , 302. , 30. ],
[ 126. , 153. , 20.33333333],
[ 126. , 101. , 20.33333333],
[ 124. , 336. , 20.33333333],
[ 123. , 205. , 20.33333333],
[ 123. , 44. , 23.55555556],
[ 121. , 271. , 30. ]])
skimage.feature.blob_doh
¶skimage.feature.
blob_log
(image, min_sigma=1, max_sigma=50, num_sigma=10, threshold=0.2, overlap=0.5, log_scale=False, *, exclude_border=False)[source]¶Finds blobs in the given grayscale image.
Blobs are found using the Laplacian of Gaussian (LoG) method [1]. For each blob found, the method returns its coordinates and the standard deviation of the Gaussian kernel that detected the blob.
Input grayscale image, blobs are assumed to be light on dark background (white on black).
the minimum standard deviation for Gaussian kernel. Keep this low to detect smaller blobs. The standard deviations of the Gaussian filter are given for each axis as a sequence, or as a single number, in which case it is equal for all axes.
The maximum standard deviation for Gaussian kernel. Keep this high to detect larger blobs. The standard deviations of the Gaussian filter are given for each axis as a sequence, or as a single number, in which case it is equal for all axes.
The number of intermediate values of standard deviations to consider between min_sigma and max_sigma.
The absolute lower bound for scale space maxima. Local maxima smaller than thresh are ignored. Reduce this to detect blobs with less intensities.
A value between 0 and 1. If the area of two blobs overlaps by a fraction greater than threshold, the smaller blob is eliminated.
If set intermediate values of standard deviations are interpolated using a logarithmic scale to the base 10. If not, linear interpolation is used.
If nonzero int, exclude_border excludes blobs from within exclude_borderpixels of the border of the image.
A 2d array with each row representing 2 coordinate values for a 2D
image, and 3 coordinate values for a 3D image, plus the sigma(s) used.
When a single sigma is passed, outputs are:
(r, c, sigma)
or (p, r, c, sigma)
where (r, c)
or
(p, r, c)
are coordinates of the blob and sigma
is the standard
deviation of the Gaussian kernel which detected the blob. When an
anisotropic gaussian is used (sigmas per dimension), the detected sigma
is returned for each dimension.
Notes
The radius of each blob is approximately \(\sqrt{2}\sigma\) for a 2D image and \(\sqrt{3}\sigma\) for a 3D image.
References
Examples
>>> from skimage import data, feature, exposure
>>> img = data.coins()
>>> img = exposure.equalize_hist(img) # improves detection
>>> feature.blob_log(img, threshold = .3)
array([[ 266. , 115. , 11.88888889],
[ 263. , 302. , 17.33333333],
[ 263. , 244. , 17.33333333],
[ 260. , 174. , 17.33333333],
[ 198. , 155. , 11.88888889],
[ 198. , 103. , 11.88888889],
[ 197. , 44. , 11.88888889],
[ 194. , 276. , 17.33333333],
[ 194. , 213. , 17.33333333],
[ 185. , 344. , 17.33333333],
[ 128. , 154. , 11.88888889],
[ 127. , 102. , 11.88888889],
[ 126. , 208. , 11.88888889],
[ 126. , 46. , 11.88888889],
[ 124. , 336. , 11.88888889],
[ 121. , 272. , 17.33333333],
[ 113. , 323. , 1. ]])
skimage.feature.blob_log
¶skimage.feature.
haar_like_feature
(int_image, r, c, width, height, feature_type=None, feature_coord=None)[source]¶Compute the Haarlike features for a region of interest (ROI) of an integral image.
Haarlike features have been successfully used for image classification and object detection [1]. It has been used for realtime face detection algorithm proposed in [2].
Integral image for which the features need to be computed.
Rowcoordinate of top left corner of the detection window.
Columncoordinate of top left corner of the detection window.
Width of the detection window.
Height of the detection window.
The type of feature to consider:
‘type2x’: 2 rectangles varying along the x axis;
‘type2y’: 2 rectangles varying along the y axis;
‘type3x’: 3 rectangles varying along the x axis;
‘type3y’: 3 rectangles varying along the y axis;
‘type4’: 4 rectangles varying along x and y axis.
By default all features are extracted.
If using with feature_coord, it should correspond to the feature type of each associated coordinate feature.
The array of coordinates to be extracted. This is useful when you want
to recompute only a subset of features. In this case feature_type
needs to be an array containing the type of each feature, as returned
by haar_like_feature_coord()
. By default, all coordinates are
computed.
Resulting Haarlike features. Each value is equal to the subtraction of sums of the positive and negative rectangles. The data type depends of the data type of int_image: int when the data type of int_image is uint or int and float when the data type of int_image is float.
Notes
When extracting those features in parallel, be aware that the choice of the backend (i.e. multiprocessing vs threading) will have an impact on the performance. The rule of thumb is as follows: use multiprocessing when extracting features for all possible ROI in an image; use threading when extracting the feature at specific location for a limited number of ROIs. Refer to the example Face classification using Haarlike feature descriptor for more insights.
References
Oren, M., Papageorgiou, C., Sinha, P., Osuna, E., & Poggio, T. (1997, June). Pedestrian detection using wavelet templates. In Computer Vision and Pattern Recognition, 1997. Proceedings., 1997 IEEE Computer Society Conference on (pp. 193199). IEEE. http://tinyurl.com/y6ulxfta DOI:10.1109/CVPR.1997.609319
Viola, Paul, and Michael J. Jones. “Robust realtime face detection.” International journal of computer vision 57.2 (2004): 137154. http://www.merl.com/publications/docs/TR2004043.pdf DOI:10.1109/CVPR.2001.990517
Examples
>>> import numpy as np
>>> from skimage.transform import integral_image
>>> from skimage.feature import haar_like_feature
>>> img = np.ones((5, 5), dtype=np.uint8)
>>> img_ii = integral_image(img)
>>> feature = haar_like_feature(img_ii, 0, 0, 5, 5, 'type3x')
>>> feature
array([1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1,
2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1,
2, 1, 2, 1, 2, 1, 1, 1])
You can compute the feature for some precomputed coordinates.
>>> from skimage.feature import haar_like_feature_coord
>>> feature_coord, feature_type = zip(
... *[haar_like_feature_coord(5, 5, feat_t)
... for feat_t in ('type2x', 'type3x')])
>>> # only select one feature over two
>>> feature_coord = np.concatenate([x[::2] for x in feature_coord])
>>> feature_type = np.concatenate([x[::2] for x in feature_type])
>>> feature = haar_like_feature(img_ii, 0, 0, 5, 5,
... feature_type=feature_type,
... feature_coord=feature_coord)
>>> feature
array([ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 1, 3, 1, 3, 1, 3, 1,
3, 1, 3, 1, 3, 2, 1, 3, 2, 2, 2, 1])
skimage.feature.haar_like_feature
¶skimage.feature.
haar_like_feature_coord
(width, height, feature_type=None)[source]¶Compute the coordinates of Haarlike features.
Width of the detection window.
Height of the detection window.
The type of feature to consider:
‘type2x’: 2 rectangles varying along the x axis;
‘type2y’: 2 rectangles varying along the y axis;
‘type3x’: 3 rectangles varying along the x axis;
‘type3y’: 3 rectangles varying along the y axis;
‘type4’: 4 rectangles varying along x and y axis.
By default all features are extracted.
Coordinates of the rectangles for each feature.
The corresponding type for each feature.
Examples
>>> import numpy as np
>>> from skimage.transform import integral_image
>>> from skimage.feature import haar_like_feature_coord
>>> feat_coord, feat_type = haar_like_feature_coord(2, 2, 'type4')
>>> feat_coord # doctest: +SKIP
array([ list([[(0, 0), (0, 0)], [(0, 1), (0, 1)],
[(1, 1), (1, 1)], [(1, 0), (1, 0)]])], dtype=object)
>>> feat_type
array(['type4'], dtype=object)
skimage.feature.
draw_haar_like_feature
(image, r, c, width, height, feature_coord, color_positive_block=(1.0, 0.0, 0.0), color_negative_block=(0.0, 1.0, 0.0), alpha=0.5, max_n_features=None, random_state=None)[source]¶Visualization of Haarlike features.
The region of an integral image for which the features need to be computed.
Rowcoordinate of top left corner of the detection window.
Columncoordinate of top left corner of the detection window.
Width of the detection window.
Height of the detection window.
The array of coordinates to be extracted. This is useful when you want
to recompute only a subset of features. In this case feature_type
needs to be an array containing the type of each feature, as returned
by haar_like_feature_coord()
. By default, all coordinates are
computed.
Floats specifying the color for the positive block. Corresponding values define (R, G, B) values. Default value is red (1, 0, 0).
Floats specifying the color for the negative block Corresponding values define (R, G, B) values. Default value is blue (0, 1, 0).
Value in the range [0, 1] that specifies opacity of visualization. 1  fully transparent, 0  opaque.
The maximum number of features to be returned. By default, all features are returned.
If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by np.random. The random state is used when generating a set of features smaller than the total number of available features.
An image in which the different features will be added.
Examples
>>> import numpy as np
>>> from skimage.feature import haar_like_feature_coord
>>> from skimage.feature import draw_haar_like_feature
>>> feature_coord, _ = haar_like_feature_coord(2, 2, 'type4')
>>> image = draw_haar_like_feature(np.zeros((2, 2)),
... 0, 0, 2, 2,
... feature_coord,
... max_n_features=1)
>>> image
array([[[ 0. , 0.5, 0. ],
[ 0.5, 0. , 0. ]],
<BLANKLINE>
[[ 0.5, 0. , 0. ],
[ 0. , 0.5, 0. ]]])
Cascade
¶skimage.feature.
Cascade
¶Bases: object
Class for cascade of classifiers that is used for object detection.
The main idea behind cascade of classifiers is to create classifiers of medium accuracy and ensemble them into one strong classifier instead of just creating a strong one. The second advantage of cascade classifier is that easy examples can be classified only by evaluating some of the classifiers in the cascade, making the process much faster than the process of evaluating a one strong classifier.
Accuracy parameter. Increasing it, makes the classifier detect less false positives but at the same time the false negative score increases.
Amount of stages in a cascade. Each cascade consists of stumps i.e. trained features.
The overall amount of stumps in all the stages of cascade.
The overall amount of different features used by cascade. Two stumps can use the same features but has different trained values.
The width of a detection window that is used. Objects smaller than this window can’t be detected.
The height of a detection window.
A link to the c array that stores stages information using Stage struct.
Link to the c array that stores MBLBP features using MBLBP struct.
The ling to the array with lookup tables that are used by trained MBLBP features (MBLBPStumps) to evaluate a particular region.
__init__
()¶Initialize cascade classifier.
A file in a OpenCv format from which all the cascade classifier’s parameters are loaded.
Accuracy parameter. Increasing it, makes the classifier detect less false positives but at the same time the false negative score increases.
detect_multi_scale
()¶Search for the object on multiple scales of input image.
The function takes the input image, the scale factor by which the searching window is multiplied on each step, minimum window size and maximum window size that specify the interval for the search windows that are applied to the input image to detect objects.
Ndarray that represents the input image.
The scale by which searching window is multiplied on each step.
The ratio by which the search step in multiplied on each scale of the image. 1 represents the exaustive search and usually is slow. By setting this parameter to higher values the results will be worse but the computation will be much faster. Usually, values in the interval [1, 1.5] give good results.
Minimum size of the search window.
Maximum size of the search window.
Minimum amount of intersecting detections in order for detection to be approved by the function.
The minimum value of value of ratio (intersection area) / (small rectangle ratio) in order to merge two detections into one.
Dict have form {‘r’: int, ‘c’: int, ‘width’: int, ‘height’: int}, where ‘r’ represents row position of top left corner of detected window, ‘c’  col position, ‘width’  width of detected window, ‘height’  height of detected window.
eps
¶features_number
¶stages_number
¶stumps_number
¶window_height
¶window_width
¶BRIEF
¶skimage.feature.
BRIEF
(descriptor_size=256, patch_size=49, mode='normal', sigma=1, sample_seed=1)[source]¶Bases: skimage.feature.util.DescriptorExtractor
BRIEF binary descriptor extractor.
BRIEF (Binary Robust Independent Elementary Features) is an efficient feature point descriptor. It is highly discriminative even when using relatively few bits and is computed using simple intensity difference tests.
For each keypoint, intensity comparisons are carried out for a specifically distributed number N of pixelpairs resulting in a binary descriptor of length N. For binary descriptors the Hamming distance can be used for feature matching, which leads to lower computational cost in comparison to the L2 norm.
Size of BRIEF descriptor for each keypoint. Sizes 128, 256 and 512 recommended by the authors. Default is 256.
Length of the two dimensional square patch sampling region around the keypoints. Default is 49.
Probability distribution for sampling location of decision pixelpairs around keypoints.
Seed for the random sampling of the decision pixelpairs. From a square window with length patch_size, pixel pairs are sampled using the mode parameter to build the descriptors using intensity comparison. The value of sample_seed must be the same for the images to be matched while building the descriptors.
Standard deviation of the Gaussian lowpass filter applied to the image to alleviate noise sensitivity, which is strongly recommended to obtain discriminative and good descriptors.
Examples
>>> from skimage.feature import (corner_harris, corner_peaks, BRIEF,
... match_descriptors)
>>> import numpy as np
>>> square1 = np.zeros((8, 8), dtype=np.int32)
>>> square1[2:6, 2:6] = 1
>>> square1
array([[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 1, 1, 1, 0, 0],
[0, 0, 1, 1, 1, 1, 0, 0],
[0, 0, 1, 1, 1, 1, 0, 0],
[0, 0, 1, 1, 1, 1, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0]], dtype=int32)
>>> square2 = np.zeros((9, 9), dtype=np.int32)
>>> square2[2:7, 2:7] = 1
>>> square2
array([[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, 0, 0],
[0, 0, 1, 1, 1, 1, 1, 0, 0],
[0, 0, 1, 1, 1, 1, 1, 0, 0],
[0, 0, 1, 1, 1, 1, 1, 0, 0],
[0, 0, 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]], dtype=int32)
>>> keypoints1 = corner_peaks(corner_harris(square1), min_distance=1)
>>> keypoints2 = corner_peaks(corner_harris(square2), min_distance=1)
>>> extractor = BRIEF(patch_size=5)
>>> extractor.extract(square1, keypoints1)
>>> descriptors1 = extractor.descriptors
>>> extractor.extract(square2, keypoints2)
>>> descriptors2 = extractor.descriptors
>>> matches = match_descriptors(descriptors1, descriptors2)
>>> matches
array([[0, 0],
[1, 1],
[2, 2],
[3, 3]])
>>> keypoints1[matches[:, 0]]
array([[2, 2],
[2, 5],
[5, 2],
[5, 5]])
>>> keypoints2[matches[:, 1]]
array([[2, 2],
[2, 6],
[6, 2],
[6, 6]])
2D ndarray of binary descriptors of size descriptor_size for Q
keypoints after filtering out border keypoints with value at an
index (i, j)
either being True
or False
representing
the outcome of the intensity comparison for ith keypoint on jth
decision pixelpair. It is Q == np.sum(mask)
.
Mask indicating whether a keypoint has been filtered out
(False
) or is described in the descriptors array (True
).
CENSURE
¶skimage.feature.
CENSURE
(min_scale=1, max_scale=7, mode='DoB', non_max_threshold=0.15, line_threshold=10)[source]¶Bases: skimage.feature.util.FeatureDetector
CENSURE keypoint detector.
Minimum scale to extract keypoints from.
Maximum scale to extract keypoints from. The keypoints will be extracted from all the scales except the first and the last i.e. from the scales in the range [min_scale + 1, max_scale  1]. The filter sizes for different scales is such that the two adjacent scales comprise of an octave.
Type of bilevel filter used to get the scales of the input image. Possible values are ‘DoB’, ‘Octagon’ and ‘STAR’. The three modes represent the shape of the bilevel filters i.e. box(square), octagon and star respectively. For instance, a bilevel octagon filter consists of a smaller inner octagon and a larger outer octagon with the filter weights being uniformly negative in both the inner octagon while uniformly positive in the difference region. Use STAR and Octagon for better features and DoB for better performance.
Threshold value used to suppress maximas and minimas with a weak magnitude response obtained after NonMaximal Suppression.
Threshold for rejecting interest points which have ratio of principal curvatures greater than this value.
References
Motilal Agrawal, Kurt Konolige and Morten Rufus Blas “CENSURE: Center Surround Extremas for Realtime Feature Detection and Matching”, https://link.springer.com/chapter/10.1007/9783540886938_8 DOI:10.1007/9783540886938_8
Adam Schmidt, Marek Kraft, Michal Fularz and Zuzanna Domagala “Comparative Assessment of Point Feature Detectors and Descriptors in the Context of Robot Navigation” http://yadda.icm.edu.pl/yadda/element/bwmeta1.element.baztech268aaf280faf4872a4df7e2e61cb364c/c/Schmidt_comparative.pdf DOI:10.1.1.465.1117
Examples
>>> from skimage.data import astronaut
>>> from skimage.color import rgb2gray
>>> from skimage.feature import CENSURE
>>> img = rgb2gray(astronaut()[100:300, 100:300])
>>> censure = CENSURE()
>>> censure.detect(img)
>>> censure.keypoints
array([[ 4, 148],
[ 12, 73],
[ 21, 176],
[ 91, 22],
[ 93, 56],
[ 94, 22],
[ 95, 54],
[100, 51],
[103, 51],
[106, 67],
[108, 15],
[117, 20],
[122, 60],
[125, 37],
[129, 37],
[133, 76],
[145, 44],
[146, 94],
[150, 114],
[153, 33],
[154, 156],
[155, 151],
[184, 63]])
>>> censure.scales
array([2, 6, 6, 2, 4, 3, 2, 3, 2, 6, 3, 2, 2, 3, 2, 2, 2, 3, 2, 2, 4, 2, 2])
Keypoint coordinates as (row, col)
.
Corresponding scales.
ORB
¶skimage.feature.
ORB
(downscale=1.2, n_scales=8, n_keypoints=500, fast_n=9, fast_threshold=0.08, harris_k=0.04)[source]¶Bases: skimage.feature.util.FeatureDetector
, skimage.feature.util.DescriptorExtractor
Oriented FAST and rotated BRIEF feature detector and binary descriptor extractor.
Number of keypoints to be returned. The function will return the best n_keypoints according to the Harris corner response if more than n_keypoints are detected. If not, then all the detected keypoints are returned.
The n parameter in skimage.feature.corner_fast. Minimum number of
consecutive pixels out of 16 pixels on the circle that should all be
either brighter or darker w.r.t testpixel. A point c on the circle is
darker w.r.t test pixel p if Ic < Ip  threshold
and brighter if
Ic > Ip + threshold
. Also stands for the n in FASTn
corner
detector.
The threshold
parameter in feature.corner_fast
. Threshold used
to decide whether the pixels on the circle are brighter, darker or
similar w.r.t. the test pixel. Decrease the threshold when more
corners are desired and viceversa.
The k parameter in skimage.feature.corner_harris. Sensitivity
factor to separate corners from edges, typically in range [0, 0.2]
.
Small values of k result in detection of sharp corners.
Downscale factor for the image pyramid. Default value 1.2 is chosen so that there are more dense scales which enable robust scale invariance for a subsequent feature description.
Maximum number of scales from the bottom of the image pyramid to extract the features from.
References
Ethan Rublee, Vincent Rabaud, Kurt Konolige and Gary Bradski “ORB: An efficient alternative to SIFT and SURF” http://www.vision.cs.chubu.ac.jp/CVR/pdf/Rublee_iccv2011.pdf
Examples
>>> from skimage.feature import ORB, match_descriptors
>>> img1 = np.zeros((100, 100))
>>> img2 = np.zeros_like(img1)
>>> np.random.seed(1)
>>> square = np.random.rand(20, 20)
>>> img1[40:60, 40:60] = square
>>> img2[53:73, 53:73] = square
>>> detector_extractor1 = ORB(n_keypoints=5)
>>> detector_extractor2 = ORB(n_keypoints=5)
>>> detector_extractor1.detect_and_extract(img1)
>>> detector_extractor2.detect_and_extract(img2)
>>> matches = match_descriptors(detector_extractor1.descriptors,
... detector_extractor2.descriptors)
>>> matches
array([[0, 0],
[1, 1],
[2, 2],
[3, 3],
[4, 4]])
>>> detector_extractor1.keypoints[matches[:, 0]]
array([[ 42., 40.],
[ 47., 58.],
[ 44., 40.],
[ 59., 42.],
[ 45., 44.]])
>>> detector_extractor2.keypoints[matches[:, 1]]
array([[ 55., 53.],
[ 60., 71.],
[ 57., 53.],
[ 72., 55.],
[ 58., 57.]])
Keypoint coordinates as (row, col)
.
Corresponding scales.
Corresponding orientations in radians.
Corresponding Harris corner responses.
2D array of binary descriptors of size descriptor_size for Q
keypoints after filtering out border keypoints with value at an
index (i, j)
either being True
or False
representing
the outcome of the intensity comparison for ith keypoint on jth
decision pixelpair. It is Q == np.sum(mask)
.
__init__
(downscale=1.2, n_scales=8, n_keypoints=500, fast_n=9, fast_threshold=0.08, harris_k=0.04)[source]¶Initialize self. See help(type(self)) for accurate signature.
detect
(image)[source]¶Detect oriented FAST keypoints along with the corresponding scale.
Input image.
detect_and_extract
(image)[source]¶Detect oriented FAST keypoints and extract rBRIEF descriptors.
Note that this is faster than first calling detect and then extract.
Input image.
extract
(image, keypoints, scales, orientations)[source]¶Extract rBRIEF binary descriptors for given keypoints in image.
Note that the keypoints must be extracted using the same downscale and n_scales parameters. Additionally, if you want to extract both keypoints and descriptors you should use the faster detect_and_extract.
Input image.
Keypoint coordinates as (row, col)
.
Corresponding scales.
Corresponding orientations in radians.