skimage 0.17.2

NotesParametersReturns
hog(image, orientations=9, pixels_per_cell=(8, 8), cells_per_block=(3, 3), block_norm='L2-Hys', visualize=False, transform_sqrt=False, feature_vector=True, multichannel=None)

Compute a Histogram of Oriented Gradients (HOG) by

  1. (optional) global image normalization

  2. computing the gradient image in row and :None:None:`col`

  3. computing gradient histograms

  4. normalizing across blocks

  5. flattening into a feature vector

Notes

The presented code implements the HOG extraction method from 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 (L2-Hys 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 :None:None:`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.

Parameters

image : (M, N[, C]) ndarray

Input image.

orientations : int, optional

Number of orientation bins.

pixels_per_cell : 2-tuple (int, int), optional

Size (in pixels) of a cell.

cells_per_block : 2-tuple (int, int), optional

Number of cells in each block.

block_norm : str {'L1', 'L1-sqrt', 'L2', 'L2-Hys'}, optional

Block normalization method:

L1

Normalization using L1-norm.

L1-sqrt

Normalization using L1-norm, followed by square root.

L2

Normalization using L2-norm.

L2-Hys

Normalization using L2-norm, followed by limiting the maximum values to 0.2 (:None:None:`Hys` stands for hysteresis ) and renormalization using L2-norm. (default) For details, see , .

visualize : bool, optional

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.

transform_sqrt : bool, optional

Apply power law compression to normalize the image before processing. DO NOT use this if the image contains negative values. Also see :None:None:`notes` section below.

feature_vector : bool, optional

Return the data as a feature vector by calling .ravel() on the result just before returning.

multichannel : boolean, optional

If True, the last :None:None:`image` dimension is considered as a color channel, otherwise as spatial.

Returns

out : (n_blocks_row, n_blocks_col, n_cells_row, n_cells_col, n_orient) ndarray

HOG descriptor for the image. If :None:None:`feature_vector` is True, a 1D (flattened) array is returned.

hog_image : (M, N) ndarray, optional

A visualisation of the HOG image. Only provided if :None:None:`visualize` is True.

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

Examples

See :

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/_hog.py#46
type: <class 'function'>
Commit: