Correction of lateral chromatic aberration

bulrichl

Well-known member
I use PixInsight also for processing all of my daylight images. Whereas I did not encounter a use case for PI's ChannelMatch process, I badly miss a process for the correction of lateral chromatic aberration. This is the only case when I am currently forced to use different software in my workflow, and I would love to achieve this task in PixInsight. The images captured with my favorite lens (Canon 17-40 mm f/4L USM) show considerable lateral CA (red - green), changing considerably with focal length and distance. Lateral CA results in the red, green, and blue planes beeing at different magnifications. The amount of the effect is a function of the distance from the optical axis.

This artifact can be easily corrected. The software that I use for this purpose contains a transformation that magnifies or reduces the red or/and the blue channel of an image with reference to the optical axes. The optical axis (by default: the image center) can be changed, and the red and blue magnification factors can be set. This is an example (bottom left section of an image captured at a focal length of 17 mm, before and after correction of lateral CA):

before.png


after.png


Please consider to implement an equivalent process in PixInsight. Maybe the existing ChannelMatch process can be changed or extended to achieve this task?

Bernd
 
I use PixInsight also for processing all of my daylight images. Whereas I did not encounter a use case for PI's ChannelMatch process, I badly miss a process for the correction of lateral chromatic aberration. This is the only case when I am currently forced to use different software in my workflow, and I would love to achieve this task in PixInsight. The images captured with my favorite lens (Canon 17-40 mm f/4L USM) show considerable lateral CA (red - green), changing considerably with focal length and distance. Lateral CA results in the red, green, and blue planes beeing at different magnifications. The amount of the effect is a function of the distance from the optical axis.

This artifact can be easily corrected. The software that I use for this purpose contains a transformation that magnifies or reduces the red or/and the blue channel of an image with reference to the optical axes. The optical axis (by default: the image center) can be changed, and the red and blue magnification factors can be set. This is an example (bottom left section of an image captured at a focal length of 17 mm, before and after correction of lateral CA):

View attachment 12076

View attachment 12075

Please consider to implement an equivalent process in PixInsight. Maybe the existing ChannelMatch process can be changed or extended to achieve this task?

Bernd
I think that if the scaling of each RGB channel is different but constant for each RGB channel then FFTRegistartion script shoud be able to realign the channels each other (two channels over a reference one). It has the option to take into account rotation and scale during the registration.

Unfortunately I've tried with your small images but the mono channels won't align, I am not sure if I misinterpret how it works or if these kind of daily images are not suitable for such task.

Maybe @Juan Conejero can provide more details on how the script works and if it's suitable for correcting this kind of chromatic aberration?
 
No image registration should be necessary to implement a correction of lateral chromatic aberration. This can be implemented easily with a geometric transformation known as central dilation. I already wrote a script to do this years ago. See the Distortion Example II: Central Dilations section of this tutorial. The script in that tutorial can be considered as a proof of concept to solve this problem. It could be modified quite easily to define an arbitrary center, and even to define nonlinear transformations if necessary (in which case the transformation wouldn't be affine, but that isn't a problem for this task).

Thank you for an excellent suggestion. I'll see how this can be implemented, and be prepared because I may ask you for some test images.
 
I think that if the scaling of each RGB channel is different but constant for each RGB channel then FFTRegistartion script shoud be able to realign the channels each other (two channels over a reference one). It has the option to take into account rotation and scale during the registration.

Unfortunately I've tried with your small images but the mono channels won't align, I am not sure if I misinterpret how it works or if these kind of daily images are not suitable for such task.

Maybe @Juan Conejero can provide more details on how the script works and if it's suitable for correcting this kind of chromatic aberration?
Hello Roberto,

thank you for your suggestion. Unfortunately it didn't work, the color fringing in this region of the image beacame even slightly worse. The result was: FFTRegistration only applied a translate operation.

Lateral chromatic aberration correction requires a different operation: at the optical axis, no correction is necessary at all. For the rest of the image, the needed magnification is a function of the distance to the optical axis. As Juan already wrote (he was quicker than I), this is totally different from a normal registration process.

Bernd
 
Thank you for an excellent suggestion. I'll see how this can be implemented, and be prepared because I may ask you for some test images.
Hello Juan,

thank you for responding. I was not aware of this tutorial of 2013!

I will be happy to share some test images.

Bernd
 
Hi Juan,

I tried the code snippet in the tutorial that you cited ( https://pixinsight.com/tutorials/sa-distortion/ , section "Distortion example II: Central Dilations"). With the example image (800 x 800 px), I had to set warpFactor = -65 in order to get a well corrected image.

However, the same result is obtained when the code is simplified (the variable dr and trigonometric functions are not needed here):

Code:
   function affineWarp( image, warpFactor )
   {
      var c = image.bounds.center;
      var r = c.distanceTo( 0, 0 );
      var w = image.width;
      var h = image.height;

      var work = new Image( image );

      for ( var y = 0; y < h; ++y )
         for ( var x = 0; x < w; ++x )
         {
            var dx = x - c.x;
            var dy = y - c.y;
            var fx = 2*dx*warpFactor/w;
            var fy = 2*dy*warpFactor/w;
            image.setSample( work.interpolate( x-fx, y-fy ), x, y );
         }
   }

   var window = ImageWindow.activeWindow;
   var view = window.mainView;
   view.beginProcess();
   affineWarp( view.image, -46 );  // = sqrt(65^2/2) this warp factor relates to w instead of r
   view.endProcess();

If you decide that the optical axis (default: image center) can be changed by the user, the absolute pixel values at the left and right edge of the image are different. In this case it might be more convenient to combine warpFactor and w to one linear correction factor and let the user set this parameter in the range of approximately [0.99750, 1.00250] or even better: let him set the parameter (linear correction factor - 1) in the range of [-0.00250, +0.00250]. In the latter case, a correction factor of 0 would not change anything which in my view is more intuitive.

By the way, I sent a private message to you with a link to 8 test images (TIFF format, 5202 x 3463 px). From one of them the two example images in post #1 were generated.

Bernd
 
Last edited:
Hi Juan,

the following modification of the code snippet in the tutorial that you cited ( https://pixinsight.com/tutorials/sa-distortion/ , section "Distortion example II: Central Dilations") achieves the correction of lateral chromatic aberration of daylight images. Red or / and blue channels can be corrected. The user shall input a correction factor for the red and for the blue channel. Optionally the center of the aberration (which is the image center by default) can be changed by the user. I successfully used this as a script in the processing of all my daylight images for two months.

Code:
   function affineWarp( image, corrFactor, c )

   {
      var w = image.width;
      var h = image.height;

      var work = new Image( image );

      for ( var y = 0; y < h; ++y )
         for ( var x = 0; x < w; ++x )
         {
            var dx = x - centerAberration.x;
            var dy = y - centerAberration.y;
            var fx = dx*corrFactor;
            var fy = dy*corrFactor;
            image.setSample( work.interpolate( x-fx, y-fy , c ), x, y, c );
         }
   }

   var rCorrFactor = -0.000600;               // User input: correction factor for red channel
   var bCorrFactor =  0.000000;               // User input: correction factor for blue channel
   var window = ImageWindow.activeWindow;
   var view = window.mainView;
   var centerAberration = view.image.bounds.center;    // Default for center of aberration: image center

//   var cx = ..., cy = ...;                    // User input (optional): change center of aberration
//   centerAberration = new Point( cx, cy );

   view.beginProcess();
   if( rCorrFactor )
   {
       affineWarp( view.image, rCorrFactor, 0 );    // Perform correction for red channel
   }
   if( bCorrFactor )
   {
       affineWarp( view.image, bCorrFactor, 2 );    // Perform correction for blue channel
   }
   view.endProcess();


I suggest you to create a new process in the 'Geometry' category on the basis of the above modified code snippet.


Bernd
 
Back
Top