{ } Raw JSON

bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / feature / _hog / hog

function

skimage.feature._hog:hog

source: /dev/scikit-image/src/skimage/feature/_hog.py :48

Signature

def   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 * channel_axis = None )

Summary

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

Extended Summary

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

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 : {'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 (Hys stands for hysteresis) and renormalization using L2-norm. (default) For details, see [3], [4].

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 notes section below.

feature_vector : bool, optional

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

channel_axis : int or None, optional

If None, the image is assumed to be a grayscale (single channel) image. Otherwise, this parameter indicates which axis of the array corresponds to channels.

Returns

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

HOG descriptor for the image. If 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 visualize is True.

Raises

: ValueError

If the image is too small given the values of pixels_per_cell and cells_per_block.

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 (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 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.

Aliases

  • skimage.feature.hog

Referenced by