Login  Register

Applying calibrated geometrical distortion to an image ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Applying calibrated geometrical distortion to an image ?

Alan Hewat
I have a camera instrument with a fixed geometry that produces slightly distorted images.

I want to determine the distortion correction field, by comparing the distorted image with the undistorted image, eg of a grid. I then want to apply that calibrated correction field to any image with the same camera, without user interaction. I need a precise automatic correction, since the user must measure positions within the corrected image.

I tried http://biocomp.cnb.csic.es/~iarganda/SplineDeformationGenerator/ which allows a choice of distortion models with a small number of parameters. This works, but calibration requires an a priori choice of the type of distortion  (fisheye, barrel etc...) and then manual adjustment of the parameters to obtain what <b>appears</b> to be the least distorted image. It is too subjective, and difficult to obtain parameters that remove all distortion.

Then http://biocomp.cnb.csic.es/~iarganda/bUnwarpJ/ looked promising. This determines the distortion field that will transform between an un-distorted and distorted image pair. But again it appears to be a manual process and I couldn't see from the tutorial how I could store the distortion field and automatically apply it to new images with the same distortion.

I would have thought that calibrated distortion correction was a common need for many fixed geometry cameras, but couldn't find much more on the WWW. Any suggestions would be welcome.

Alan.


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Applying calibrated geometrical distortion to an image ?

giubi
Hi Alan,

Calibrated distortion correction is a common need in several applications.

Determine the optical geometry of your camera is not easy though. Here the
well documented MATLAB Toolbox:
http://www.vision.caltech.edu/bouguetj/calib_doc/

Here an automated undistortion example using the OpenCV C++ library:
http://www.aishack.in/2010/07/calibrating-undistorting-with-opencv-in-c-oh-yeah/

Hope it helps,
/Giuseppe


On 3 March 2013 09:33, Alan Hewat <[hidden email]> wrote:

> I have a camera instrument with a fixed geometry that produces slightly
> distorted images.
>
> I want to determine the distortion correction field, by comparing the
> distorted image with the undistorted image, eg of a grid. I then want to
> apply that calibrated correction field to any image with the same camera,
> without user interaction. I need a precise automatic correction, since the
> user must measure positions within the corrected image.
>
> I tried http://biocomp.cnb.csic.es/~iarganda/SplineDeformationGenerator/which allows a choice of distortion models with a small number of
> parameters. This works, but calibration requires an a priori choice of the
> type of distortion  (fisheye, barrel etc...) and then manual adjustment of
> the parameters to obtain what <b>appears</b> to be the least distorted
> image. It is too subjective, and difficult to obtain parameters that remove
> all distortion.
>
> Then http://biocomp.cnb.csic.es/~iarganda/bUnwarpJ/ looked promising.
> This determines the distortion field that will transform between an
> un-distorted and distorted image pair. But again it appears to be a manual
> process and I couldn't see from the tutorial how I could store the
> distortion field and automatically apply it to new images with the same
> distortion.
>
> I would have thought that calibrated distortion correction was a common
> need for many fixed geometry cameras, but couldn't find much more on the
> WWW. Any suggestions would be welcome.
>
> Alan.
>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Applying calibrated geometrical distortion to an image ?

Albert Cardona-2
In reply to this post by Alan Hewat
Alan,

Have a look here:

http://fiji.sc/wiki/index.php/Distortion_Correction

This is a protocol to calculate the distortion of your camera. The resulting transformation you could apply using Stephan Saalfeld's mpicbg library functions.

Albert

On Mar 3, 2013, at 3:33 AM, Alan Hewat <[hidden email]> wrote:

> I have a camera instrument with a fixed geometry that produces slightly distorted images.
>
> I want to determine the distortion correction field, by comparing the distorted image with the undistorted image, eg of a grid. I then want to apply that calibrated correction field to any image with the same camera, without user interaction. I need a precise automatic correction, since the user must measure positions within the corrected image.
>
> I tried http://biocomp.cnb.csic.es/~iarganda/SplineDeformationGenerator/ which allows a choice of distortion models with a small number of parameters. This works, but calibration requires an a priori choice of the type of distortion  (fisheye, barrel etc...) and then manual adjustment of the parameters to obtain what <b>appears</b> to be the least distorted image. It is too subjective, and difficult to obtain parameters that remove all distortion.
>
> Then http://biocomp.cnb.csic.es/~iarganda/bUnwarpJ/ looked promising. This determines the distortion field that will transform between an un-distorted and distorted image pair. But again it appears to be a manual process and I couldn't see from the tutorial how I could store the distortion field and automatically apply it to new images with the same distortion.
>
> I would have thought that calibrated distortion correction was a common need for many fixed geometry cameras, but couldn't find much more on the WWW. Any suggestions would be welcome.
>
> Alan.
>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Applying calibrated geometrical distortion to an image ?

Alan Hewat
Thanks Albert.

As I understand, this is a method of correcting for distortion without
using a special calibration image. You just take a matrix of partly
overlapping images of the object, stitch them together and fit the
individual images to the average. Iteration with a new average will
then converge to give a correction field that can be applied to any
image. I used a simpler 1D version of this technique ~30 years ago to
calibrate 64 detectors scanning a linear object. It depends on having
sufficient overlap between adjacent images, and then it does a great
job and converges quickly.

Unfortunately I can't do that with my current problem. The camera has
a fixed geometry w.r.t. the object, and can't scan. It is an
instrument with two fixed cameras looking at a fixed screen in a box.
After correcting each camera for distortion, I have to stitch them
together, and measure precise points in the composite image. Although
the cameras are nominally identical, the overlap is not sufficient for
your method to work in my case http://neutronoptics.com/laue.html

With my fixed geometry I should be able to use a calibration pattern
such as a grid or checkerboard.

Thanks also to Giuseppe for pointing out that such techniques exist in
MatLab. I was hoping to find that some-one had done such a distortion
correction with ImageJ using a calibration pattern. The examples I
found are almost what I need, but not quite appropriate.

Alan.

On 3 March 2013 15:09, Albert Cardona <[hidden email]> wrote:

> Alan,
>
> Have a look here:
>
> http://fiji.sc/wiki/index.php/Distortion_Correction
>
> This is a protocol to calculate the distortion of your camera. The resulting transformation you could apply using Stephan Saalfeld's mpicbg library functions.
>
> Albert
>
> On Mar 3, 2013, at 3:33 AM, Alan Hewat <[hidden email]> wrote:
>
>> I have a camera instrument with a fixed geometry that produces slightly distorted images.
>>
>> I want to determine the distortion correction field, by comparing the distorted image with the undistorted image, eg of a grid. I then want to apply that calibrated correction field to any image with the same camera, without user interaction. I need a precise automatic correction, since the user must measure positions within the corrected image.
>>
>> I tried http://biocomp.cnb.csic.es/~iarganda/SplineDeformationGenerator/ which allows a choice of distortion models with a small number of parameters. This works, but calibration requires an a priori choice of the type of distortion  (fisheye, barrel etc...) and then manual adjustment of the parameters to obtain what <b>appears</b> to be the least distorted image. It is too subjective, and difficult to obtain parameters that remove all distortion.
>>
>> Then http://biocomp.cnb.csic.es/~iarganda/bUnwarpJ/ looked promising. This determines the distortion field that will transform between an un-distorted and distorted image pair. But again it appears to be a manual process and I couldn't see from the tutorial how I could store the distortion field and automatically apply it to new images with the same distortion.
>>
>> I would have thought that calibrated distortion correction was a common need for many fixed geometry cameras, but couldn't find much more on the WWW. Any suggestions would be welcome.
>>
>> Alan.
>>
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html



--
______________________________________________
Dr Alan Hewat, NeutronOptics, Grenoble, FRANCE
<[hidden email]> +33.476.98.41.68
        http://www.NeutronOptics.com/hewat
______________________________________________

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Applying calibrated geometrical distortion to an image ?

Michael Schmid
In reply to this post by Alan Hewat
Hi Alan,

hmm, it seems to me that bUnwarpJ should be able to do the same
undistortion for all of your photos:
Take a photo of a grid, and create a synthetic undistorted grid of the
same size.
With bUnwarpJ, use 'Save Transformation' to store the transformation
necessary to convert the photo into the synthetic grid.
Then, use 'Load Elastic Transformation' to apply it manually, or use the
macro interface to apply it to an image stored on disk.

Michael

__________________________________________________________________
On Sun, March 3, 2013 09:33, Alan Hewat wrote:

> I have a camera instrument with a fixed geometry that produces slightly
> distorted images.
>
> I want to determine the distortion correction field, by comparing the
> distorted image with the undistorted image, eg of a grid. I then want to
> apply that calibrated correction field to any image with the same camera,
> without user interaction. I need a precise automatic correction, since the
> user must measure positions within the corrected image.
>
> I tried http://biocomp.cnb.csic.es/~iarganda/SplineDeformationGenerator/
> which allows a choice of distortion models with a small number of
> parameters. This works, but calibration requires an a priori choice of the
> type of distortion  (fisheye, barrel etc...) and then manual adjustment of
> the parameters to obtain what <b>appears</b> to be the least distorted
> image. It is too subjective, and difficult to obtain parameters that
> remove all distortion.
>
> Then http://biocomp.cnb.csic.es/~iarganda/bUnwarpJ/ looked promising. This
> determines the distortion field that will transform between an
> un-distorted and distorted image pair. But again it appears to be a manual
> process and I couldn't see from the tutorial how I could store the
> distortion field and automatically apply it to new images with the same
> distortion.
>
> I would have thought that calibrated distortion correction was a common
> need for many fixed geometry cameras, but couldn't find much more on the
> WWW. Any suggestions would be welcome.
>
> Alan.
>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Applying calibrated geometrical distortion to an image ?

Alan Hewat
Thanks Michael.

Encouraged by your recommendation of bUnWarpJ I have persisted with
trying to understand how it might be used. Reading the description of
its predecessor http://bigwww.epfl.ch/thevenaz/UnwarpJ/ also helped.

I experimented by taking an image of a checkerboard and applying a
pincushion distortion with SplineDeformationGenerator. I was able to
transform this distorted imageA into an undistorted imageB and save
the deformation file, with both bUnWarpJ and UnWarpJ. (The latter is
perhaps simpler for a one-way process). And yes, the macro interface
seems suitable for automating the undistortion process for other
images.

call("bunwarpj.bUnwarpJ_.elasticTransformImageMacro", "My_path/A.jpg",
"My_path/B.jpg", "My_path/A_direct_transf.txt", "My_path/output.tif");

But then I apparently have to provide the user with not only the
deformation file "A_direct_transf.txt" but also a target image "B.jpg"
to use with his own image "A.jpg" to obtain the corrected image
"output.tif". (It is not clear why I have to provide the target
image). With SplineDeformationGenerator I only had to provide a couple
of parameters for a particular camera.

What would have been nice would have been an automated registration
procedure like bUnWarpJ that would result in a distortion MODEL eg
assuming the usual barrel/pincushion lens distortion, with just a few
parameters as in SplineDeformationGenerator; that is easy to transmit
to the user http://neutronoptics.com/laue.html#hires

This experience has made me appreciate that SplineDeformationGenerator
is perhaps still my best bet for a practical tool, even though the
determination of its "Noise K1/K2" parameters by trial and error is
not obvious, and the resulting correction is not perfect.

Thanks again to everyone for educating me about these more general
distortion corrections with ImageJ/Fiji.

Alan.

On 3 March 2013 18:57, Michael Schmid <[hidden email]> wrote:

> Hi Alan,
>
> hmm, it seems to me that bUnwarpJ should be able to do the same
> undistortion for all of your photos:
> Take a photo of a grid, and create a synthetic undistorted grid of the
> same size.
> With bUnwarpJ, use 'Save Transformation' to store the transformation
> necessary to convert the photo into the synthetic grid.
> Then, use 'Load Elastic Transformation' to apply it manually, or use the
> macro interface to apply it to an image stored on disk.
>
> Michael
>
> __________________________________________________________________
> On Sun, March 3, 2013 09:33, Alan Hewat wrote:
>> I have a camera instrument with a fixed geometry that produces slightly
>> distorted images.
>>
>> I want to determine the distortion correction field, by comparing the
>> distorted image with the undistorted image, eg of a grid. I then want to
>> apply that calibrated correction field to any image with the same camera,
>> without user interaction. I need a precise automatic correction, since the
>> user must measure positions within the corrected image.
>>
>> I tried http://biocomp.cnb.csic.es/~iarganda/SplineDeformationGenerator/
>> which allows a choice of distortion models with a small number of
>> parameters. This works, but calibration requires an a priori choice of the
>> type of distortion  (fisheye, barrel etc...) and then manual adjustment of
>> the parameters to obtain what <b>appears</b> to be the least distorted
>> image. It is too subjective, and difficult to obtain parameters that
>> remove all distortion.
>>
>> Then http://biocomp.cnb.csic.es/~iarganda/bUnwarpJ/ looked promising. This
>> determines the distortion field that will transform between an
>> un-distorted and distorted image pair. But again it appears to be a manual
>> process and I couldn't see from the tutorial how I could store the
>> distortion field and automatically apply it to new images with the same
>> distortion.
>>
>> I would have thought that calibrated distortion correction was a common
>> need for many fixed geometry cameras, but couldn't find much more on the
>> WWW. Any suggestions would be welcome.
>>
>> Alan.
______________________________________________
Dr Alan Hewat, NeutronOptics, Grenoble, FRANCE
<[hidden email]> +33.476.98.41.68
        http://www.NeutronOptics.com/hewat
______________________________________________

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html