本文整理汇总了Python中pipeline.Pipeline.show方法的典型用法代码示例。如果您正苦于以下问题:Python Pipeline.show方法的具体用法?Python Pipeline.show怎么用?Python Pipeline.show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pipeline.Pipeline
的用法示例。
在下文中一共展示了Pipeline.show方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: find_mask
# 需要导入模块: from pipeline import Pipeline [as 别名]
# 或者: from pipeline.Pipeline import show [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
示例2: find_particle
# 需要导入模块: from pipeline import Pipeline [as 别名]
# 或者: from pipeline.Pipeline import show [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