Hello
I finished writing a script to correct the barrel/pinchcusion photographic objectives, using Helmut Dersch's formula:
Normal Mode: r_src = (a * (r_dest ^ 3) + b * (r_dest ^ 2) + c * r_dest + d) * r_dest
Inverse Mode: r_src = 1/(a * (r_dest ^ 3) + b * (r_dest ^ 2) + c * r_dest + d) * r_dest
a,b,c,d parameters are the radial distortion/correction coefficients for the X,Y dimension equation.
The coefficient a,b,c,d represents scaling and the radial terms control pincushion and barrel distortion. The higher order coefficients affect the pixels further from center. The whole expression has a scaling effect. Thus, to avoid overall scaling, keep a+b+c+d=1. For normal mode, pincushion correction and barrel distortion are achieved using a,b,c positive and barrel correction and pincushion distortion are achieved using a,b,c negative.
For a+b+c+d>1, the image will be scaled smaller and for a+b+c+d<1, the image will be scaled larger.
Typical values are: d near 1 and a,b,c near zero.
For inverse mode, the situation above is reversed. Thus for inverse mode, pincushion correction and barrel distortion are achieved using a,b,c, negative and barrel correction and pincushion distortion are achieved using a,b,c,d positive.
For a+b+c+d<1, the image will be scaled smaller and for a+b+c+d+e>1, the image will be scaled larger.
Values of a=0,b=0,c=0,d=1, makes no change in the image in the appropriate dimension.
Coefficients a,b,c,d,e are floating point values.
Some examples:
Original
Corrected
Original
Corrected
And now I need some help. I can implement a, b, c, d coefficients for X and Y independiently i.e. ax, bx, cx, dx and ay, by, cy, dy. But theoretically, this formula
can correct chromatic aberration with independent coeficients for each RGB channels Redax, Redbx....Blueyc, Blueyd. You can shift x and y points, choose center of image, etc. A lot of controls.
I don't know how to implement this controls: simple text controls, sliders? SpinBox don't alow negative and decimal values.
And this for Juan. I got error calculations with standart formula r_src = (a * (r_dest ^ 3) + b * (r_dest ^ 2) + c * r_dest + d) * r_dest so I implemented r_src=(a*(r_dest*r_dest*r_dest) + b*(r_dest*r_dest) + c*r_dest + d)*r_dest. What I'm doing wrong?
Thanks