Update: Application available. See
bottom of page
Chromatic aberration (CA) is a common lens error caused by a different refractive index at different wavelength. Please read http://www.vanwalree.com/optics/chromatic.html 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...
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.
For script creation you need a MS-Excel compatible spreadsheet and CA_PW.zip (containing CA_PW.xls). And of course you need a panotools installation, f.e. from http://www.path.unimelb.edu.au/~dersch/
Get the example image used here for own experimments: rd.jpg (1.3 MB)
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.
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:
3.4 Using
Results
Use the results directly with my batch
TCA correction based on PTStitcher and ImageMagick. Get PTCA.zip
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.
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.
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.
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 http://www.pinlady.net/vr/
[2] PTStitcher
first calculates d = 1-(a+b+c) to keep the same size (this is the value
that PTOptimizer outputs as '
e-Mail: Erik Krause
Good luck!
© Erik Krause 07/2004, updated 09/2004