當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。