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


Python morphology.closing方法代码示例

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


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

示例1: isolate_islands

# 需要导入模块: from skimage import morphology [as 别名]
# 或者: from skimage.morphology import closing [as 别名]
def isolate_islands(prediction, threshold):
    bw = closing(prediction > threshold , square(3))
    labelled = label(bw)  
    regions_properties = regionprops(labelled)
    max_region_area = 0
    select_region = 0
    for region in regions_properties:
        if region.area > max_region_area:
            max_region_area = region.area
            select_region = region
    output = np.zeros(labelled.shape)
    if select_region == 0:
        return output
    else:
        output[labelled == select_region.label] = 1
        return output

# input: output from bwperim -- 2D image with perimeter of the ellipse = 1 
开发者ID:pydsgz,项目名称:DeepVOG,代码行数:20,代码来源:draw_ellipse.py

示例2: __call__

# 需要导入模块: from skimage import morphology [as 别名]
# 或者: from skimage.morphology import closing [as 别名]
def __call__(self, img_small):
        m = morphology.square(self.square_size)
        img_th = morphology.black_tophat(img_small, m)
        img_sob = abs(filters.sobel_v(img_th))
        img_closed = morphology.closing(img_sob, m)
        threshold = filters.threshold_otsu(img_closed)
        return img_closed > threshold 
开发者ID:konstantint,项目名称:PassportEye,代码行数:9,代码来源:image.py

示例3: prefilter

# 需要导入模块: from skimage import morphology [as 别名]
# 或者: from skimage.morphology import closing [as 别名]
def prefilter(self, img, rec_size=20, se_size=3):
    
        se = morphology.disk(se_size)
        
        im1 = self.morpho_rec(img, rec_size)
        im2 = self.morpho_rec2(im1, int(rec_size / 2))
        
        im3 = morphology.closing(im2, se)
        
        return im3 
开发者ID:PeterJackNaylor,项目名称:DRFNS,代码行数:12,代码来源:segmentation_test.py

示例4: prefilter_new

# 需要导入模块: from skimage import morphology [as 别名]
# 或者: from skimage.morphology import closing [as 别名]
def prefilter_new(self, img, rec_size=20, se_size=3):
    
        img_cc = ccore.numpy_to_image(img, copy=True)        
        im1 = ccore.diameter_open(img_cc, rec_size, 8)        
        im2 = ccore.diameter_close(im1, int(rec_size / 2), 8)        

        #im1 = self.morpho_rec(img, rec_size)
        #im2 = self.morpho_rec2(im1, int(rec_size / 2))

        se = morphology.disk(se_size)        
        im3 = morphology.closing(im2.toArray(), se)
        
        return im3 
开发者ID:PeterJackNaylor,项目名称:DRFNS,代码行数:15,代码来源:segmentation_test.py

示例5: closing

# 需要导入模块: from skimage import morphology [as 别名]
# 或者: from skimage.morphology import closing [as 别名]
def closing(gray_img, kernel=None):
    """Wrapper for scikit-image closing functions. Opening can remove small dark spots (i.e. pepper).

    Inputs:
    gray_img = input image (grayscale or binary)
    kernel   = optional neighborhood, expressed as an array of 1s and 0s. If None, use cross-shaped structuring element.

    :param gray_img: ndarray
    :param kernel = ndarray
    :return filtered_img: ndarray
    """

    params.device += 1

    # Make sure the image is binary/grayscale
    if len(np.shape(gray_img)) != 2:
        fatal_error("Input image must be grayscale or binary")

    # If image is binary use the faster method
    if len(np.unique(gray_img)) == 2:
        bool_img = morphology.binary_closing(image=gray_img, selem=kernel)
        filtered_img = np.copy(bool_img.astype(np.uint8) * 255)
    # Otherwise use method appropriate for grayscale images
    else:
        filtered_img = morphology.closing(gray_img, kernel)

    if params.debug == 'print':
        print_image(filtered_img, os.path.join(params.debug_outdir, str(params.device) + '_opening' + '.png'))
    elif params.debug == 'plot':
        plot_image(filtered_img, cmap='gray')

    return filtered_img 
开发者ID:danforthcenter,项目名称:plantcv,代码行数:34,代码来源:closing.py


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