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


Python segmentation.felzenszwalb方法代码示例

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


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

示例1: felzenszwalb

# 需要导入模块: from skimage import segmentation [as 别名]
# 或者: from skimage.segmentation import felzenszwalb [as 别名]
def felzenszwalb(image, scale=SCALE, sigma=SIGMA, min_size=MIN_SIZE):
    """Computes Felsenszwalb's efficient graph based image segmentation.

    Args:
        image: The image.
        scale: Float indicating largeness of clusters (optional).
        sigma: Width of Gaussian kernel used in preprocessing (optional).
        min_size: Minimum component size. Enforced using postprocessing
          (optional).

    Returns:
        Integer mask indicating segment labels.
    """

    image = tf.cast(image, tf.uint8)

    def _felzenszwalb(image):
        segmentation = skimage_felzenszwalb(image, scale, sigma, min_size)
        return segmentation.astype(np.int32)

    return tf.py_func(_felzenszwalb, [image], tf.int32, stateful=False,
                      name='felzenszwalb') 
开发者ID:rusty1s,项目名称:graph-based-image-classification,代码行数:24,代码来源:felzenszwalb.py

示例2: segment_image

# 需要导入模块: from skimage import segmentation [as 别名]
# 或者: from skimage.segmentation import felzenszwalb [as 别名]
def segment_image(im, parameter_object):

    dims, rows, cols = im.shape

    image2segment = np.dstack((rescale_intensity(im[0],
                                                 in_range=(parameter_object.image_min,
                                                           parameter_object.image_max),
                                                 out_range=(0, 255)),
                               rescale_intensity(im[1],
                                                 in_range=(parameter_object.image_min,
                                                           parameter_object.image_max),
                                                 out_range=(0, 255)),
                               rescale_intensity(im[2],
                                                 in_range=(parameter_object.image_min,
                                                           parameter_object.image_max),
                                                 out_range=(0, 255))))

    felzer = felzenszwalb(np.uint8(image2segment),
                          scale=50,
                          sigma=.01,
                          min_size=5,
                          multichannel=True).reshape(rows, cols)

    props = regionprops(felzer)
    props = np.array([p.area for p in props], dtype='uint64')

    return fill_labels(np.uint64(felzer), props) 
开发者ID:jgrss,项目名称:spfeas,代码行数:29,代码来源:spfunctions.py

示例3: create_patches

# 需要导入模块: from skimage import segmentation [as 别名]
# 或者: from skimage.segmentation import felzenszwalb [as 别名]
def create_patches(self, method='slic', discovery_images=None,
                     param_dict=None):
    """Creates a set of image patches using superpixel methods.

    This method takes in the concept discovery images and transforms it to a
    dataset made of the patches of those images.

    Args:
      method: The superpixel method used for creating image patches. One of
        'slic', 'watershed', 'quickshift', 'felzenszwalb'.
      discovery_images: Images used for creating patches. If None, the images in
        the target class folder are used.

      param_dict: Contains parameters of the superpixel method used in the form
                of {'param1':[a,b,...], 'param2':[z,y,x,...], ...}. For instance
                {'n_segments':[15,50,80], 'compactness':[10,10,10]} for slic
                method.
    """
    if param_dict is None:
      param_dict = {}
    dataset, image_numbers, patches = [], [], []
    if discovery_images is None:
      raw_imgs = self.load_concept_imgs(
          self.target_class, self.num_discovery_imgs)
      self.discovery_images = raw_imgs
    else:
      self.discovery_images = discovery_images
    if self.num_workers:
      pool = multiprocessing.Pool(self.num_workers)
      outputs = pool.map(
          lambda img: self._return_superpixels(img, method, param_dict),
          self.discovery_images)
      for fn, sp_outputs in enumerate(outputs):
        image_superpixels, image_patches = sp_outputs
        for superpixel, patch in zip(image_superpixels, image_patches):
          dataset.append(superpixel)
          patches.append(patch)
          image_numbers.append(fn)
    else:
      for fn, img in enumerate(self.discovery_images):
        image_superpixels, image_patches = self._return_superpixels(
            img, method, param_dict)
        for superpixel, patch in zip(image_superpixels, image_patches):
          dataset.append(superpixel)
          patches.append(patch)
          image_numbers.append(fn)
    self.dataset, self.image_numbers, self.patches =\
    np.array(dataset), np.array(image_numbers), np.array(patches) 
开发者ID:amiratag,项目名称:ACE,代码行数:50,代码来源:ace.py


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