neulab/docprompting-conala huggingface dataset:
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 bag-of-features 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.   Parameters 
 
image(M, N) array 

Input image (grayscale).  
stepint, optional 

Distance between descriptor sampling points.  
radiusint, optional 

Radius (in pixels) of the outermost ring.  
ringsint, optional 

Number of rings.  
histogramsint, optional 

Number of histograms sampled per ring.  
orientationsint, optional 

Number of orientations (bins) per histogram.  
normalization[ ‘l1’ | ‘l2’ | ‘daisy’ | ‘off’ ], optional 

How to normalize the descriptors  ‘l1’: L1-normalization of each descriptor. ‘l2’: L2-normalization of each descriptor. ‘daisy’: L2-normalization of individual histograms. ‘off’: Disable normalization.   
sigmas1D array of float, optional 

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  
ring_radii1D array of int, optional 

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  
visualizebool, optional 

Generate a visualization of the DAISY descriptors    Returns 
 
descsarray 

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  
descs_img(M, N, 3) array (only if visualize==True) 

Visualization of the DAISY descriptors.     References  
1(1,2)  
Tola et al. “Daisy: An efficient dense descriptor applied to wide- baseline stereo.” Pattern Analysis and Machine Intelligence, IEEE Transactions on 32.5 (2010): 815-830.  
2  
http://cvlab.epfl.ch/software/daisy
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 Haar-like features.  Parameters 
 
image(M, N) ndarray 

The region of an integral image for which the features need to be computed.  
rint 

Row-coordinate of top left corner of the detection window.  
cint 

Column-coordinate of top left corner of the detection window.  
widthint 

Width of the detection window.  
heightint 

Height of the detection window.  
feature_coordndarray of list of tuples or None, optional 

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.  
color_positive_rectangletuple of 3 floats 

Floats specifying the color for the positive block. Corresponding values define (R, G, B) values. Default value is red (1, 0, 0).  
color_negative_blocktuple of 3 floats 

Floats specifying the color for the negative block Corresponding values define (R, G, B) values. Default value is blue (0, 1, 0).  
alphafloat 

Value in the range [0, 1] that specifies opacity of visualization. 1 - fully transparent, 0 - opaque.  
max_n_featuresint, default=None 

The maximum number of features to be returned. By default, all features are returned.  
random_stateint, RandomState instance or None, optional 

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.    Returns 
 
features(M, N), ndarray 

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, 'type-4')
>>> 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. ]],

       [[0.5, 0. , 0. ],
        [0. , 0.5, 0. ]]])
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]
 
Multi-block local binary pattern visualization. Blocks with higher sums are colored with alpha-blended white rectangles, whereas blocks with lower sums are colored alpha-blended cyan. Colors and the alpha parameter can be changed.  Parameters 
 
imagendarray of float or uint 

Image on which to visualize the pattern.  
rint 

Row-coordinate of top left corner of a rectangle containing feature.  
cint 

Column-coordinate of top left corner of a rectangle containing feature.  
widthint 

Width of one of 9 equal rectangles that will be used to compute a feature.  
heightint 

Height of one of 9 equal rectangles that will be used to compute a feature.  
lbp_codeint 

The descriptor of feature to visualize. If not provided, the descriptor with 0 value will be used.  
color_greater_blocktuple of 3 floats 

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).  
color_greater_blocktuple of 3 floats 

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).  
alphafloat 

Value in the range [0, 1] that specifies opacity of visualization. 1 - fully transparent, 0 - opaque.    Returns 
 
outputndarray of float 

Image with MB-LBP visualization.     References  
1  
Face Detection Based on Multi-Block LBP Representation. Lun Zhang, Rufeng Chu, Shiming Xiang, Shengcai Liao, Stan Z. Li http://www.cbsr.ia.ac.cn/users/scliao/papers/Zhang-ICB07-MBLBP.pdf
skimage.feature.greycomatrix(image, distances, angles, levels=None, symmetric=False, normed=False) [source]
 
Calculate the grey-level co-occurrence matrix. A grey level co-occurrence matrix is a histogram of co-occurring greyscale values at a given offset over an image.  Parameters 
 
imagearray_like 

Integer typed input image. Only positive valued images are supported. If type is other than uint8, the argument levels needs to be set.  
distancesarray_like 

List of pixel pair distance offsets.  
anglesarray_like 

List of pixel pair angles in radians.  
levelsint, optional 

The input image should contain integers in [0, levels-1], where levels indicate the number of grey-levels counted (typically 256 for an 8-bit image). This argument is required for 16-bit 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.  
symmetricbool, optional 

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.  
normedbool, optional 

If True, normalize each matrix P[:, :, d, theta] by dividing by the total number of accumulated co-occurrences for the given offset. The elements of the resulting matrix sum to 1. The default is False.    Returns 
 
P4-D ndarray 

The grey-level co-occurrence histogram. The value P[i,j,d,theta] is the number of times that grey-level j occurs at a distance d and at an angle theta from grey-level 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  
1  
The GLCM Tutorial Home Page, http://www.fp.ucalgary.ca/mhallbey/tutorial.htm  
2  
Haralick, RM.; Shanmugam, K., “Textural features for image classification” IEEE Transactions on systems, man, and cybernetics 6 (1973): 610-621. DOI:10.1109/TSMC.1973.4309314  
3  
Pattern Recognition Engineering, Morton Nadler & Eric P. Smith  
4  
Wikipedia, https://en.wikipedia.org/wiki/Co-occurrence_matrix   Examples Compute 2 GLCMs: One for a 1-pixel offset to the right, and one for a 1-pixel 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.greycoprops(P, prop='contrast') [source]
 
Calculate texture properties of a GLCM. Compute a feature of a grey level co-occurrence matrix to serve as a compact summary of the matrix. The properties are computed as follows:  ‘contrast’: \(\sum_{i,j=0}^{levels-1} P_{i,j}(i-j)^2\)
 ‘dissimilarity’: \(\sum_{i,j=0}^{levels-1}P_{i,j}|i-j|\)
 ‘homogeneity’: \(\sum_{i,j=0}^{levels-1}\frac{P_{i,j}}{1+(i-j)^2}\)
 ‘ASM’: \(\sum_{i,j=0}^{levels-1} P_{i,j}^2\)
 ‘energy’: \(\sqrt{ASM}\)
 
 ‘correlation’:

 \[\sum_{i,j=0}^{levels-1} P_{i,j}\left[\frac{(i-\mu_i) \ (j-\mu_j)}{\sqrt{(\sigma_i^2)(\sigma_j^2)}}\right]\]     Each GLCM is normalized to have a sum of 1 before the computation of texture properties.  Parameters 
 
Pndarray 

Input array. P is the grey-level co-occurrence histogram for which to compute the specified property. The value P[i,j,d,theta] is the number of times that grey-level j occurs at a distance d and at an angle theta from grey-level i.  
prop{‘contrast’, ‘dissimilarity’, ‘homogeneity’, ‘energy’, ‘correlation’, ‘ASM’}, optional 

The property of the GLCM to compute. The default is ‘contrast’.    Returns 
 
results2-D ndarray 

2-dimensional array. results[d, a] is the property ‘prop’ for the d’th distance and the a’th angle.     References  
1  
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.haar_like_feature_coord(width, height, feature_type=None) [source]
 
Compute the coordinates of Haar-like features.  Parameters 
 
widthint 

Width of the detection window.  
heightint 

Height of the detection window.  
feature_typestr or list of str or None, optional 

The type of feature to consider:  ‘type-2-x’: 2 rectangles varying along the x axis; ‘type-2-y’: 2 rectangles varying along the y axis; ‘type-3-x’: 3 rectangles varying along the x axis; ‘type-3-y’: 3 rectangles varying along the y axis; ‘type-4’: 4 rectangles varying along x and y axis.  By default all features are extracted.    Returns 
 
feature_coord(n_features, n_rectangles, 2, 2), ndarray of list of tuple coord 

Coordinates of the rectangles for each feature.  
feature_type(n_features,), ndarray of str 

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, 'type-4')
>>> feat_coord 
array([ list([[(0, 0), (0, 0)], [(0, 1), (0, 1)],
              [(1, 1), (1, 1)], [(1, 0), (1, 0)]])], dtype=object)
>>> feat_type
array(['type-4'], dtype=object)
skimage.feature.hessian_matrix(image, sigma=1, mode='constant', cval=0, order='rc') [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 r- and c-directions.  Parameters 
 
imagendarray 

Input image.  
sigmafloat 

Standard deviation used for the Gaussian kernel, which is used as weighting function for the auto-correlation matrix.  
mode{‘constant’, ‘reflect’, ‘wrap’, ‘nearest’, ‘mirror’}, optional 

How to handle values outside the image borders.  
cvalfloat, optional 

Used in conjunction with mode ‘constant’, the value outside the image boundaries.  
order{‘rc’, ‘xy’}, optional 

This parameter allows for the use of reverse or forward order of the image axes in gradient computation. ‘rc’ indicates the use of the first axis initially (Hrr, Hrc, Hcc), whilst ‘xy’ indicates the usage of the last axis initially (Hxx, Hxy, Hyy)    Returns 
 
Hrrndarray 

Element of the Hessian matrix for each pixel in the input image.  
Hrcndarray 

Element of the Hessian matrix for each pixel in the input image.  
Hccndarray 

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].  Parameters 
 
imagearray 

The image over which to compute Hessian Determinant.  
sigmafloat, optional 

Standard deviation used for the Gaussian kernel, used for the Hessian matrix.  
approximatebool, optional 

If True and the image is 2D, use a much faster approximate computation. This argument has no effect on 3D and higher images.    Returns 
 
outarray 

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  
1  
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) [source]
 
Compute eigenvalues of Hessian matrix.  Parameters 
 
H_elemslist of ndarray 

The upper-diagonal elements of the Hessian matrix, as returned by hessian_matrix.    Returns 
 
eigsndarray 

The eigenvalues of the Hessian matrix, in decreasing order. The eigenvalues are the leading dimension. That is, eigs[i, j, k] contains the ith-largest 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.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.  Parameters 
 
image(N, M) array 

Graylevel image.  
Pint 

Number of circularly symmetric neighbour set points (quantization of the angular space).  
Rfloat 

Radius of circle (spatial resolution of the operator).  
method{‘default’, ‘ror’, ‘uniform’, ‘var’} 

Method to determine the pattern.  
 ‘default’: original local binary pattern which is gray scale but not

rotation invariant.    
 ‘ror’: extension of default implementation which is gray scale and

rotation invariant.    
 ‘uniform’: improved rotation invariance with uniform patterns and

finer quantization of the angular space which is gray scale and rotation invariant.    
 ‘nri_uniform’: non rotation-invariant uniform patterns variant

which is only gray scale invariant [2].    
 ‘var’: rotation invariant variance measures of the contrast of local

image texture which is rotation but not gray scale invariant.        Returns 
 
output(N, M) array 

LBP image.     References  
1  
Multiresolution Gray-Scale 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.  
2  
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.masked_register_translation(src_image, target_image, src_mask, target_mask=None, overlap_ratio=0.3) [source]
 
Deprecated function. Use skimage.registration.phase_cross_correlation instead.
skimage.feature.match_descriptors(descriptors1, descriptors2, metric=None, p=2, max_distance=inf, cross_check=True, max_ratio=1.0) [source]
 
Brute-force matching of descriptors. For each descriptor in the first set this matcher finds the closest descriptor in the second set (and vice-versa in the case of enabled cross-checking).  Parameters 
 
descriptors1(M, P) array 

Descriptors of size P about M keypoints in the first image.  
descriptors2(N, P) array 

Descriptors of size P about N keypoints in the second image.  
metric{‘euclidean’, ‘cityblock’, ‘minkowski’, ‘hamming’, …} , optional 

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 L2-norm is used for all descriptors of dtype float or double and the Hamming distance is used for binary descriptors automatically.  
pint, optional 

The p-norm to apply for metric='minkowski'.  
max_distancefloat, optional 

Maximum allowed distance between descriptors of two keypoints in separate images to be regarded as a match.  
cross_checkbool, optional 

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.  
max_ratiofloat, optional 

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 Scale-Invariant Keypoints”, International Journal of Computer Vision, 2004.    Returns 
 
matches(Q, 2) array 

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.match_template(image, template, pad_input=False, mode='constant', constant_values=0) [source]
 
Match a template to a 2-D or 3-D 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 top-left corner of the template. To find the best match you must search for peaks in the response (output) image.  Parameters 
 
image(M, N[, D]) array 

2-D or 3-D input image.  
template(m, n[, d]) array 

Template to locate. It must be (m <= M, n <= N[, d <= D]).  
pad_inputbool 

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 (top-left corner) of the template.  
modesee numpy.pad, optional 

Padding mode.  
constant_valuessee numpy.pad, optional 

Constant values used in conjunction with mode='constant'.    Returns 
 
outputarray 

Response image with correlation coefficients.     Notes Details on the cross-correlation 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  
1  
J. P. Lewis, “Fast Normalized Cross-Correlation”, Industrial Light and Magic.  
2  
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]])