我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用skimage.feature()。
def factory(feature): """ Factory to choose feature extractor :param feature: name of the feature :return: Feature extractor function """ if feature == 'hog': return hog elif feature == 'deep': return deep elif feature == 'gray': return gray elif feature == 'lab': return lab elif feature == 'luv': return luv elif feature == 'hsv': return hsv elif feature == 'hls': return hls else: return rgb
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