Please help me to understand new Chromatic Aberration controls (and a few other questions)

Hello everyone,

Firstly, many thanks and deep appreciation goes to the genius community of developers for the recent V5.5 release. I truly believe RawTherapee offers me superior image processing quality and have never switched back to Adobe Camera Raw for my photos.

I was very excited to see new Auto CA controls in V5.5. I have some questions:

  1. Are there any image quality disadvantages to using multiple levels of iteration for auto CA correction? (Apart from the hit on processing speed.) That is, is a setting of 5 always (apart from gross bugs which I’ve seen a bit of on github, which isn’t related to the level setting) going to be better than a setting of 1 for image quality?

  2. Why should the auto CA removal by default be so conservative and thus require an option for an additional 5 levels of CA correction? Please help me understand the process. Is it because it is not easy to estimate the amount of CA to be removed on the first iteration?

  3. In the one image I’ve tested and studied closely, there is absolutely zero difference above 3 iterations. 3, 4, and 5 all give exactly the same result. Under what conditions would/should I expect to see that 4 and 5 iterations would give an even cleaner result?

  4. I understand that auto CA in theory can be superior than manual correction, since it divides the image into blocks rather than applies the same correction to the whole image, and thus is able to correct radially asymmetric CA. May I know what is the pixel dimensions of each block it divides the image into? Or is it a fixed arbitrary number of tiles regardless of the pixel dimensions of the raw file?

  5. CA removal in RT is applied prior to demosaicing, and shifts the three colour channels. Since the movement is never always in whole pixel steps, some resampling must be done. What is the interpolation used? Bicubic, Lanczos or something else?

  6. Not exactly related to CA, but on the topic of interpolation, under “Transform>Resize”, does the choice of interpolator (Bicubic, Lanczos(3,4,8?)) affect what is used to resample the image for lens geometry corrections, and rotations (horizon levelling)? If not, I would appreciate being directed to the correct information. I’ve asked about it quite some time back, and apparently it’s bicubic. I was wondering if it would be possible to also have the option to use the sharper Lanczos interpolator. I understand that it’s arguably less mathematically “correct” and has the tendency to produce ringing artifacts with large window sizes.

  7. What is the window size used for the lanczos interpolation implemented in RT?

Edit:
8. Exactly what does “Avoid color shift” do?

I’ve been trying to dig through the RT Github page with little success in getting to the bottom of these questions. I do not have a programming background, so please be patient with me. Thank you!

1 Like

Interesting topic (with a long title :stuck_out_tongue:). I posed a similar question recently that someone could help answer here as well:

What is the step-by-step approach you would take to handle CA and fringing using RT?

Implicit in my question is the context where I have trouble with colours. Not talking about colour blindness; I just process colour differently and that makes it hard to work with colours. Maybe I need an assistive tool like the sharpening contrast mask but for CA and fringing…


Back to @samuelchia’s questions. I don’t know anything about the underlying algorithms, but here are my (uninformed?) thoughts based on my introductory experience with the CA tool, to jump start this conversation.

1-3. Auto CA is quite powerful. It doesn’t require any user interaction and does a decent job. I prefer it that way, though of course the algorithm, thresholding, etc., always has room for improvement. The only real way to gauge its robustness is to subject it to heavy testing and comparison.

But some user input is necessary because circumstances are different for every image. That is where the iterations come in. When it comes to iteration, having a conservative algorithm is vital. That is the only way it can be useful. I.e., 1 iter is probably minimal and max iter is probably a little overboard. Again, the number would likely need some tweaking based on user feedback.

If there is no difference from 3+ iterations, this means that that is the best that Auto CA can do, even if it weren’t so auto and you could manage its parameters.

One last thing about iteration is that certain algorithms and techniques stack well when repeated and some not as much. However, in my mind, informed by some of the papers I have read, an iterative technique is often less robust than a non-iterative one. The former, however, is often faster and simpler to process.

4-6. As for interpolation, Lanczos isn’t automatically best for everything. Each technique has its pros and cons, although your questions suggest that you would like more control over the technique and tiling. Maybe the RT devs could open up some expert options for you. :wine_glass:

The thing I would say is that I would rather have a smoother interpolation than a sharper one since sharper ones, and ones with lobes or moire, generate more artifacts and general nastiness that I wouldn’t want to have to accept or correct afterwards.

That said, all interpolation is somewhat detectable. If you have any experience with image forensic tools, you would know what I mean. Or try using my “hessian norm” G’MIC filter after you do a lens correction; you would be able to see the ripples that way.

PS Perhaps sharing a diverse set of sample images would help further our discussion. :wink:

Hi @afre, thanks for sharing your thoughts.

I find this to be rather straightforward. CA correction should be done automatically or with a custom (not generic) lens profile for your own lens, because manual correction cannot deal with the radial asymmetry that all lenses suffer from. I always use auto CA correction for all my images, and I haven’t found a single situation where it gives a worse result than no or manual correction, gross bugs excluded. Thereafter, whatever colour fringing remains is probably longitudinal CA which cannot be removed by shifting the colour channels, and it’s the job of the defringe tool to assist you further. Residual colour fringing artifacts could also be false colour from demosaicing. I’ve noticed that VNG4 makes my astro stars have green fringes, not present with AMaZE, DCB or RCD.

Edit: I think the CA tool has been around for a long time and (I’m assuming) hardly anyone has issues with the auto correction. There are very few threads here regarding that. I’m not trying to find fault with it. In addition, I’m not really interested in treating super gross lens defects. I tend to think that the auto CA fails mostly on really poor images. I think it performs excellently on most regular images made with a decent quality lens. Manual correction can be quite hard to nail precisely sometimes. But now that I think about it…I’ve maybe got one problem image I want to save which failed with auto CA correction. Time to dig it up again…

I think the problem is many are obsessed about precision of all sorts which are virtually never visible in the way we present our images. Recently I’m having some trouble convincing Graeme Gill of ArgyllCMS that the added precision of device-link profiles are never visible with regular conversions even for high-end printing (there’s some kind of issue with how the ICC profile’s BtoA tables are generated). I think the more important question is what looks better at the end of the day? Are the artifacts tiny and inconsequential and will pass undetected to virtually anyone? Is the final result sharper in a good way? Is it beautiful?

Edit: So even though false colour artifacts and moire are more prevalent with AA-filterless sensors, the industry has largely moved towards such constructions for all the highest resolution 35mm format cameras. I’m not saying I like this change however :slight_smile:

Sure, though I’m unsure as to what kind of samples I should show, because I’m not actually trying to create an issue, rather understand how the tools currently work.

2 Likes

Oh, I forgot to ask one more thing, edited first post with additional question:

  1. Exactly what does “Avoid color shift” do?
1 Like

Morning, @samuelchia,

https://rawpedia.rawtherapee.com/Lab_Adjustments/de#Avoid_Color_Shift

Have fun!
Claes in Lund, Sweden

  1. For general use iteration of max. 2 is recommended. Higher values can result in a visible color shift even if “Avoid color shift” is on.

  2. Because of possible color shift.

  3. Images with heavy CA’s

  4. I don’t know. :slight_smile:

  5. I don’t know. :slight_smile:

  6. I don’t know. :slight_smile:

  7. I don’t know. :slight_smile:

  8. “Avoid color shift” avoids color shift :smile: and for general use it should be on.

Thanks @Claes! I’m assuming that the “Avoid color shift” checkbox for all tools perform the exact same function as the one for Lab adjustments?

Thanks @TooWaBoo for clarifying some of the details. The tip to use a max of 2 is very good. I’m actually not able to detect colour shifts at the max setting, even though I’m usually quite good at spotting such things. I’m assuming it’s highly dependent on the image content.

Then this checkbox should be checked by default all the time? Why should we ever want the colour to shift anyway? Why is there even a checkbox for this? Why not hardcode the prevention of colour shift all the time?

1 Like

Avoid Color Shift

Fits the colors of the image into the gamut of the working color space and applies Munsell correction to retain color purity.

Hmm, this makes no sense in the context of CA correction to me?

1 Like

The CA correction prior to 5.5 had three main drawbacks:

  1. Often CA was not completely corrected. There was still some CA left over.
    So I just tried out applying another step of CA correction on the result of the CA correction, and it worked.
    In my tests 2 iterations gave a better correction than 1 iteration in the majority of cases. For some images using 3 iterations gave a small improvement and for 1 image 5 iterations were needed.
    That’s why default is 2 and max is 5
    The iterative approach also has the nice feature of being backwards compatible.

  2. There was a bug in old ca correction, which is fixed now. This bug is fixed also in darktable.

  3. CA correction often introduces a small color shift (often a desaturation). Using the iterative approach this effect unfortunately enhanced. For this reason I implemented the ‘Avoid color shift’ which works completely different than the ‘Avoid color shift’ from other tools in RT.

The image is divided in tiles of 112x112 pixels. It shifts only red and blue channels. Green channel is not modified.

2 Likes

There are some corner cases where it leads to artefacts.

1 Like

Excellent information! Thank you @heckflosse!

I’m just now looking at one of my raw files and seeing that 2 iterations seems to be introducing more resultant error than 1 iteration. It’s very subtle however, and I cannot definitely say so yet. You say “the majority of cases”, have you ever experienced a situation when 2 was worse than 1 (apart from more desaturation)?

Wonderful! The shifting is never in whole pixel steps, I’m assuming. If so, do you happen to know what interpolation is used?

I’m assuming you are referring to this?

1 Like

Yes, if there is no CA in the image. But then even 1 iteration can be worse than no CA correction

No, this was a bug during development of the ‘Avoid color shift’ feature, which is fixed.

1 Like

I see, thank you!

Do you mind expounding on this?

1 Like

I’m already looking for an example.

1 Like

I shall patiently await then! :slight_smile:

1 Like

The 5th sample raw image from here

Left without ‘Avoid color shift’, right with

1 Like

Mainly bilinear interpolations.

1 Like

I also detected that sometimes. But it was a false positive in most cases caused by ca correction in lens correction tool being also enabled. These tools naturally don’t play well together.
Unfortunately the current ‘default’ profiles have both enabled. I will open an issue…

Here’s a comparison:

2 Likes

Very interesting, thanks. I’ve just noticed with a different test image, that the amount of colour shift by checking “Avoid color shift” is actually greater than the amount of shifting with it checked. Unchecked, the red channel decreased by 1 point from the original value. When checked, the red channel increased by 2 points from the original. It would seem that any such shifting would be more obvious in neutral or near-neutral colours, such as this sky-dominated example, except the shifting is much more severe.

I haven’t actually found a case where checking it actually produces a better result, but I haven’t tested it extensively yet. At the moment, I would actually recommend, against @TooWaBoo’s advice, to leave it off most of the time.

It’s interesting that I’m not detecting a much less sharp result, unlike regular image resizing with Bilinear vs Bicubic. However, one wonders how much better it could be with bicubic?

Ooh that’s interesting. However, I think that CA correction should always be disabled in the lens correction tool.

What I saw was a false positive in out-of-focus areas, but then also the in-focus area shows a subtly worse result. It’s barely visible. It’s a strange thing alright.

In-focused example, 2 iterations is very, very subtly worse. Impossible to tell at 100% zoom, requiring 200% or more to see. Here it is at 400% zoom:

Another crop from the same image, but from out-of-focus section, 2 iterations introduces more CA:

1 Like

Here’s a sample of that. It just so happens that the sample point I picked is even more in favour of unchecking “avoid colour shift”:

It seems to do more harm than good? Slight desaturation from CA removal should be totally inconsequential and it’s hard to imagine anyone being bothered by it. It’s easy to boost saturation with the many other tools.

1 Like