本文整理汇总了Python中PIL.ImageDraw.Draw.point方法的典型用法代码示例。如果您正苦于以下问题:Python Draw.point方法的具体用法?Python Draw.point怎么用?Python Draw.point使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PIL.ImageDraw.Draw
的用法示例。
在下文中一共展示了Draw.point方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mapdraw
# 需要导入模块: from PIL.ImageDraw import Draw [as 别名]
# 或者: from PIL.ImageDraw.Draw import point [as 别名]
def mapdraw(args,colorbar):
img = Image.new('RGB',(args['xlen'],args['ylen']),'white')
draw = Draw(img)
for key,value in args['datamap'].iteritems():
draw.point(value,getrgb(str(key)))
img2 = img.resize((args['y'],args['y']), Image.BILINEAR)
imgclr = colorbar.resize((args['colorbar'],img2.size[1]), Image.BILINEAR)
# ===== ENTIRE IMAGE CREATION W/ TEXT=====
imgbox = Image.new('RGB',((300+args['y']+args['colorbar']),(img2.size[1]+200)),args['background'])
imgbox.paste(img2,(100,100))
imgbox.paste(imgclr,((200+img2.size[0]),100))
drawbox = Draw(imgbox)
title = args['title']
titlesize = 50 # future user input
font = truetype("/library/fonts/Arial.ttf",titlesize)
smfontsize = 30 # future user input
smfont = truetype("/library/fonts/Arial.ttf",smfontsize)
titlewidth = font.getsize(title)[0]
drawbox.text(((imgbox.size[0]/2 - titlewidth/2), titlesize/2),title,(0,0,0),font=font)
drawbox.text(((imgbox.size[0] - 95),100),str(args['max']),(0,0,0),font=smfont)
drawbox.text(((imgbox.size[0] - 95),(100 + img2.size[1] - smfontsize)),str(args['min']),(0,0,0),font=smfont)
imgbox.show()
if 'title' in args:
title = args['title']+'_'+str(args['min'])+'_'+str(args['max'])+'.png'
else:
title = 'output_'+str(args['min'])+'_'+str(args['max'])+'.png'
imgbox.save(args['save']+'/'+title)
示例2: point
# 需要导入模块: from PIL.ImageDraw import Draw [as 别名]
# 或者: from PIL.ImageDraw.Draw import point [as 别名]
def point(self, patterns, color='black'):
hasher = md5()
draw = Draw(self.image)
for y, pattern in enumerate(patterns):
pattern_data = pattern.pattern_data
hasher.update(pattern_data)
points = [
(x, y)
for x, dot in enumerate(_to_bit(pattern_data)) if dot == '1'
]
draw.point(points, color)
self.hash = hasher.hexdigest()
示例3: colormap
# 需要导入模块: from PIL.ImageDraw import Draw [as 别名]
# 或者: from PIL.ImageDraw.Draw import point [as 别名]
def colormap(args):
rangelen = args['max'] - args['min']
rangemid = args['min'] + (rangelen / 2)
rangemax = args['max']
rangemin = args['min']
cr2 = rgb2hex.linear_gradient(args['colors'][1],args['colors'][2],(int(rangelen/2*1000))+1)['hex']
cr1 = rgb2hex.linear_gradient(args['colors'][0],args['colors'][1],(int(rangelen/2*1000))+1)['hex']
dictlist = {}
# === PAIR DATA WITH COLOR MAP ===
for y,sl in enumerate(args['data']): # for each sublist within dataset (row)
for x,i in enumerate(sl): # for each point in sublist (column)
val = args['colors'][1]
#top half of data range
if i > rangemid:
if i <= rangemax:
val = cr2[int((i - (rangemin + rangelen/2)) * 1000)]
else:
val = args['colors'][2]
#bottom half of data range
elif i < rangemid:
if i >= rangemin:
val = cr1[int((i - rangemin) * 1000)]
else:
val = args['colors'][0]
# mask
if 'mask' in args:
if i <= args['mask'][0]:
val = args['mask'][1]
# add to dict
if val in dictlist:
dictlist[val].append((x,y))
else:
dictlist[val] = [(x,y)]
args['datamap'] = dictlist
# ===== COLORBAR CREATION =====
clr = (cr1 + cr2)
clr = clr[::-1000]
widthclr = args['colorbar']
heightclr = len(clr)
imgclr = Image.new("RGB",(widthclr,heightclr),"white")
drawclr = Draw(imgclr)
for y,val in enumerate(clr):
for x in range(widthclr):
drawclr.point((x,y),getrgb(str(val)))
return args, imgclr