lens correction command line tools

991 views
Skip to first unread message

Hadubard

unread,
Feb 2, 2009, 9:00:58 AM2/2/09
to hugi...@googlegroups.com
Hello everyone,

for a university project I have to process a lot of fisheye images to
retrieve rectilinear images. I tried defisheye.sh from http://
www.fmwconcepts.com/imagemagick/defisheye/index.php but on our 8 core
ubuntu drive pc it still takes about 90 minutes to process a single
image.

Are there other scripts available for this purpose? Can I use the
hugin tools?
I would be glad if someone could point me in the right direction.

I have the correct lens parameters from the manufacture of the
fisheye lens (Sunex Superfisheye: http://www.superfisheye.com/)

regards,
Hadubard

Claus Bratvogel

unread,
Feb 2, 2009, 12:29:23 PM2/2/09
to hugi...@googlegroups.com
Hello Hadubard,

> Are there other scripts available for this purpose? Can I use the
> hugin tools?
> I would be glad if someone could point me in the right direction.

Do you know the software
lensfun?
http://lensfun.berlios.de/

It is possible to compile ufraw with the lensfun library.
Maybe there is a possibility to use ufraw-batch in combination with lensfun.

Regards

Claus
--
Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger01

Bruno Postle

unread,
Feb 2, 2009, 12:33:17 PM2/2/09
to Hugin ptx
>> Are there other scripts available for this purpose? Can I use the
>> hugin tools?

>It is possible to compile ufraw with the lensfun library.


>Maybe there is a possibility to use ufraw-batch in combination with lensfun.

Yes, for RAW files ufraw-batch in combination with lensfun would do
it. For non-RAW files then you can use fulla, a command-line tool
that ships with hugin:

http://wiki.panotools.org/Fulla

Note that either way you will probably need to calibrate your lens
distortion parameters with hugin first.

--
Bruno

Hadubard

unread,
Feb 2, 2009, 12:48:58 PM2/2/09
to hugi...@googlegroups.com
Hi Bruno, Hi Claus,

>> It is possible to compile ufraw with the lensfun library.
>> Maybe there is a possibility to use ufraw-batch in combination
>> with lensfun.
>
> Yes, for RAW files ufraw-batch in combination with lensfun would do
> it.

I just checked the ufraw website and it doesn't mention a possibility
to correct for fisheye distortions or any other kind of distortion.
So that won't help. Btw. I already used dcraw to convert the raw
images to tiff, but I could work with both types.

> For non-RAW files then you can use fulla, a command-line tool
> that ships with hugin:
>
> http://wiki.panotools.org/Fulla

Thanks, just found that too, I will surely give it a try.

> Note that either way you will probably need to calibrate your lens
> distortion parameters with hugin first.

Why is that? I got the original parameters from Sunnex and I supposed
they know their lenses.

regards,
Hadubard

Erik Krause

unread,
Feb 2, 2009, 3:10:20 PM2/2/09
to hugi...@googlegroups.com
Hadubard wrote:

> > Note that either way you will probably need to calibrate your lens
> > distortion parameters with hugin first.
>
> Why is that? I got the original parameters from Sunnex and I supposed
> they know their lenses.

Parameters for what lens correction model? Panotools (and hence hugin
and fulla) feature a lens correction model based on a default projection
(fisheye, rectilinear, equirectangular etc.) and a correction
polynomial. See http://wiki.panotools.org/Lens_correction_model for
details.

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

Claus Bratvogel

unread,
Feb 2, 2009, 5:21:31 PM2/2/09
to hugi...@googlegroups.com
Hello Hadubard,

-------- Original-Nachricht --------
> Datum: Mon, 2 Feb 2009 18:48:58 +0100
> Von: Hadubard <hadu...@gmail.com>

> I just checked the ufraw website and it doesn't mention a possibility
> to correct for fisheye distortions or any other kind of distortion.
> So that won't help.

You're right.
lensfun is the lib that delivers the correction.
ufraw is a example for a application that uses this lib.
digikam (for KDE4) is another application that uses this lib.

Regards

Claus
--
Jetzt 1 Monat kostenlos! GMX FreeDSL - Telefonanschluss + DSL
für nur 17,95 Euro/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K11308T4569a

Hadubard

unread,
Feb 2, 2009, 5:36:06 PM2/2/09
to hugi...@googlegroups.com
> Parameters for what lens correction model? Panotools (and hence hugin
> and fulla) feature a lens correction model based on a default
> projection
> (fisheye, rectilinear, equirectangular etc.) and a correction
> polynomial. See http://wiki.panotools.org/Lens_correction_model for
> details.

I'm really not good at all this. It's not really my domain. But
Sunnex gave me a PTGui starter guide saying, that for use with their
lens I had to set some parameters b and c to specified values and the
horizontal field of view of the lens to 185. So I thought that I
could simply come up with a scriptable version of the pano tools, and
since fulla is using the same library that might work?!

Tomorrow I will try fulla. But if you have other recommendations it
would be of great interest to me.

regards,
Hadubard

Bruno Postle

unread,
Feb 2, 2009, 5:57:54 PM2/2/09
to Hugin ptx
On Mon 02-Feb-2009 at 23:36 +0100, Hadubard wrote:
>
>I'm really not good at all this. It's not really my domain. But
>Sunnex gave me a PTGui starter guide saying, that for use with their
>lens I had to set some parameters b and c to specified values and the
>horizontal field of view of the lens to 185. So I thought that I
>could simply come up with a scriptable version of the pano tools, and
>since fulla is using the same library that might work?!

Yes these is the same system as used in fulla, i.e. you would use
parameters like this: -g a:b:c:d (where a = 0 and d = 1 - a - b - c)

Note that fulla will correct lens distortion and give you a
'perfect' fisheye image, but it won't change the projection.

If you want to extract a rectilinear image then you need to create a
hugin project file with these parameters and with output set to
rectilinear, check that it all works, save the file and use it as a
template with 'nona'.

Probably you don't actually need fulla.

--
Bruno

Hadubard

unread,
Feb 2, 2009, 6:03:51 PM2/2/09
to hugi...@googlegroups.com
> Yes these is the same system as used in fulla, i.e. you would use
> parameters like this: -g a:b:c:d (where a = 0 and d = 1 - a - b - c)
>
> Note that fulla will correct lens distortion and give you a
> 'perfect' fisheye image, but it won't change the projection.
>
> If you want to extract a rectilinear image then you need to create a
> hugin project file with these parameters and with output set to
> rectilinear, check that it all works, save the file and use it as a
> template with 'nona'.

Ok, I will try that tomorrow.

Thanks for your help. This seems like a real productive group ;-)

regards,
Hadubard

Andrew Kreps

unread,
Feb 2, 2009, 7:16:09 PM2/2/09
to hugi...@googlegroups.com
but on our 8 core
ubuntu drive pc it still takes about 90 minutes to process a single
image.


Have you made sure that you're fully utilizing your cores?  Most programs do not take into account for the availability of extra processing threads.  I usually split the set of files to be processed into folders, one for each core, and I run a separate process in each folder from the command line.  It may be possible to process 8 images in the same 90 minute period.


Hadubard

unread,
Feb 2, 2009, 7:25:30 PM2/2/09
to hugi...@googlegroups.com

Thanks for mentioning that, but it would still be far too slow for
our purposes. For each set of images we have to process 720 indiviual
images and we can't afford to calculate more than a day for all of them.
And by the way, when I checked the cpu usage using the "top" command
it was constantly at 100%. And I'm not the only one working with that
machine ;-)

regards,
Hadubard

paul womack

unread,
Feb 3, 2009, 4:13:59 AM2/3/09
to hugi...@googlegroups.com


Unless the Sunnex parameters are in the format that hugin/fulla requires
you'll either need to convert the parameters, or calibrate from
scratch.

BugBear

Hadubard

unread,
Feb 3, 2009, 5:58:39 AM2/3/09
to hugi...@googlegroups.com
Hi,

to make it more concrete: I have circular fisheye images like this one:
http://user.cs.tu-berlin.de/~baumbach/image1.jpg (compressed version)

The idea is to take all images that I have, to correct for the
fisheye distortion and then take only a center strip from the image
of about 15 pixel to put them all together in order to have a picture
like this:
http://user.cs.tu-berlin.de/~baumbach/image2.jpg (compressed version)

I am currently developping a python application to view those
panoramic images. When you look closely on the top and bottom parts
of the second image you can see, that there are a lot of artefacts
that come from the fact, that the source images are distorted. That's
why I need a way correct those distortions. I don't mind that the
resulting image won't look correct, since I only use a central strip.

Is that possible with fulla? I just tried to use the parameters from
Sunnex (parameters b and c) with the following fulla command line:
fulla -v -g 0:-0.2986:0.0671:0 IMG_0711.CR2.tiff
Where comes the horizontal field of view into it?

The result is here:
http://user.cs.tu-berlin.de/~baumbach/image3.jpg (compressed version)
That is not at all what I was looking for.

What am I missing? Does it mean, that the parameters are not working
with fulla and that I have to calibrate using hugin?

regards,
Hadubard

Bruno Postle

unread,
Feb 3, 2009, 6:25:23 AM2/3/09
to Hugin ptx
On Tue 03-Feb-2009 at 11:58 +0100, Hadubard wrote:
>
>to make it more concrete: I have circular fisheye images like this one:
>http://user.cs.tu-berlin.de/~baumbach/image1.jpg (compressed version)
>
>The idea is to take all images that I have, to correct for the
>fisheye distortion and then take only a center strip from the image
>of about 15 pixel to put them all together in order to have a picture
>like this:
>http://user.cs.tu-berlin.de/~baumbach/image2.jpg (compressed version)
>
>I am currently developping a python application to view those
>panoramic images. When you look closely on the top and bottom parts
>of the second image you can see, that there are a lot of artefacts
>that come from the fact, that the source images are distorted.

No the artefacts are because you are not rotating the lens around
the 'no parallax point'. This is nothing to do with the lens
distortion.

>Is that possible with fulla? I just tried to use the parameters from
>Sunnex (parameters b and c) with the following fulla command line:
>fulla -v -g 0:-0.2986:0.0671:0 IMG_0711.CR2.tiff
>Where comes the horizontal field of view into it?
>
>The result is here:
>http://user.cs.tu-berlin.de/~baumbach/image3.jpg (compressed version)
>That is not at all what I was looking for.

Assuming that you do want equirectangular panoramas, then you don't
want to convert to rectilinear at all - Slices from (corrected)
fisheye images will do the job.

So you can use fulla/lensfun rather than nona.

>What am I missing? Does it mean, that the parameters are not working
>with fulla and that I have to calibrate using hugin?

The parameters are not working, ptgui works slightly differently and
these images would need to be rotated 90 degrees for the same values
to apply. However the image still looks really wrong, I strongly
recommend you recalibrate the lens with hugin.

--
Bruno

Hadubard

unread,
Feb 3, 2009, 6:52:15 AM2/3/09
to hugi...@googlegroups.com
> No the artefacts are because you are not rotating the lens around
> the 'no parallax point'. This is nothing to do with the lens
> distortion.

The way I put the image strips together I strongly believe the
artefacts are caused by fisheye distortion. And I strongly believe
that I'm rotating the lens around the point of no parallax. I work on
a stereo viewer and the image you saw is only one of two
perspectives. When I view the stereo images in my application I have
a really convincing stereo impression. I believe that this wouldn't
be like that with a parallax error.

What makes you believe it is a parallax problem?

>> Is that possible with fulla? I just tried to use the parameters from
>> Sunnex (parameters b and c) with the following fulla command line:
>> fulla -v -g 0:-0.2986:0.0671:0 IMG_0711.CR2.tiff
>> Where comes the horizontal field of view into it?
>>
>> The result is here:
>> http://user.cs.tu-berlin.de/~baumbach/image3.jpg (compressed version)
>> That is not at all what I was looking for.
>
> Assuming that you do want equirectangular panoramas, then you don't
> want to convert to rectilinear at all - Slices from (corrected)
> fisheye images will do the job.

So what do you mean with corrected?

> So you can use fulla/lensfun rather than nona.

ok, but how? Calibrating the lens with hugin and than apply the
obtained parameters in the way I did with the wrong parameters?

>> What am I missing? Does it mean, that the parameters are not working
>> with fulla and that I have to calibrate using hugin?
>
> The parameters are not working, ptgui works slightly differently and
> these images would need to be rotated 90 degrees for the same values
> to apply. However the image still looks really wrong, I strongly
> recommend you recalibrate the lens with hugin.

Which image? The third one?
In order to retrieve the correct lens parameters?

regards,
Hadubard

Plinio Barraza

unread,
May 13, 2015, 6:49:42 PM5/13/15
to hugi...@googlegroups.com, hadu...@gmail.com
Just in case anyone is needing a similar solution I use Blender, which can do this... but you need to know how to work it.
1. Enter tracking mode
2. Enter the lens coefficients
3. Import image sequence
4. Make a simple track to set up the compositing nodes.
5. Render to files
(I use it for drone photogrammetry)

Terry Duell

unread,
May 13, 2015, 7:07:29 PM5/13/15
to hugi...@googlegroups.com
Hello Plinio,

On Thu, 14 May 2015 08:37:00 +1000, Plinio Barraza
<barraz...@gmail.com> wrote:

> Just in case anyone is needing a similar solution I use Blender, which
> can do this... but you need to know how to work it.
> 1. Enter tracking mode
> 2. Enter the lens coefficients
> 3. Import image sequence
> 4. Make a simple track to set up the compositing nodes.
> 5. Render to files
> (I use it for drone photogrammetry)
>

Do you think your method is simpler/easier than the scripts provided at
<https://github.com/lucacapacci/SamyangFisheyeDefisher> ?

There might be a bit of experimentation required to adjust the scripts to
suit, but it does look like it might be a simple process. I have not tried
it.

Cheers,
--
Regards,
Terry Duell
Reply all
Reply to author
Forward
0 new messages