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


Python skimage.segmentation方法代码示例

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


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

示例1: execute

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import segmentation [as 别名]
def execute(self, eopatch):
        """ Main execute method
        """
        feature_type, feature_name = next(self.feature_checker(eopatch))

        data = eopatch[feature_type][feature_name]

        if np.isnan(data).any():
            warnings.warn('There are NaN values in given data, super-pixel segmentation might produce bad results',
                          RuntimeWarning)

        if feature_type.is_time_dependent():
            data = np.moveaxis(data, 0, 2)
            data = data.reshape((data.shape[0], data.shape[1], data.shape[2] * data.shape[3]))

        superpixel_mask = np.atleast_3d(self._create_superpixel_mask(data))

        new_feature_type, new_feature_name = self.superpixel_feature
        eopatch[new_feature_type][new_feature_name] = superpixel_mask

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

示例2: generate_markers

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import segmentation [as 别名]
def generate_markers(image):
    #Creation of the internal Marker
    marker_internal = image < -400
    marker_internal = segmentation.clear_border(marker_internal)
    marker_internal_labels = measure.label(marker_internal)
    areas = [r.area for r in measure.regionprops(marker_internal_labels)]
    areas.sort()
    if len(areas) > 2:
        for region in measure.regionprops(marker_internal_labels):
            if region.area < areas[-2]:
                for coordinates in region.coords:                
                       marker_internal_labels[coordinates[0], coordinates[1]] = 0
    marker_internal = marker_internal_labels > 0
    #Creation of the external Marker
    external_a = ndimage.binary_dilation(marker_internal, iterations=10)
    external_b = ndimage.binary_dilation(marker_internal, iterations=55)
    marker_external = external_b ^ external_a
    #Creation of the Watershed Marker matrix
    marker_watershed = np.zeros(image.shape, dtype=np.int)
    marker_watershed += marker_internal * 255
    marker_watershed += marker_external * 128
    return marker_internal, marker_external, marker_watershed 
开发者ID:Wrosinski,项目名称:Kaggle-DSB,代码行数:24,代码来源:dsbowl_preprocess_2d.py

示例3: get_masks

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import segmentation [as 别名]
def get_masks(img, n_seg=250):
    logger.debug('SLIC segmentation initialised')
    segments = skimage.segmentation.slic(img, n_segments=n_seg, compactness=10, sigma=1)
    logger.debug('SLIC segmentation complete')
    logger.debug('contour extraction...')
    masks = [[numpy.zeros((img.shape[0], img.shape[1]), dtype=numpy.uint8), None]]
    for region in skimage.measure.regionprops(segments):
        masks.append([masks[0][0].copy(), region.bbox])
        x_min, y_min, x_max, y_max = region.bbox
        masks[-1][0][x_min:x_max, y_min:y_max] = skimage.img_as_ubyte(region.convex_image)
    logger.debug('contours extracted')
    return masks[1:] 
开发者ID:whdcumt,项目名称:BlurDetection,代码行数:14,代码来源:FocusMask.py

示例4: __init__

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import segmentation [as 别名]
def __init__(self, feature, superpixel_feature, *, segmentation_object=skimage.segmentation.felzenszwalb,
                 **segmentation_params):
        """
        :param feature: Raster feature which will be used in segmentation
        :param superpixel_feature: A new mask timeless feature to hold super-pixel mask
        :param segmentation_object: A function (object) which performs superpixel segmentation, by default that is
            `skimage.segmentation.felzenszwalb`
        :param segmentation_params: Additional parameters which will be passed to segmentation_object function
        """
        self.feature_checker = self._parse_features(feature, allowed_feature_types=FeatureTypeSet.SPATIAL_TYPES)
        self.superpixel_feature = next(self._parse_features(superpixel_feature,
                                                            allowed_feature_types={FeatureType.MASK_TIMELESS})())
        self.segmentation_object = segmentation_object
        self.segmentation_params = segmentation_params 
开发者ID:sentinel-hub,项目名称:eo-learn,代码行数:16,代码来源:superpixel.py

示例5: _create_superpixel_mask

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import segmentation [as 别名]
def _create_superpixel_mask(self, data):
        """ Method which performs the segmentation
        """
        with warnings.catch_warnings():
            warnings.filterwarnings('ignore', category=RuntimeWarning, module=skimage.segmentation.__name__)
            return self.segmentation_object(data, **self.segmentation_params) 
开发者ID:sentinel-hub,项目名称:eo-learn,代码行数:8,代码来源:superpixel.py

示例6: getMinorMajorRatio_2

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import segmentation [as 别名]
def getMinorMajorRatio_2(image):
    image = image.copy()
    # Create the thresholded image to eliminate some of the background
    imagethr = np.where(image > np.mean(image),0.,1.0)
 
    #Dilate the image
    imdilated = morphology.dilation(imagethr, np.ones((4,4)))
 
    # Create the label list
    label_list = measure.label(imdilated)
    label_list = imagethr*label_list
    label_list = label_list.astype(int)
    
    region_list = measure.regionprops(label_list)
    maxregion = getLargestRegion(region_list, label_list, imagethr)
        
    # guard against cases where the segmentation fails by providing zeros
    ratio = 0.0
    minor_axis_length = 0.0
    major_axis_length = 0.0
    area = 0.0
    convex_area = 0.0
    eccentricity = 0.0
    equivalent_diameter = 0.0
    euler_number = 0.0
    extent = 0.0
    filled_area = 0.0
    orientation = 0.0
    perimeter = 0.0
    solidity = 0.0
    centroid = [0.0,0.0]
    if ((not maxregion is None) and  (maxregion.major_axis_length != 0.0)):
        ratio = 0.0 if maxregion is None else  maxregion.minor_axis_length*1.0 / maxregion.major_axis_length
        minor_axis_length = 0.0 if maxregion is None else maxregion.minor_axis_length 
        major_axis_length = 0.0 if maxregion is None else maxregion.major_axis_length  
        area = 0.0 if maxregion is None else maxregion.area  
        convex_area = 0.0 if maxregion is None else maxregion.convex_area  
        eccentricity = 0.0 if maxregion is None else maxregion.eccentricity  
        equivalent_diameter = 0.0 if maxregion is None else maxregion.equivalent_diameter  
        euler_number = 0.0 if maxregion is None else maxregion.euler_number  
        extent = 0.0 if maxregion is None else maxregion.extent 
        filled_area = 0.0 if maxregion is None else maxregion.filled_area  
        orientation = 0.0 if maxregion is None else maxregion.orientation 
        perimeter = 0.0 if maxregion is None else maxregion.perimeter  
        solidity = 0.0 if maxregion is None else maxregion.solidity
        centroid = [0.0,0.0] if maxregion is None else maxregion.centroid
 
    return ratio,minor_axis_length,major_axis_length,area,convex_area,eccentricity,\
           equivalent_diameter,euler_number,extent,filled_area,orientation,perimeter,solidity, centroid[0], centroid[1] 
开发者ID:benanne,项目名称:kaggle-ndsb,代码行数:51,代码来源:extract_features.py


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