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.54k stars 1.13k forks source link

Additional distortion settings for perspective correction #15117

Closed zivanfi closed 1 year ago

zivanfi commented 1 year ago

Dear Darktable Developers,

Thank you for the great software. I would like to suggest a feature for consideration.

The perspective correction workflow creates a correct projection in the mathematical sense, but perceptually, the proportions in the resulting images can look "off". Take this photo for example:

20230823_201945-without-guides

The image in the middle is original photo. The one on the left has perspective correction applied and therefore it doesn't look like it is "leaning away" any more. However, despite being a correct projection, the upper sections of the church look too tall and thus unrealistic. The photo on the right is mathematically not a correct projection any more, yet to my eye it looks better, because the vertical length of the sections are closer to the original proportions:

20230823_201945-with-guides

I created the photo on the right by splitting the photo on the left (the result of the perspective correction) into several vertical sections (indicated by dashed lines) and scaling them individually to match the original proportions. (The camera was pointed slightly upwards while taking photo to put the subject in the center of the photo. Since the rectilinear projection of the lens produces less length distortion closer to the center than farther from it, the original photo has less length distortion than the corrected one.) In the ideal case, this variable scaling would be continuous. (I also stretched the photo horizontally to maintain correct proportions, but that was regular uniform scaling. I also applied one more aspect-preserving uniform scaling to line up all photos side-by-side, but that would not be necessary if we only wanted the final result.)

Based on this idea, I would like to suggest you to consider whether the result of the perspective correction could be fine-tuned with a variable scaling to counteract the length distortion of perspective projection. This would admittedly introduce another type of distortion (diagonal lines would not be straight any more), but could still improve the perceived distortion.

zivanfi commented 1 year ago

I realized that I was wrong. I looked up a photo of the same church that was taken with a telephoto lens from much farther and from a higher level so it has almost no distortions. I measured the vertical proportions of the different features and they closely match the perspective-corrected photo.

What made the perspective-corrected photo look unnatural was not the vertical proportions being off but the apparent horizontal compression: the towers seem thinner in the perspective-corrected photo than in reality. However, there already is a counter-distortion setting for this in darktable: the aspect adjust. A pleasing result can easily be achieved by tweaking that setting.