鱼眼镜头图像畸变矫正(fish eye distortion)
来源:互联网 发布:正规贵金属行情软件 编辑:程序博客网 时间:2024/06/08 13:32
from PIL import Imageimport mathdef fish_eye_dis(img): "fish eye distortion" width_in, height_in = img.size; im_out = Image.new("RGB",(width_in,height_in)); radius = max(width_in, height_in)/2; #assume the fov is 180 #R = f*theta lens = radius*2/math.pi; for i in range(width_in): for j in range(height_in): #offset to center x = i - width_in/2; y = j - height_in/2; r = math.sqrt(x*x + y*y); theta = math.atan(r/radius); if theta<0.00001: k = 1; else: k = lens*theta/r; src_x = x*k; src_y = y*k; src_x = src_x+width_in/2; src_y = src_y+height_in/2; pixel = im.getpixel((src_x,src_y)); im_out.putpixel((i,j),pixel); return im_out;if __name__=="__main__": input_name = "image0.jpg"; output_name = "image_dis.jpg"; im = Image.open(input_name); img_out = fish_eye_dis(im); img_out.save(output_name); print "fish eye distortion completely, save image to %s" % output_name
效果如下:
原图
矫正后
原理参考:Fisheye lens Wikis
源代码地址(oschina.net):fish eye distortion.py
0 0
- 鱼眼镜头图像畸变矫正(fish eye distortion)
- 图像矫正----认识畸变(Distortion)
- 鱼眼镜头畸变校正模型
- 鱼眼镜头畸变校正方法
- 图像径向畸变矫正
- 鱼眼镜头的标定及矫正
- 鱼眼镜头畸变校正-OpenCV3.1.0和Matalb2012a
- 鱼眼镜头畸变校正的一些参考链接
- 摄像机模型,畸变模型及畸变图像的矫正
- fish eye
- 畸变(Distortion)
- 鱼眼相机畸变矫正的总结
- opencv 图像畸变矫正加速、透视变换加速方法总结
- opencv 图像畸变矫正加速、透视变换加速方法总结
- 畸变矫正(反畸变)
- VR眼镜 开发 (九) Fov与头动矫正
- 图像处理算法之鱼眼镜头特效模拟
- 镜头畸变矫正
- 447. Number of Boomerangs
- IO类操作
- [NOIP] [LCA] NOIP2016Day1 天天爱跑步
- recyclerview嵌套Gridview的图片错位或显示不全解决办法实验
- 二元选择排序
- 鱼眼镜头图像畸变矫正(fish eye distortion)
- Java8 简洁的匿名内部类使用Demo
- 微信投票管理系统(三)E-R图
- 网络爬虫代码(数据筛选情是有jsoup)
- 51单片之LED的点亮
- cpu、内存、硬盘和指令那些事
- Eclipse新建web项目,实现登录验证功能
- iOS 导航栏返回按钮自定义
- 黑盒测试基本方法