def _get_glyph(gnum, height, width, shift_prob, shift_size):
if isinstance(gnum, list):
n = randint(*gnum)
else:
n = gnum
glyph = random_points_in_circle(
n, 0, 0, 0.5
)*array((width, height), 'float')
_spatial_sort(glyph)
if random()<shift_prob:
shift = ((-1)**randint(0,2))*shift_size*height
glyph[:,1] += shift
if random()<0.5:
ii = randint(0,n-1,size=(1))
xy = glyph[ii,:]
glyph = row_stack((glyph, xy))
return glyph
评论列表
文章目录