函数定义:
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, *, channel_axis=None)
参数解释:
通过以下方式计算定向梯度 (HOG) 的直方图
1.(可选)全局图像归一化
2. 计算row
和col
中的梯度图像
3. 计算梯度直方图
4. 跨块标准化
5. 展平成特征向量
image:(M,N [,C]) ndarray 输入图像(灰度)。
orientations:int,可选方向箱的数量。
pixels_per_cell:2元组(int,int),可选的单元格大小(以像素为单位)。
cells_per_block:2元组(int,int),可选每个块中的单元格数。
block_norm:str {‘L1’,‘L1-sqrt’,‘L2’,‘L2-Hys’},可选
块归一化方法:
L1
:使用 L1 范数进行归一化。
L1-sqrt
:使用 L1 范数进行归一化,然后是平方根。
L2
:使用 L2 范数进行归一化。
L2-Hys
:使用 L2 范数进行归一化,然后限制最大值为 0.2(Hys
代表滞后
)和使用 L2 范数进行重整化。 (默认)
visualize:bool,可选
同时返回 HOG 的图像。对于每个单元格和方向箱,图像包含以单元格中心为中心的线段,垂直于所跨越的角度范围的中点方向箱,并具有与相应的强度成比例的直方图值。
transform_sqrt :bool,可选
应用幂律压缩来规范化图像之前加工。如果图像包含负片,请勿使用此选项价值观。另请参阅下面的“注释”部分。
feature_vector:bool,可选
通过对结果调用 .ravel() 将数据作为特征向量返回就在返回之前。
multichannel:bool,可选
如果为 True,则最后一个“图像”维度被视为颜色通道,
否则作为空间。此参数已弃用:指定channel_axis
代替。
channel_axis :int或None,可选
如果为 None,则假定图像是灰度(单通道)图像。
否则,该参数表示数组的哪个轴对应到频道。
skimage库中函数定义
Extract Histogram of Oriented Gradients (HOG) for a given image.
Compute a Histogram of Oriented Gradients (HOG) by
1. (optional) global image normalization
2. computing the gradient image in `row` and `col`
3. computing gradient histograms
4. normalizing across blocks
5. 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 : 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 (`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.
multichannel : boolean, optional
If True, the last `image` dimension is considered as a color channel,
otherwise as spatial. This argument is deprecated: specify
`channel_axis` instead.
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.
.. versionadded:: 0.19
`channel_axis` was added in 0.19.
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.