_exact_ lens calibration / undistortion model in Hugin

133 views
Skip to first unread message

Sven Utcke

unread,
May 7, 2013, 9:14:49 AM5/7/13
to hugi...@googlegroups.com
Hi,

I find it extremely difficult to get information about the exact calibration model used in Hugin.  Yes, I know that a, b, c refer to radial distortions, d, e are an offset, and g, t refer to shear (and Va, Vb, Vc have something todo with vignetting). However since I'm trying to convert some other lens model (the one from the Matlab Calibration Toolbox) into the Hugin one (as good as possible), I really need the math!

Here's what I have found out so far:

* x gets translated by (-width/2), y by (-height/2). Presumably it's here that d and e come into play - but is it x_new=x-width/2-e or x_new=x-width/2+e(i.e. does e get added or subtracted?)

* x_new then gets scaled by s=min(height,width)/2 so that x_newer=xnew/s

* Next comes radial distortion such that x_newest=(a*r^3+b*r^2+c*r+(1-a-b-c))*x_newer, with r=sqrt(x_newer^2+y_newer^2). Presumably here we're also going to deal with shear, so g and t will probably come into play here. But how?

* then scale and translation are undone again, and I can get the undistorted image values for (x,y) by sampling the image at position (x_newest*s+width/2,y_newest*s+height/2) (and here, again, d and e might come into play - or not.)

So, how are d, e, g, t applied?

Any help deeply appreciated

Sven

PS: oh, and if anyone knows what to make of Va etc...?

Erik Krause

unread,
May 7, 2013, 3:48:03 PM5/7/13
to hugi...@googlegroups.com
Am 07.05.2013 15:14, schrieb Sven Utcke:
> I find it extremely difficult to get information about the exact
> calibration model used in Hugin

I assume you know http://wiki.panotools.org/Lens_correction_model

Lens correction always applies to the chosen source projection. For
standard fisheye f.e. it's the deviation from the ideal fisheye mapping:
http://wiki.panotools.org/Fisheye_Projection

In addition you should know about the crop model hugin uses. See
http://wiki.panotools.org/Panotools_internals#Details especially the
section Cropping.

--
Erik Krause
http://www.erik-krause.de

Sven Utcke

unread,
May 23, 2013, 2:40:16 PM5/23/13
to hugi...@googlegroups.com
Hi Erik,


Am Dienstag, 7. Mai 2013 21:48:03 UTC+2 schrieb Erik Krause:
Am 07.05.2013 15:14, schrieb Sven Utcke:
> I find it extremely difficult to get information about the exact
> calibration model used in Hugin

I assume you know http://wiki.panotools.org/Lens_correction_model

Yes, I do. But that's more of a generell idea of calibration, not even a calibration 101, certainly no formula.
 
Lens correction always applies to the chosen source projection. For
standard fisheye f.e. it's the deviation from the ideal fisheye mapping:
http://wiki.panotools.org/Fisheye_Projection

Well, I use normal (rectilinear) lenses, but frankly, even if you could just point me to a formula for fisheye lenses, I would at least be better of that what I am now.
 
In addition you should know about the crop model hugin uses. See
http://wiki.panotools.org/Panotools_internals#Details especially the
section Cropping.

I believe that's about the ONLY thing I actually got figured out.

Really, what I need is math, not words.
And no, I'm not afraid of math - I teach math :-)

Any takers?

Sven

Erik Krause

unread,
Jun 2, 2013, 11:08:57 AM6/2/13
to hugi...@googlegroups.com
Am 23.05.2013 20:40, schrieb Sven Utcke:

> Well, I use normal (rectilinear) lenses, but frankly, even if you could
> just point me to a formula for fisheye lenses, I would at least be better
> of that what I am now.

The actual lens correction is the same. Only the projection formula
changes.

Some hints: The way shift and shear parameters work can be tried out. In
the output canvas the image moves up for positive d and right for
positive e values. Positive g values shear the image left up and right
down, positive t values shear top to left and bottom to right.

The way a, b, c, d and e work can be seen most easily in the abc.xls
excel sheet which you can get from http://4pi.org/downloads/
Unfortunately the g and t parameters are not covered.

Internally any operation is performed by a dedicated transformation
function. All the different transformation functions are put on a stack.
This stack is worked down for any destination pixel. This does not only
include lens correction but also correction of perspective distortion
(projection in a sphere) and transform to output projection. The beauty
of this technique is that interpolation occurs only once no matter how
complex the remapping is.

Sorry I can't be of any further help. There should be more knowledgeable
members here: Tom Sharpless or Tim Nugent f.e.
Reply all
Reply to author
Forward
0 new messages