feature_extractor.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:cv-utils 作者: gmichaeljaison 项目源码 文件源码
def hog(img, options=None):
    """
    HOG feature extractor.

    :param img:
    :param options:
    :return: HOG Feature for given image
        The output will have channels same as number of orientations.
        Height and Width will be reduced based on block-size and cell-size
    """
    op = _DEF_HOG_OPTS.copy()
    if options is not None:
        op.update(options)

    img = gray(img)
    img_fd = skimage.feature.hog(img,
                                 orientations=op['orientations'],
                                 pixels_per_cell=op['cell_size'],
                                 cells_per_block=op['block_size'],
                                 visualise=False)
    h, w = img.shape

    cx, cy = op['cell_size']
    n_cellsx, n_cellsy = w // cx, h // cy

    bx, by = op['block_size']
    n_blksx, n_blksy = (n_cellsx - bx) + 1, (n_cellsy - by) + 1

    hog_shape = n_blksy * by, n_blksx * bx, op['orientations']

    image_hog = np.reshape(img_fd, hog_shape)
    return image_hog
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号