本文整理汇总了Python中shapely.geometry.Polygon.copy方法的典型用法代码示例。如果您正苦于以下问题:Python Polygon.copy方法的具体用法?Python Polygon.copy怎么用?Python Polygon.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shapely.geometry.Polygon
的用法示例。
在下文中一共展示了Polygon.copy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: range
# 需要导入模块: from shapely.geometry import Polygon [as 别名]
# 或者: from shapely.geometry.Polygon import copy [as 别名]
#Loop for each sample required
for j in range(samples_count):
#loop until a patch fully inside the polygon is found
output = False
attempts = 0
while(not output):
#Stop attempting to get a sample if the Golgi is too small
attempts += 1
if attempts > 3000:
print "Skipping %s: cannot find a valid sample" % file['imagePath']
break
#apply random rotation
rotation = randint(0, 359)
mask = polygon.copy()
mask = mask.rotate(rotation, resample=Image.BICUBIC, expand=True)
#pick a random box in the image
x = randint(0, mask.size[0] - PATCH_SIZE)
y = randint(0, mask.size[1] - PATCH_SIZE)
candidate_patch_coords = (x, y, x + PATCH_SIZE, y + PATCH_SIZE)
candidate_patch = box(*candidate_patch_coords)
#and then cut it out
crop_mask = mask.crop(candidate_patch_coords)
#then test if the patch contains entirely golgi
if crop_mask.histogram()[-1] == PATCH_SIZE**2:
#if yes - output the patch
output = True