Considering some tweaks to the lens correction module

I’ve been wanting to learn my way around the darktable code base, and I am thinking about starting by scratching a small itch: some UI/UX improvements to the lens correction module. At least for now, I don’t intend to change the way the image is actually processed, just to experiment with how the options are presented.

Before diving too deep, I thought I share what I’m thinking of doing, and see if other people find it interesting, or if I’m being oblivious to something.

Tweak #1: how to turn on/off specific corrections

Lens correction can do 3 types of corrections: (a) distortion, (b) TC aberrations, and (c) vignette. The user can select which one they want using a dropdown, which goes:

  • none
  • a+b+c
  • a+b
  • a+c
  • b+c
  • a
  • b
  • c

To me, that seems like a convoluted and not particularly convenient way to do this, and it would feel much simpler to have 3 separate check boxes.

Tweak #2: how to see which correction is available

Lensfun doesn’t always have data for all of distortion, TC aberrations, and vignette. But the module doesn’t directly let you know what’s available. What you need to do is, using the drop down discussed above, pick what you’d like to see, and then look at the “corrections done” field to see if it’s different from what you asked. If it’s different, what’s missing wasn’t available.

Instead, I’d suggest adding, next to each checkbox, an icon of some kind (maybe ○ vs ⦿), together with a tooltip, letting you know which are available, separately from which is active.

Tweak #3: Warnings

If the lens you’re using cannot be found in the lensfun database, the modules warns you with a red triangle and a warning message. I think that’s very useful, because if you turn on the module despite it doing nothing, you might get unexpected results if a later version of the lensfun database does have info on your lens, and darktable starts applying corrections “behind your back”. Those unexpected corrections might even clash with some other edits you made.

However, I think that for the same reason, we should extend that logic to when a lens is available, but you’ve turned on a correction for which lensfun has no data. I’d still include the top level red warning triangle (or maybe just a yellow one?), but also a similar warning triangle next to the relevant check box.

Tweak #4: initialization

When the module is turned on with default parameters, currently, if your lens can be found, all 3 corrections are turned on, even if only a subset is available. Again, to avoid future version of the database silently turning on corrections which were not available when the initial edit was made, I’d like to change the initialization to only tick those corrections that are actually there.

I think that’d be more in line with the general darktable approach than the current behavior: even as new modules or new version of existing modules, or different defaults for existing modules get added in new version of darktable, they do not get auto-applied, and your pictures stay the same as you upgrade, unless you actually go and opt into the new things.

You’d still be able to manually check those corrections that aren’t available if you’d like to opt into them being corrected if a future database makes them available, but you’d get a warning, and that wouldn’t be the default behavior.

Tweak #5: manual mode

Currently, in the lensfun mode, you can apply manual vignette corrections, and you can also tick a box and apply (simple) manual TCA corrections, called TCA override. Or you can switch away from the lensfun mode, into a “only manual vignette” mode, where you can do the same manual vignette corrections, but not the TCA corrections.

I think the “only manual vignette” mode should be renamed “manual”, and that it should not only have the vignette controls, but also the manual TCA controls.

Also (but I’m less sure about that), maybe the vignette and TCA override controls should only be available in the manual mode. People who want to mix and match could use an additional module instance, one in lensfun mode, one in manual mode. That would also make it clearer how these things combine: currently, the vignette control adds to the effect of the lensfun vignette correction, but TCA override replaces it. With two separate module instances, the use can decide what they want.

Then again, for processing efficiency, maybe it’s better to keep it all available in the lensfun mode, but then I’d suggest that manual TCA should be an addition, not a replacement (and if you want it as a replacement, you untick the automatic TCA).

Or maybe there shouldn’t be a lensfun vs manual mode switch, and there should just be a “where do you get your profile from” switch, (embeded, lensfun autodetect, lensfun manual selection, none), and the manual controls would always be available below that.

Tweak #6: manual distortion correction

Having the ability to manually correct for barrel/pincushion distortion would be useful. It’s not as good as having a full lens profile, but it can help some already. The module can already handle it internally thanks to lensfun processing, so all we’d need to do is to expose this in the UI.

5 Likes

I fully agree with #1 - for #2, I’d recommend greying out the unavailable options + forcing them off.

3 Likes

This is the big change I would love to see. Please …instigate this improvement.

2 Likes

Since it is possible to have a custom lensfun database, and it is possible to exchange xmp files from one instance of darktable to another one, it is possible to set up on file on a computer where some corrections are available (and used), and then open it on another one where it isn’t.

If this happens, I’d like it for the use to be warned, and be able to do something about it.

So, even if you cannot turn on missing corrections, if they have already been turned on, I’d show a warning triangle or something like that. Users should probably be able to uncheck them when they’re in that state, even if I suppose you could always to that by resetting the whole module. But that seems a little heavy handed.

Follow up question: would you ever feel that you need to combine manual distortion corrections with the automated ones? Maybe because the automated ones are slightly off and you want to compensate, or maybe you want to cause distortion for artistic effect…

Asking to figure out if I need to be able to merge the correction parameters when they’re both present, or if it’s enough to be able to use either, but not both. (Of course, you can always use a new module instance, but I’m thinking about whether you need it in the same instance).

I can see an advantage in being able to override the supplied correction. With vignetting I sometime feel the supplied correction is insufficient. My main case use however is for unsupported lens or working scans.

1 Like

Don’t make one huge PR with a bunch of changes. Better to start with an issue (or series of issues) and the pain points you want to fix and then do a series of PRs to make small, easy to digest (and rollback if necessary) fixes.

4 Likes

Certain versions of lensfun have a function that returns the available corrections for a given entry, based on what’s available in the database. rawproc #ifdefs the capability with versions 0395 and 0399, using checkboxes for each op and graying out the ones that aren’t available. Works like a treat.

1 - 4 all sound great to me. No strong opinion on 5 or 6. Like @kofa I initially thought greyed out unavailable options would be preferable, but haven’t given it a lot of thought.

One thing I haven’t really figured out yet, is how the following variants would play with the Quick Access Panel:

  • Regular check boxes, with a separate warning label if you turn on something that isn’t available
  • Check boxes that can be grayed out
  • a composite control which contains for instance: a ○ vs ⦿ icon indicating availability, a checkbox to turn it on or off, and a red or orange triangle when you turn on something that isn’t available

I guess I’ll experiment and see how that turns out.