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


Python Pipeline.mask_original方法代码示例

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


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

示例1: find_mask

# 需要导入模块: from pipeline import Pipeline [as 别名]
# 或者: from pipeline.Pipeline import mask_original [as 别名]
def find_mask(filename,show=False,outfile="output.jpg", downsample=20, compsizethresh=50,adapthresh=500,blur=10,dilation=10,erosion=1):
    p = Pipeline(filename=filename, downsample=20,dilation=10,erosion=1)

    p.open() #perform background subtraction
    blurnum = int(blur)
    blurary = (blurnum,blurnum)
    p.blur(blurary) #blur the image
    p.crop(factor=8) #crop out the black borders that are produced by the blur
    adapthreshnum = int(adapthresh)
    p.threshold(adapthreshnum) #do adaptive thresholding
    p.erode() #erode the thresholded image

    p.connected_components_iterative() #calculate the connected components
    """
    try:
        p.check_circularity() #check to make sure everything makes sense so far
    except:
        print "I think this one doesn't have the hole in it..."
        #p.save_to_file(p.saved_data,filename=outfile) #saved the masked image to a file
        return np.ones(p.data.shape) #return an empty mask
    """
    p.select_largest_component() #select the largest connected component

    p.connected_components_iterative(full=False) #calculate the connected components of the inverted image
    #p.select_largest_component() #selected the largest connected components of the inverted image (this should now be the interior of the hole)
    p.select_largest_component()

    p.dilate() #dilate the mask
    p.mask_original() #mask the original image with the calculated mask
    p.save_to_file(out=p.data, filename=outfile) #saved the masked image to a file
    if show:
        p.show(data=np.concatenate((p.saved_data,p.data),axis=1)) #show the mask for debugging

    return p.data
开发者ID:hbradlow,项目名称:em_hole_finder,代码行数:36,代码来源:find_mask.py

示例2: find_particle

# 需要导入模块: from pipeline import Pipeline [as 别名]
# 或者: from pipeline.Pipeline import mask_original [as 别名]
def find_particle(filename,show=True,debug=False):
    from find_mask import find_mask
    hole_mask = find_mask(filename,show=False)

    p = Pipeline(downsample=20,filename=filename)

    if debug:
        p.show()

    p.open(window_size=(20,20))
    p.crop(factor=15)
    p.threshold() #do adaptive thresholding

    if debug:
        p.show()

    p.connected_components_iterative(full=False) #calculate the connected components
    p.threshold_component_size()
    if debug:
        p.show() #show the mask for debugging
    p.data = np.max(p.data) - p.data
    p.erode(factor=1)
    p.erode(factor=1)

    if debug:
        p.show()


    p.subtract(hole_mask)

    if debug:
        p.show()

    p.convex_hull_per_component()

    p.mask_original()
    p.show() #show the mask for debugging
开发者ID:hbradlow,项目名称:em_hole_finder,代码行数:39,代码来源:find_particle.py


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