darktable-org / darktable

darktable is an open source photography workflow application and raw developer
https://www.darktable.org
GNU General Public License v3.0
9.73k stars 1.14k forks source link

option to set default lens correction method #16724

Open hqhoang opened 5 months ago

hqhoang commented 5 months ago

Is your feature request related to a problem? Please describe. My Tamron 17-70/2.8 has incorrect embedded lens correction metadata, e.g. at 20mm or 31mm. I have to switch the method from "embedded metadata" to "Lensfun database" every time I apply distortion correction.

Describe the solution you'd like A setting/option to set the default "correction method" for the lens correction module. The embedded data from the lens is not always correct, for instance, Tamron 17-70/2.8 for Fujifilm X.

darkelectron commented 5 months ago

You can create a preset with the settings of “embedded metadata”, and auto-apply that preset to your Tamron lens. You can also have it only apply to the case of: Fujifilm X + Tamron 17-70/2.8.

Source:

hqhoang commented 5 months ago

Yeah, I do use auto-preset on other modules (exposure, color calibration, ...) However, I don't always apply lens correction, only about half of the time (e.g. if a shot at 17mm has people near the edges, applying distortion correction would stretch the people out weirdly).

Also, lens correction is a module where preset doesn't work. A preset is based on a specific focal length, and most shots have different focal length, thus, the correction will be incorrectly applied. Similarly, I couldn't copy/paste the lens correction from one photo to another unless the two photos are of the same focal length.

darkelectron commented 5 months ago

A preset is based on a specific focal length

That is incorrect, that only applies for “auto-apply” preset.

hqhoang commented 5 months ago

That is incorrect, that only applies for “auto-apply” preset.

Sigh, I'm not sure if it's a bug, but it has been that way for several years now. When I save a preset with "Lensfun database" method, the correction at that specific focal length is stored in the preset, and thus can only be applied correctly to shots at the same FL. Same problem prevents copying/pasting the lens correction from one photo to another with a different FL.

You probably can verify yourself with these steps (I'm on 4.7.0+1079~g7ebded0604-dirty):

  1. edit shot #.1 at a long focal length, e.g. 70mm in my example, apply a Lensfun distortion correction, save it as preset (e.g. "test preset at 70mm"). Note that I cannot choose what is or is not saved into the preset. Screenshot from 2024-05-05 14-58-31

  2. edit shot #.2 at a different focal length, e.g. 31mm, apply a Lensfun distortion correction, it should apply correction for 31mm. Screenshot from 2024-05-05 14-58-43

  3. apply the saved preset from #.1 to #.2. Shot #.2 now has incorrect correction of 70mm applied to it. Screenshot from 2024-05-05 15-03-36

darkelectron commented 5 months ago

My bad, I thought you meant presets in general.

PS: This related to #1990

darkelectron commented 5 months ago

@hqhoang Considering you are using the dev version, you could edit the source to make “Lensfun database” the default.

You can do this by editing the file src/iop/lens.cc:

  1. Find the method called: dt_iop_lens_method_t.
  2. Copy this line: method = DT_IOP_LENS_METHOD_LENSFUN;.
  3. Comment out the if statement.
  4. Paste what you copied in step 2, just before the return statement.
  5. Recompile.

20240506_021356

wpferguson commented 5 months ago

You could solve this with a lua script. You could invoke it with a shortcut and it could look at the values and make the correct settings.

hqhoang commented 5 months ago

You could solve this with a lua script. You could invoke it with a shortcut and it could look at the values and make the correct settings.

I'm not processing a lot photos lately so it's not urgent, thus, submitting as a feature request hoping for a proper solution. A script could work, but it's just a hacky temporary workaround. After all, what decides one correction method is better than the others to set it as default?

wpferguson commented 5 months ago

but it's just a hacky temporary workaround

The Lua scripting language is embedded in darktable. It has access to the darktable internals and is intended for extending darktable functionality when the basic functionality isn't enough, or implementing user specific workflows.

a proper solution

If you want to define how the solution is implemented, then you need to implement it.

github-actions[bot] commented 3 months ago

This issue has been marked as stale due to inactivity for the last 60 days. It will be automatically closed in 300 days if no update occurs. Please check if the master branch has fixed it and report again or close the issue.