Author Topic: Lens distortion profiling  (Read 6661 times)

ruediger

  • Guest
Lens distortion profiling
« on: 2012 April 01 08:11:35 »
Hi all,
I was thinking about building some lens distortion profiles as a prerecorded Dynamic Alignment process, which is applied directly after debayering and before star alignment.
Right now, the distortion of (my) camera lenses with focal lenghts < 400mm makes alignment to an artificial starfield impossible and therefore also the new plate solving and annotation scripts don't work properly (sometimes they do, most of the time not).
My intention is the following: I create an artificial starfield, show it on the monitor screen and take a photo of it. A script auto"magic"ally matches the stars from the distorted camera picture to the source picture and creates a dynamic alignment process. Does it sound feasible? Other or better suggestions?

Rüdiger


Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
Re: Lens distortion profiling
« Reply #1 on: 2012 April 01 12:56:44 »
Maybe as a first experiment, try to image some regular structure such as a brick wall, and use it to determine a basic distortion. For fine tuning the transform, stars a probably the most exact field you can get. For long focal length, you may be able to purchase sufficiently large sheets of millimeter paper. For wide field lenses, they are always  too small.

Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

Offline vicent_peris

  • PTeam Member
  • PixInsight Padawan
  • ****
  • Posts: 988
    • http://www.astrofoto.es/
Re: Lens distortion profiling
« Reply #2 on: 2012 April 01 13:01:45 »
Hi,

It would be better if one can apply a distortion model to the SG synthetic image, in order to avoid one geometric transformation to the image.


Regards,
Vicent.

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
Re: Lens distortion profiling
« Reply #3 on: 2012 April 01 13:28:06 »
I hear that DXO http://www.dxo.com/us/photo has a lot of built in profiles. If you have the money...
Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

Offline troypiggo

  • PixInsight Addict
  • ***
  • Posts: 258
Re: Lens distortion profiling
« Reply #4 on: 2012 April 01 13:42:43 »
So does Lightroom and PTLens, the latter being very reasonable price.  But Vicent's suggestion to use SG would always be more accurate, wouldn't it?

ruediger

  • Guest
Re: Lens distortion profiling
« Reply #5 on: 2012 April 02 00:04:00 »
Thanks for your answers.

I have access to both Lightroom and PT Lens profiles. Actually, the right part of the screenshot shows the Lightroom profile for a 50mm lens applied to the artificial starfield on the left, i.e. giving me the inverse distortion. For a quick test, I "dynamic align"ed the undistorted field to the distorted one, saved the process and applied it to the distorted star field. This works, so basically I'm able to convert Lightroom profiles to dynamic alignment processes. Automating the mapping process should be easy to program, if you start from the center, find the position of the nearest 4 neighbour "stars" and work towards the edges. During the alignment process, it was also very nice to see, how many points you actually need for an accurate model and how easy you can introduce severe additional distortion when choosing too few reference points. But I don't want to extract and convert other people's work... also on a quick look, the Lightroom 50mm 1.4 distortion profile looks a little bit off centered, as if it was built from a bad lens sample. Therefore my idea with taking actual pictures of artificial starfields.

I'm not sure, if the following will work:
Once I've a couple of undistorted (i.e. perfectly rectilinear) images and want to build, let's say, a 2x2 mosaic from them, will the undistorted images "snap on" an appropiately sized artificial starfield with gnomonic projection?

A distortion model built into the star generator might help for single images, but not for mosaic building?

Rüdiger

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
Re: Lens distortion profiling
« Reply #6 on: 2012 April 02 01:37:08 »
Ruediger:
- instead of transforming a starfield with light room etc., you can also just transform some artifical pattern (for example a rectangular grid.) Should make finding corresponding points easier.
- gnomic projections and coordinates: creating a mosaic will not work if the field of view is too large. All projections are attempts to map a sphere to a plane, and with reasonably low distortions this will only work for relatively small fields of view. In particular, each gnomic projection is different depending on its central coordinate. You should see the effect if you try to create a mosaic from 2 star fiields with FOV 90 degrees.
- To create a large field mosaic (e.g. full sky), you need a different strategy. Google, or use this http://home.arcor-online.de/axel.mellinger/ as a starting point.

Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

ruediger

  • Guest
Re: Lens distortion profiling
« Reply #7 on: 2012 April 02 03:30:09 »
...and with reasonably low distortions this will only work for relatively small fields of view. In particular, each gnomic projection is different depending on its central coordinate
I'd be happy to make small mosaics from 50mm or 135mm or have single shots with these focal lengths accurately plate solved and annotated. To be more specific:
- I have a typical 50mm Orion shot, that is mappable to an artificial starfield, but with increasing inaccuracy towards the edges. Now IF the raw material is undistorted, will the mapping in the star alignment process be perfect?
- If I try to map a 50mm shot to a larger starfield with a different central coordinate, i.e. mosaic building in mind, will star alignment still work? Where are the limits? Could star alignment for mosaic building be made more "bullet-proof" if the mosaic panes are plate solved and artificial starfields (plate solved by nature) are used?

Rüdiger

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
Re: Lens distortion profiling
« Reply #8 on: 2012 April 02 03:50:32 »
- FOV limits: StarAlignment (and the solver and the annotation script) usually works fine for my 85mm lens. There are already slight offsets visible at the border of the field, but they seem to be acceptable. With my 22mm lens, PI never solves.

- I dont know how much central coordinate offset would still be acceptable. I currently know of no way to convince PI to solve fields with larger fields of view. Maybe splitting the full mosaic into small pieces, and then aligning each piece to the artifical star field will work, then integrating again will work?!? I never tried.

- Maybe Juan has some ideas on how to make StarAlignment more tolerant to the unavoidable and central coordinate dependent distortions in larger fields.

Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

ruediger

  • Guest
Re: Lens distortion profiling
« Reply #9 on: 2012 April 03 10:57:21 »
- FOV limits: StarAlignment (and the solver and the annotation script) usually works fine for my 85mm lens. There are already slight offsets visible at the border of the field, but they seem to be acceptable. With my 22mm lens, PI never solves.
I experimented a little bit with my 50mm and 24mm lenses. Once the images are undistorted (now I temporarily used the Lightroom profile) and you enter the correct center in the starfield generator, my images map. Even up into the edges the mapping is now perfect. For comparison, I attach the difference between the "raw", distorted 50mm image and the corrected one. Despite beeing the insanely expensive EF 1.2/50mm L lens, you see how much distortion even in the crop format edges this lens has  :-[

Registering the 24mm image to the starfield worked good once I used small previews around the image center and checked "compute intersections: always" (x) restrict to previews.

What does not work, is trying to register a 50mm image into a 24mm image. I tried this with two artificial starfields, which both are plate solved and annotated. By no means I was able to register the 50mm FOV into the larger one, thus making easy mosaic building impossible. I think, image registration should make use of the plate solving information.

Rüdiger

Offline Nocturnal

  • PixInsight Jedi Council Member
  • *******
  • Posts: 2727
    • http://www.carpephoton.com
Re: Lens distortion profiling
« Reply #10 on: 2012 April 03 11:09:02 »
I agree it would be great if mosaic building could use WCS information. I've build mosaics where I've had to manually pick a tiny group of stars in previews in both images to make it find a match.
Best,

    Sander
---
Edge HD 1100
QHY-8 for imaging, IMG0H mono for guiding, video cameras for occulations
ASI224, QHY5L-IIc
HyperStar3
WO-M110ED+FR-III/TRF-2008
Takahashi EM-400
PIxInsight, DeepSkyStacker, PHD, Nebulosity

ruediger

  • Guest
Re: Lens distortion profiling
« Reply #11 on: 2012 April 23 11:23:16 »
Hi all,

after looking into the ImageSolver code, mapping one image ("target") with WCS coordinates into another image ("starfield") with shorter focal length is basically this:
 ( dst_x, dst_y ) = starfield.Convert_RD_I( target.Convert_I_RD( src_x, src_y ) )
First, the image coordinates are transferred to RA/DEC, than RA/DEC is transferred to the starfield image coordinates.

Attached is a simple script that does the mapping of one plate solved image into another with help of DynamicAlignment. It needs the WCSmetada.jsh from the ImageSolver script. Since no stars are analyzed inside the WCSMapper script, the resulting mapped image still needs to be fed into StarAlignment. But StarAlignment won't fail on these pre-distorted image.

Attached is a screenshot where I aligned 135mm, 50mm and 200mm focal length shots against a 24mm starfield. Intentionally I did not use the GradientDomainMergeMosaic tool because it was working too good, not allowing to clearly see the edges of the inserted images  :D

Rüdiger

Offline pfile

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 4729
Re: Lens distortion profiling
« Reply #12 on: 2012 April 24 08:33:55 »
it seems strange to me that you have problems at < 400mm. i have solved images taken with a canon 50d + canon 200L with andres' script, and i think i even solved one from the same camera + a nifty 50 (canon 50mm f/1.8 ).

what if you restrict the match to the central area of the image? the imagesolver script will restrict the list of matched stars to any previews defined on the image being solved.
« Last Edit: 2012 April 24 08:45:00 by pfile »

ruediger

  • Guest
Re: Lens distortion profiling
« Reply #13 on: 2012 April 24 09:11:36 »
it seems strange to me that you have problems at < 400mm. i have solved images taken with a canon 50d + canon 200L with andres' script, and i think i even solved one from the same camera + a nifty 50 (canon 50mm f/1.8 ).
I'm addressing two problems:
- if the camera picture is not perfectly rectilinear, the images might solve, but once you use the annotation script you will see an annoying inaccuracy towards the edges. An easy solution to this problem is to use a DynamicAlignment process built from a lens distortion profile, e.g. from Lightroom.
- using widefield images for mosaic building is nearly impossible with the automatic Star Alignment, because the relative distortions are too large. This problem is now solved once you have two plate solved images and use the WCSMapper script to align them.

Rüdiger