Fix lensfun-based distortion correction - #1681
Open
duddel wants to merge 1 commit into
Open
Conversation
Author
|
Sounds similar to #990. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Applying lensfun data to my lens (Nikkor Z 24-70mm f/4 S) yields, what looks like, overcompensation, especially in image center.
For comparison, I checked darktable 5.6.0 against RapidRAW 1.6.2. Both use the exact same lensfun value for my lens, but the first tool generates matching results to the in-camera jpeg processing. I think darktable uses the lensfun reference implementation.
After digging into the code, I found 3 issues.
(1)
lens_dist_amthas an arbitrary scale of2.5. While this makes sense to increase sensitivity in certain cases, here it does not. Thelens_distortion_amountfrom GUI is scaled to[0, 2], default1.0(slider value100). To get the vanilla correction factor, the slider value would need to be40.(2)
The
half_diagonalis used for the normalizedradius(ptlens,poly3,poly5), but it must be the "half short edge of the image". Vignetting still uses the half diagonal.(3)
The
poly3model defines onlyk1, which boils down toptlensmodel witha=0, b=k1, c=0. (Not relevant for my observation, but still an issue)I hope I found all occurrences where this is relevant.
This PR should fix most of the issue, but we might also need to consider image aspect ratio vs. calibration aspect ratio.
Also, not sure if TCA also needs a treatment.
References: lensfun code and docs.
Type of Change
Changes Made
(1)
Removed the
2.5scaling factor(2)
Using "half short edge of the image" now
(3)
added distinct
poly3case inextract_dist_params()Screenshots/Videos
Can supply example image if required.
Testing
Test Configuration:
Checklist
Additional Notes
AI Disclaimer:
Please state the involvement of AI in this PR: