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
rowandcolcomputing gradient histograms
normalizing across blocks
flattening into a feature vector
Parameters
image: (M, N[, C]) ndarrayInput image.
orientations: int, optionalNumber of orientation bins.
pixels_per_cell: 2-tuple (int, int), optionalSize (in pixels) of a cell.
cells_per_block: 2-tuple (int, int), optionalNumber of cells in each block.
block_norm: {'L1', 'L1-sqrt', 'L2', 'L2-Hys'}, optionalBlock normalization method:
L1Normalization using L1-norm.
L1-sqrtNormalization using L1-norm, followed by square root.
L2Normalization using L2-norm.
L2-HysNormalization using L2-norm, followed by limiting the maximum values to 0.2 (
Hysstands forhysteresis) and renormalization using L2-norm. (default) For details, see [3], [4].
visualize: bool, optionalAlso 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, optionalApply power law compression to normalize the image before processing. DO NOT use this if the image contains negative values. Also see
notessection below.feature_vector: bool, optionalReturn the data as a feature vector by calling .ravel() on the result just before returning.
channel_axis: int or None, optionalIf 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) ndarrayHOG descriptor for the image. If
feature_vectoris True, a 1D (flattened) array is returned.hog_image: (M, N) ndarray, optionalA visualisation of the HOG image. Only provided if
visualizeis True.
Raises
: ValueErrorIf 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