当前位置: 首页>>代码示例>>Python>>正文


Python skimage.feature方法代码示例

本文整理汇总了Python中skimage.feature方法的典型用法代码示例。如果您正苦于以下问题:Python skimage.feature方法的具体用法?Python skimage.feature怎么用?Python skimage.feature使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在skimage的用法示例。


在下文中一共展示了skimage.feature方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: compute_hog

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import feature [as 别名]
def compute_hog(depc, cid_list, config=None):
    """
    Doctest:
        >>> from ibeis.core_annots import *  # NOQA
        >>> ibs, depc, aid_list = testdata_core()
        >>> chip_config = {}
        >>> config = HOGConfig()
        >>> cid_list = depc.get_rowids('chips', aid_list, config=chip_config)
        >>> hoggen = compute_hog(depc, cid_list, config)
        >>> hog = list(hoggen)[0]
        >>> ut.quit_if_noshow()
        >>> import plottool_ibeis as pt
        >>> hog_image = make_hog_block_image(hog, config)
        >>> ut.show_if_requested()
    """
    import skimage.feature
    orientations = config['orientations']

    ut.assert_all_not_None(cid_list, 'cid_list')
    chip_fpath_list = depc.get_native(
        'chips', cid_list, 'img', read_extern=False)

    for chip_fpath in chip_fpath_list:
        chip = vt.imread(chip_fpath, grayscale=True) / 255.0
        hog = skimage.feature.hog(chip, feature_vector=False,
                                  orientations=orientations,
                                  pixels_per_cell=(16, 16), cells_per_block=(1, 1))
        yield (hog,) 
开发者ID:Erotemic,项目名称:ibeis,代码行数:30,代码来源:core_annots.py

示例2: _calculate

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import feature [as 别名]
def _calculate(self):
        instance = np.zeros((self.dataset_size, self.HOG_DIM))
        for i, info in enumerate(self.dataset.get_all_images(cropped=True)):
            img = caffe.io.load_image(info['img_file'])
            img_g = skimage.color.rgb2gray(img)
            img_r = skimage.transform.resize(img_g, self.HOG_RESIZE)

            instance[i, :] = skimage.feature.hog(img_r, orientations=9, pixels_per_cell=(8, 8), cells_per_block=(2, 2))
        return instance 
开发者ID:yassersouri,项目名称:omgh,代码行数:11,代码来源:cub_utils.py

示例3: __init__

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import feature [as 别名]
def __init__(self, feature, blob_object, **blob_parameters):
        self.feature = self._parse_features(feature, default_feature_type=FeatureType.DATA, new_names=True,
                                            rename_function='{}_BLOB'.format)

        self.blob_object = blob_object
        self.blob_parameters = blob_parameters 
开发者ID:sentinel-hub,项目名称:eo-learn,代码行数:8,代码来源:blob.py

示例4: execute

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import feature [as 别名]
def execute(self, eopatch):
        """ Execute computation of blobs on input eopatch

        :param eopatch: Input eopatch
        :type eopatch: eolearn.core.EOPatch
        :return: EOPatch instance with new key holding the blob image.
        :rtype: eolearn.core.EOPatch
        """
        for feature_type, feature_name, new_feature_name in self.feature:
            eopatch[feature_type][new_feature_name] = self._compute_blob(
                eopatch[feature_type][feature_name].astype(np.float64)).astype(np.float32)

        return eopatch 
开发者ID:sentinel-hub,项目名称:eo-learn,代码行数:15,代码来源:blob.py

示例5: _compute_hog

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import feature [as 别名]
def _compute_hog(self, data):
        results_im = np.empty((data.shape[0],
                               (int(data.shape[1] // self.pixels_per_cell[0]) - self.cells_per_block[0] + 1) *
                               self.cells_per_block[0],
                               (int(data.shape[2] // self.pixels_per_cell[1]) - self.cells_per_block[1] + 1) *
                               self.cells_per_block[1], self.n_orientations), dtype=np.float)
        if self.visualize:
            im_visu = np.empty(data.shape[0:3] + (1,))
        for time in range(data.shape[0]):
            multi_channel = data.shape[-1] != 1
            image = data[time] if multi_channel else data[time, :, :, 0]
            res, image = skimage.feature.hog(image, orientations=self.n_orientations,
                                             pixels_per_cell=self.pixels_per_cell, visualize=self.visualize,
                                             cells_per_block=self.cells_per_block, block_norm=self.block_norm,
                                             feature_vector=self.hog_feature_vector, multichannel=multi_channel)
            if self.visualize:
                im_visu[time, :, :, 0] = image
            for block_row in range(res.shape[0]):
                for block_col in range(res.shape[1]):
                    for cell_row in range(res.shape[2]):
                        for cell_col in range(res.shape[3]):
                            row = block_row * self.cells_per_block[0] + cell_row
                            col = block_col * self.cells_per_block[1] + cell_col
                            for angle in range(res.shape[4]):
                                results_im[time, row, col, angle] = res[block_row, block_col, cell_row, cell_col, angle]
        return results_im, im_visu 
开发者ID:sentinel-hub,项目名称:eo-learn,代码行数:28,代码来源:hog.py

示例6: execute

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import feature [as 别名]
def execute(self, eopatch):
        """ Execute computation of HoG features on input eopatch

            :param eopatch: Input eopatch
            :type eopatch: eolearn.core.EOPatch
            :return: EOPatch instance with new keys holding the HoG features and HoG image for visualisation.
            :rtype: eolearn.core.EOPatch
        """
        for feature_type, feature_name, new_feature_name in self.feature:
            result = self._compute_hog(eopatch[feature_type][feature_name])
            eopatch[feature_type][new_feature_name] = result[0]
            if self.visualize:
                eopatch[feature_type][self.visualize_name] = result[1]

        return eopatch 
开发者ID:sentinel-hub,项目名称:eo-learn,代码行数:17,代码来源:hog.py

示例7: __init__

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import feature [as 别名]
def __init__(self, feature, nb_points=24, radius=3):

        self.feature = self._parse_features(feature, default_feature_type=FeatureType.DATA, new_names=True,
                                            rename_function='{}_LBP'.format)

        self.nb_points = nb_points
        self.radius = radius
        if nb_points < 1 or radius < 1:
            raise ValueError('Local binary pattern task parameters must be positives') 
开发者ID:sentinel-hub,项目名称:eo-learn,代码行数:11,代码来源:local_binary_pattern.py

示例8: _compute_lbp

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import feature [as 别名]
def _compute_lbp(self, data):
        result = np.empty(data.shape, dtype=np.float)
        for time in range(data.shape[0]):
            for band in range(data.shape[-1]):
                image = data[time, :, :, band]
                result[time, :, :, band] = skimage.feature.local_binary_pattern(image, self.nb_points, self.radius,
                                                                                method='uniform')
        return result 
开发者ID:sentinel-hub,项目名称:eo-learn,代码行数:10,代码来源:local_binary_pattern.py

示例9: execute

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import feature [as 别名]
def execute(self, eopatch):
        """ Execute computation of local binary patterns on input eopatch

            :param eopatch: Input eopatch
            :type eopatch: eolearn.core.EOPatch
            :return: EOPatch instance with new key holding the LBP image.
            :rtype: eolearn.core.EOPatch
        """
        for feature_type, feature_name, new_feature_name in self.feature:
            eopatch[feature_type][new_feature_name] = self._compute_lbp(eopatch[feature_type][feature_name])

        return eopatch 
开发者ID:sentinel-hub,项目名称:eo-learn,代码行数:14,代码来源:local_binary_pattern.py

示例10: _calculate_haralick

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import feature [as 别名]
def _calculate_haralick(self, data):
        result = np.empty(data.shape, dtype=np.float)
        # For each date and each band
        for time in range(data.shape[0]):
            for band in range(data.shape[3]):
                image = data[time, :, :, band]
                image_min, image_max = np.min(image), np.max(image)
                coef = (image_max - image_min) / self.levels
                digitized_image = np.digitize(image, np.array([image_min + k * coef for k in range(self.levels - 1)]))

                # Padding the image to handle borders
                pad = self.window_size // 2
                digitized_image = np.pad(digitized_image, ((pad, pad), (pad, pad)), 'edge')
                # Sliding window
                for i in range(0, image.shape[0], self.stride):
                    for j in range(0, image.shape[1], self.stride):
                        window = digitized_image[i: i + self.window_size, j: j + self.window_size]
                        glcm = skimage.feature.greycomatrix(window, [self.distance], [self.angle], levels=self.levels,
                                                            normed=True, symmetric=True)

                        if self.texture_feature in self.AVAILABLE_TEXTURES_SKIMAGE:
                            res = skimage.feature.greycoprops(glcm, self.texture_feature)[0][0]
                        else:
                            res = self._custom_texture(glcm[:, :, 0, 0])

                        result[time, i, j, band] = res
        return result 
开发者ID:sentinel-hub,项目名称:eo-learn,代码行数:29,代码来源:haralick.py

示例11: execute

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import feature [as 别名]
def execute(self, eopatch):

        for feature_type, feature_name, new_feature_name in self.feature:
            eopatch[feature_type][new_feature_name] = self._calculate_haralick(eopatch[feature_type][feature_name])

        return eopatch 
开发者ID:sentinel-hub,项目名称:eo-learn,代码行数:8,代码来源:haralick.py

示例12: getGray

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import feature [as 别名]
def getGray(img, hueValue=63, threshold=0):
    """Returns the grayscale of the source image with its background
    removed as a 1D feature vector."""

    img = removeBackground(img, hueValue, threshold)

    img = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY).astype(np.float32) / 255

    return img.ravel() 
开发者ID:DrGFreeman,项目名称:rps-cv,代码行数:11,代码来源:imgproc.py

示例13: _init_coords

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import feature [as 别名]
def _init_coords(self):
    logging.info('peaks: starting')

    # Edge detection.
    edges = ndimage.generic_gradient_magnitude(
        self.canvas.image.astype(np.float32),
        ndimage.sobel)

    # Adaptive thresholding.
    sigma = 49.0 / 6.0
    thresh_image = np.zeros(edges.shape, dtype=np.float32)
    ndimage.gaussian_filter(edges, sigma, output=thresh_image, mode='reflect')
    filt_edges = edges > thresh_image

    del edges, thresh_image

    # This prevents a border effect where the large amount of masked area
    # screws up the distance transform below.
    if (self.canvas.restrictor is not None and
        self.canvas.restrictor.mask is not None):
      filt_edges[self.canvas.restrictor.mask] = 1

    logging.info('peaks: filtering done')
    dt = ndimage.distance_transform_edt(1 - filt_edges).astype(np.float32)
    logging.info('peaks: edt done')

    # Use a specifc seed for the noise so that results are reproducible
    # regardless of what happens before the policy is called.
    state = np.random.get_state()
    np.random.seed(42)
    idxs = skimage.feature.peak_local_max(
        dt + np.random.random(dt.shape) * 1e-4,
        indices=True, min_distance=3, threshold_abs=0, threshold_rel=0)
    np.random.set_state(state)

    # After skimage upgrade to 0.13.0 peak_local_max returns peaks in
    # descending order, versus ascending order previously.  Sort ascending to
    # maintain historic behavior.
    idxs = np.array(sorted((z, y, x) for z, y, x in idxs))

    logging.info('peaks: found %d local maxima', idxs.shape[0])
    self.coords = idxs 
开发者ID:google,项目名称:ffn,代码行数:44,代码来源:seed.py

示例14: make_hog_block_image

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import feature [as 别名]
def make_hog_block_image(hog, config=None):
    """
    References:
        https://github.com/scikit-image/scikit-image/blob/master/skimage/feature/_hog.py
    """
    from skimage import draw

    if config is None:
        config = HOGConfig()

    cx, cy = config['pixels_per_cell']

    normalised_blocks = hog
    (n_blocksy, n_blocksx, by, bx, orientations) = normalised_blocks.shape

    n_cellsx = (n_blocksx - 1) + bx
    n_cellsy = (n_blocksy - 1) + by

    # Undo the normalization step
    orientation_histogram = np.zeros((n_cellsy, n_cellsx, orientations))

    for x in range(n_blocksx):
        for y in range(n_blocksy):
            norm_block = normalised_blocks[y, x, :]
            # hack, this only works right for block sizes of 1
            orientation_histogram[y:y + by, x:x + bx, :] = norm_block

    sx = n_cellsx * cx
    sy = n_cellsy * cy

    radius = min(cx, cy) // 2 - 1
    orientations_arr = np.arange(orientations)
    dx_arr = radius * np.cos(orientations_arr / orientations * np.pi)
    dy_arr = radius * np.sin(orientations_arr / orientations * np.pi)
    hog_image = np.zeros((sy, sx), dtype=float)
    for x in range(n_cellsx):
        for y in range(n_cellsy):
            for o, dx, dy in zip(orientations_arr, dx_arr, dy_arr):
                centre = tuple([y * cy + cy // 2, x * cx + cx // 2])
                rr, cc = draw.line(int(centre[0] - dx),
                                   int(centre[1] + dy),
                                   int(centre[0] + dx),
                                   int(centre[1] - dy))
                hog_image[rr, cc] += orientation_histogram[y, x, o]
    return hog_image 
开发者ID:Erotemic,项目名称:ibeis,代码行数:47,代码来源:core_annots.py


注:本文中的skimage.feature方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。