python-PIL 画出带有角度的椭圆
来源:互联网 发布:数据透视表刷新数据 编辑:程序博客网 时间:2024/05/22 17:47
- 最近在学习FDDB的人脸识别库,发现他们的标记是用椭圆来标记的,而且还是有角度的椭圆。
- 在PIL库中好像并没有画出带有角度椭圆的函数,所以在StackOverflow上找到了如下代码:
def ellipse_with_angle(im,x,y,major,minor,angle,color): # take an existing image and plot an ellipse centered at (x,y) with a # defined angle of rotation and major and minor axes. # center the image so that (x,y) is at the center of the ellipse x -= int(major/2) y -= int(major/2) # create a new image in which to draw the ellipse im_ellipse = Image.new('RGBA', (major,major), (255,255,255,0)) draw_ellipse = ImageDraw.Draw(im_ellipse, "RGBA") # draw the ellipse ellipse_box = (0,int(major/2-minor/2),major,int(major/2-minor/2)+minor) draw_ellipse.ellipse(ellipse_box, fill=color) # rotate the new image rotated = im_ellipse.rotate(angle) rx,ry = rotated.size # paste it into the existing image and return the result im.paste(rotated, (x,y,x+rx,y+ry), mask=rotated) return im
效果还不错,如下图所示:
其实用matplotlib.patches.Ellipse也可以画出来,不过没办法转化成矩阵的形式,我主要是想判断selective search方法提取出来的方框判断是否是脸,给他们打上label。
- 实验室就我一个人在瞎搞人脸识别,不知道我这样做的做法对不对,总感觉我姿势不对。。。
- 如果有大神觉得有问题,请告诉我正确姿势。。谢谢
阅读全文
0 0
- python-PIL 画出带有角度的椭圆
- python--用PIL Image画圣诞树Imagedraw画椭圆
- 把检测出的人脸用椭圆和矩形框画出
- 实现用画笔画出一个带有渐变效果的线条
- python PIL模块的下载
- python的PIL库安装
- python的PIL工具包入门
- 让PIL生成的字带有描边效果
- 任意角度的图像画法(椭圆、矩形、菱形)
- python PIL
- python PIL
- python,PIL
- python-PIL
- python-PIL
- python PIL
- python画出来的电子时钟
- python PIL 检查图片的完整性
- centos 安装python的PIL matplotlib模块
- 【工具】文章格式转换神器pandoc
- 秒杀系统架构优化思路
- SPOJ 705
- Oracle之where子句和order by子句
- JS 之排序算法和去重复算法
- python-PIL 画出带有角度的椭圆
- Linux用户深度管理
- HDU
- Ubuntu 14.04 下 Virtual Judge 的搭建
- java反射机制
- Ubuntu安装VMware-tools步骤
- 20170814
- BUAA OJ 701 DH的矩阵游戏
- 第一次踏入博客的的世界,CSDN,但愿能够坚持下来吧