Determination of chromatic aberration correction parameters

Update: Application available. See bottom of page

1. Intro

1.1 What is chromatic aberration

Chromatic aberration (CA) is a common lens error caused by a different refractive index at different wavelength. Please read on what CA is and what it usually looks like.

This brief HOWTO describes how to determine correction values for one aspect of CA, the transversal chromatic lens aberration (TCA). The other aspect, longitudinal CA can not be corrected afterwards but can be avoided by stopping down while shooting.

Please note, that if I talk about TCA here, I don't mean the strictly optical term, but the effect that is correctable with panotools plugin 'Radial Shift' which applies different correction parameters to the three channels of a RGB image. To distinguish from optical TCA I use the term 'cTCA' for correctable TCA here.

1.2 How to distinguish from other aberrations
The easiest way to decide whether color fringes are correctable you simply should try the techniques described here. See footnote [1] for details. Anyway it might be useful to know that cTCA...

1.3 Acknowledgments
The basic ideas explained here have been developed by Jim Watters. Please visit his page for further details.

There are several applications that allow linear cTCA correction, for example photoshop CS raw converter. Unfortunately this type of correction is not sufficient for some lenses especially of the fisheye type. These lenses need a correction curve that allows different amounts of radial color channel shift in different distances from the center. This correction curve can be calculated from different linear correction values at different radiuses.

1.1. Prerequisites

The only application I know that gives percentages for linear cTCA correction is Picture Window Pro 3.5. Please get it from

For script creation you need a MS-Excel compatible spreadsheet and (containing CA_PW.xls). And of course you need a panotools installation, f.e. from

Get the example image used here for own experimments: rd.jpg (1.3 MB)

2. Preparation

You need an image with good contrasty structures from the center to the corners (or the edge for circular fisheye). Preferably structures should be mostly black and white but some colored real life image would do, too. This image should not be overexposed to avoid blooming.

The picture must be perfectly focused and should be photographed with mirror lock up and/or remote release from a tripod. Shoot closed down (high f-stop number) to avoid longitudinal CA and blurring.

It is no good idea to use a close up shot if you want to correct for distant focus images (and vice versa). TCA is focus distance dependent.

3. Procedure

3.1 A word on the examples
I've used Jim Watters full frame fisheye images for demo purpose here. Of course the described technique can be used for circular or semi circular fisheye images, too.

The used example shows a problem that is very common: The color channels are not equal in sharpness.

Whereas the the red and green channel are more or less sharp, the blue channel suffers from heavy blurring. This is one of the reasons why an automated approach (f.e. with autopano) fails as well as the method I developed some years ago that required to manually set control points in the single channel images: Verzeichnung und Farbfehler korrigieren mit PanoTools und PTGui (german only). None of these techniques  shows immediately what blue channel shift looks best.

3.2 Get linear correction values
Load the picture into Picture Window. Make sure you see the whole image without scrolling (Zoom out). Press Ctrl+W to get Window info and write down image size in pixels (you can enter it directly into CA_PW.xls)

Choose 'Transformation -> Color -> chromatic Aberration' from the menu. Right click into the preview window and select 'Zoom 1:1', right click again and select 'Zoom in' in order to get 2:1 (200%) preview. Scroll preview window to one corner (or the edge for circular fisheye):

Now adjust 'Red Shift' and 'Blue Shift' in order to minimize color fringes. Do not press the 'Apply' button! Go for sharpness if there is a compromise needed between sharpness and absence of color fringes:

Open 'Readout' window from Tools menu and click in the image (full view) on the location of the detail seen in the preview window:

Enter the values of the first line in CA_PW.xls X and Y column ('Calc' page), enter the percentages from the 'Chromatic Aberration' window in the 'Red shift %' and 'Blue shift %' columns in the xls.

Now go to another area and look whether adjustment with previous parameters is good:

Please note: No blue shift here, compared to heavy blue shift in the corner!

Repeat these steps at least approximately at the radiuses indicated by the green circles (for circular fisheye use at least four distances between the center and the edge):

You can determine CA percentages at other locations, too. This will make the result even better. You can even use multiple images. See Improvements section below.

3.3 Preparing Script and running PTOptimizer
Once you have enough points you can go to the 'Script' page in CA_PW.xls. There is an input field called 'First Image Number'. If you created a PTGui project and you want to paste into the optimizer script the control points only (without lines 1 to 5) you should enter 1 for 'First Image Number'. PTGui works with a dummy image so image numbering starts with 1.

If you want to pass the script directly to PTOptimizer, use 'First Image Number' = 0. Now copy columns A to F to your favorite text editor (notepad or whatever) and delete all lines containing x0 y0 X0 Y0. If in your regional settings the comma (,) is decimal symbol alter all commas to points (.) by search and replace. Save file (text only) and drag it on PTOptimizer.

PTOptimizer adds a section to the file containing the results. The interesting part should look like this:
# Image No 0:
# Yaw: 0 deg (p) Pitch: 0 deg (p)
# Roll: 0 deg (p) HFov: 49.919 deg (*)
# Polynomial Coefficients: a   0.000709 (*); b   -0.005417 (*); c   0.007495 (*)
# Horizontal Shift: 0.000000 (p)   Vertical Shift:  0.000000 (p)
# 4th polynomial coefficient: 0.997213
# Command for Panorama Creation:
o f0 r0 p0 y0 v49.919 a0.000709 b-0.005417 c0.007495 g0.000000 t0.000000 d0.000000 e0.000000 u20 -buf

# Image No 1:
# Yaw: 0 deg (p) Pitch: 0 deg (p)
# Roll: 0 deg (p) HFov: 50 deg (p)
# Polynomial Coefficients: a   0.000000 (p); b   0.000000 (p); c   0.000000 (p)
# Horizontal Shift: 0.000000 (p)   Vertical Shift:  0.000000 (p)
# Command for Panorama Creation:
o f0 r0 p0 y0 v50 a0.000000 b0.000000 c0.000000 g0.000000 t0.000000 d0.000000 e0.000000 u20 +buf -buf

# Image No 2:
# Yaw: 0 deg (p) Pitch: 0 deg (p)
# Roll: 0 deg (p) HFov: 49.9667 deg (*)
# Polynomial Coefficients: a   -0.004206 (*); b   0.012529 (*); c   -0.008865 (*)
# Horizontal Shift: 0.000000 (p)   Vertical Shift:  0.000000 (p)
# 4th polynomial coefficient: 1.00054
# Command for Panorama Creation:
o f0 r0 p0 y0 v49.9667 a-0.004206 b0.012529 c-0.008865 g0.000000 t0.000000 d0.000000 e0.000000 u20 +buf

3.4 Using Results
Use the results directly with my batch TCA correction based on PTStitcher and ImageMagick. Get if you want to do so and read the enclosed readme_PTCA.txt file.

If you intend to use the parameters with the panotools photoshop plugin filter 'Radial Shift' one further step is required: parameter d must be calculated out of HFov and the a, b and c parameter given by PTOptimizer. Go to the HFov page of CA_PW.xls and enter the values in the white fields. The corrected d parameter will show up in the last column. Again be aware of regional settings for decimal delimiter. PTOptimizer output is always with point. This additional calculation step is necessary to mimic the internal calculation PTStitcher does  [2].

Enter the values for a, b, c and corrected d directly into the 'Radial Shift' dialog. This dialog needs points as decimal symbol, too.

3.5 Judging Results

As a first image to correct use your test image. Look carefully at the details you used for measurement. If the correction is worse then what you achieved manually look at other regions at the same radius. If there the correction is bad too, find new values for this radius and overwrite the old ones in the xls. In general it is a good idea to use additional measurement points since PTOptimizer tries to find values that satisfy most points.

If there is good and bad correction at the same radius, your camera over-emphasizes TCA under certain conditions (f.e. in very bright areas). Then you can either go for a compromise or use two different sets of parameters in order to use the good areas from each result images to compose a good one.

4. Improvements and Suggestions

A method has been shown to find correction curves for correcting transversal chromatic aberration. The crux in this method is still the need for suitable test images. One way to get reliable test images was suggested by Gerhard Bonnet from Spheron at the Stuttgart panography meeting: Find a distant building or other detail with not too strong dark and bright structures. White window frames with dark interior  would be very good.

Now shoot (preferable from a tripod) one image with this detail in the center. Rotate camera in order to have the detail about 1/4 way to the edge and shoot again. Repeat this all the way to the edge, then go with two steps along the edge into the corner. With a circular fisheye simply rotate in steps of about 10 degrees.

Shoot all images with same exposure, the same white balance (as if you would shoot a panorama) and the same focal length of course. It would be good if lighting conditions don't change while shooting (f.e. no fast moving clouds). Now you have 7 to 9 images with exactly the same detail where you can easily measure and compare cTCA directly. Simply do one measurement in each image.

5. Conclusion

This rather complicated method could be simplified greatly by having a small tool that does all steps in one GUI. Showing a small preview at 200% or 300%  magnification would do. A semi automatic could choose the appropriate radiuses. There could even be a quick polynomial fit in order to do the corrections incremental: First correcting a corner, then looking to some inner location. If there is still visible TCA adjust values there. The program does a curve fit to keep the previous correction and applies the new one, too. Then move on to another location, see how it looks there and correct if needed. The program adjusts the curve for best fit of all previous locations.

Unfortunately I don't have the resources to write such a program. Someone with more experience in graphics programming should do it. Jim Watters proposed to write something like that, so whoever wants to contribute should contact him.

Update: Eric Gerds wrote a Photoshop CS Javascript that does exactly what I proposed here. You can find it at

6. Footnotes

[1] After having corrected cTCA in one area you should have a look at other areas in the same distance from the center. If you notice some improvement in these areas, you have a good chance of finding suitable correction parameters.

[2] PTStitcher first calculates d = 1-(a+b+c) to keep the same size (this is the value that PTOptimizer outputs as '4th polynomial coefficient:'), then applies HFov.

e-Mail: Erik Krause

Good luck!

 © Erik Krause 07/2004, updated 09/2004