擅长:python、mysql、java
<p>首先,让我们用PIL构建字母B的图像:</p>
<pre><code>import Image, ImageDraw, ImageFont
image = Image.new("RGBA", (600,150), (255,255,255))
draw = ImageDraw.Draw(image)
fontsize = 150
font = ImageFont.truetype("/usr/share/fonts/truetype/liberation/LiberationMono-Regular.ttf", fontsize)
txt = 'B'
draw.text((30, 5), txt, (0,0,0), font=font)
img = image.resize((188,45), Image.ANTIALIAS)
print type(img)
plt.imshow(img)
</code></pre>
<p>您可能会找到更好的方法来实现这一点,尤其是使用字体路径。我最好加载一个图像而不是生成它。总之,我们现在有事情要做:
<img src="https://i.stack.imgur.com/DKzgs.png" alt="Upper B"/></p>
<p>现在,真正的部分是:</p>
^{pr2}$
<p><img src="https://i.stack.imgur.com/dowzt.png" alt="Holes labelling"/>
我们在控制台中有(ipython):
<2个洞</p>