Image warping / distortion
2016-04-28 13:34
429 查看
from: http://paulbourke.net/miscellaneous/imagewarp/
Written by Paul Bourke
December 2002
This documents, primarily with examples, an image warping application that was originally developed to test the simulation of various lens types. There are a few key ideas with image transformations such as this.
The transformation that one needs is not the function that maps from the source image to the destination but the reverse. What is required is to find the source pixel associated with each pixel in the destination image.
In general the image plane is considered to be a real valued function rather than a discrete pixel plane, this is particularly so when antialiasing is implemented.
The image coordinates are transformed from pixels (i,j) ranging from 0 to the width-1 and height-1 to normalised coordinates (x,y) ranging from -1 to 1, this is irrespective of the image proportions and it applies
to both the source and destination image coordinates.
x = 2 i / width - 1
y = 2 j / height - 1
A key ingredient for image quality is antialiasing. In the code given here, supersampling is used. That is, each pixel in the destination image is sampled a number of times, the resulting estimate from the source image
are averaged (box filter is used here) to give a final estimate in the destination image.
Some transformation act upon the cartesian coordinates while other are radial (polar coordinates) in nature. The r,phi coordinates are as follows.
r = sqrt(x2 + y2)
phi = atan2(y,x)
After the radial based warp the reverse transformation back to cartesian normalised coordinates is:
x = r cos(phi)
y = r sin(phi)
This application (imagewarp.c) is written as a UNIX utility that reads a TGA file (24 or 32 bit), performs
the warping as specified by command line arguments and writes the resulting image as a TGA file to standard output (to be redirected to a file say).
The following lists each of the image warping types supported, other warping function can readily be added.
Image warping / distortion
Written by Paul BourkeDecember 2002
This documents, primarily with examples, an image warping application that was originally developed to test the simulation of various lens types. There are a few key ideas with image transformations such as this.
The transformation that one needs is not the function that maps from the source image to the destination but the reverse. What is required is to find the source pixel associated with each pixel in the destination image.
In general the image plane is considered to be a real valued function rather than a discrete pixel plane, this is particularly so when antialiasing is implemented.
The image coordinates are transformed from pixels (i,j) ranging from 0 to the width-1 and height-1 to normalised coordinates (x,y) ranging from -1 to 1, this is irrespective of the image proportions and it applies
to both the source and destination image coordinates.
x = 2 i / width - 1
y = 2 j / height - 1
A key ingredient for image quality is antialiasing. In the code given here, supersampling is used. That is, each pixel in the destination image is sampled a number of times, the resulting estimate from the source image
are averaged (box filter is used here) to give a final estimate in the destination image.
Some transformation act upon the cartesian coordinates while other are radial (polar coordinates) in nature. The r,phi coordinates are as follows.
r = sqrt(x2 + y2)
phi = atan2(y,x)
After the radial based warp the reverse transformation back to cartesian normalised coordinates is:
x = r cos(phi)
y = r sin(phi)
This application (imagewarp.c) is written as a UNIX utility that reads a TGA file (24 or 32 bit), performs
the warping as specified by command line arguments and writes the resulting image as a TGA file to standard output (to be redirected to a file say).
imagewarp tgafilename [options] Options: -a n set antialias level (Default: 1) -w n width of the output image (Default: 500) -h n height of the output image (Default: width) -m n mapping type (Default: 0) -p1 n first parameter for mapping (Default: 0) -p2 n second parameter for mapping (Default: 0) -p3 n third parameter for mapping (Default: 0) -s n scale factor (Default: 1) -v debug/verbose mode (Default: off)
The following lists each of the image warping types supported, other warping function can readily be added.
Source image This is the test image: test.tga that is transformed into each of the images below. | ![]() |
r -> 2 arcsin(r) / pi | ![]() |
r -> rp p = 1.5 | ![]() |
r -> rp p = 3 | ![]() |
x -> sign(x) x2 y -> sign(y) y2 | ![]() |
x -> x (1 - p r) / (1 - p) y -> y (1 - p.r) / (1 - p) p = 0.1 | ![]() |
x -> x (1 - p r) / (1 - p) y -> y (1 - p.r) / (1 - p) p = 0.3 | ![]() |
Method by H. Farid and A.C. Popescu for modest lens with good fit. p = 0.4 | ![]() |
r -> p1 10r p2 - p1 p1 = 0.049 p2 = 1.280 | ![]() |
Janez Pers, Stanislav Kovacic An Alternative Model for Radial Distortion in Wide-Angle Lenses (Single parameter model) p = 0.1 | ![]() |
Janez Pers, Stanislav Kovacic An Alternative Model for Radial Distortion in Wide-Angle Lenses (Single parameter model) p = 0.3 | ![]() |
相关文章推荐
- C++ 读写txt文件
- EventBus使用详解(一)——初步使用EventBus
- 商业智能数据营销该怎么做?
- TO SOLVE THE ISSUE OF MySQLStartupItem.pkg missing from MySQL DMG
- Mac OS 终端常用命令基础
- Mac OS 终端常用命令基础
- BOA服务器的搭建以及移植到开发板
- OpenCV中通过滑动条阈值分割多通道图像
- 关于JVM、JRE、JDK及环境变量
- mysql 中 character set 与 collation 的点滴理解(collation即比对方法,用于对应字符集的数据集如何排序以及字符串的比对规则)
- 28-Merge Two Sorted Lists
- Reusing dialogs with a dialog pool--一个sql server service broker例子
- myCat正则转换表达式
- Kafka开发实战(二)-集群环境搭建
- 如何配置自己的Activity,让其他应用调用
- MySql:charset和collation的设置
- 求区间(a,b)中与n的互质数
- 简单实现短链接算法
- (5)学习ArduPilot源码——shetch范例
- 函数