skimage 0.17.2

NotesParametersReturnsBackRef
haar_like_feature(int_image, r, c, width, height, feature_type=None, feature_coord=None)

Haar-like features have been successfully used for image classification and object detection . It has been used for real-time face detection algorithm proposed in .

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 sphx_glr_auto_examples_applications_plot_haar_extraction_selection_classification.py for more insights.

Parameters

int_image : (M, N) ndarray

Integral image for which the features need to be computed.

r : int

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

c : int

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

width : int

Width of the detection window.

height : int

Height of the detection window.

feature_type : str 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.

If using with :None:None:`feature_coord`, it should correspond to the feature type of each associated coordinate feature.

feature_coord : ndarray 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.

Returns

haar_features : (n_features,) ndarray of int or float

Resulting Haar-like 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 :None:None:`int_image`: :None:None:`int` when the data type of :None:None:`int_image` is uint or :None:None:`int` and :None:None:`float` when the data type of :None:None:`int_image` is :None:None:`float`.

Compute the Haar-like features for a region of interest (ROI) of an integral image.

Examples

This example is valid syntax, but we were not able to check execution
>>> 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, 'type-3-x')
... 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 pre-computed coordinates.

This example is valid syntax, but we were not able to check execution
>>> 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 ('type-2-x', 'type-3-x')])
... # 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])
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

skimage.feature.haar.haar_like_feature

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /skimage/feature/haar.py#87
type: <class 'function'>
Commit: