Can software automatically level a photo by detecting horizons or vertical lines?
Asked 12/7/2010
5 views
2 answers
0
Is there any standalone software or Lightroom/Photoshop plugin that can analyze a photo, detect lines that should be horizontal or vertical (such as a horizon, buildings, or poles), and then automatically rotate and crop the image? I currently do this manually and would like to know whether reliable automatic leveling tools or approaches exist.
Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0
Photography Stack Exchange contributor
15y ago
2 Answers
5
There may well be programs that attempt to do what you describe, but I'm doubtful it would be that effective. If the camera is pitched up or down slightly then you could have a perfectly level image, despite not having a single horizontal or vertical line.
The reason for this is that unless your camera is dead flat along the optical axis (that runs parallel to the lens) then your telegraph poles etc. won't be vertical in an image, even if the camera is level - the lines will all converge on an imaginary vanishing point in the sky. Likewise, if the camera is not face on to a true horizontal line it won't be rendered horizontal in the image.
It's possible to employ a more sophisticated approach, by either trying to identify the horizon in images, or even better grouping lines that share a common vanishing point, estimating the pitch angle and thus the correct angle to rotate the image, but such a process would be considerably more involved.
Originally by user1375. Source · Licensed CC BY-SA 4.0
user1375
15y ago
0
Generated from our catalog & community — verify before relying on it.
Partly, but not reliably for every image.
Automatic leveling can work in simple cases, especially when there is a clear, dominant horizon. A common approach is line detection (for example, using a Hough transform in OpenCV), then rotating the image based on the strongest near-horizontal or near-vertical line.
The limitation is perspective: if the camera is tilted up/down or not square to the scene, lines that are truly horizontal or vertical in the real world may not appear horizontal or vertical in the photo. They can converge toward vanishing points, so a purely line-based algorithm may “correct” an image that was already properly shot. Curved shorelines and scenes without obvious reference lines are also hard for software to interpret correctly.
So yes, tools and algorithms exist, and they can be useful when the scene contains an obvious horizon or strong architectural lines. But fully automatic leveling is scene-dependent and won’t always be accurate without human review.
Recommended products
UniqueBot
AI15y ago
Your Answer
Related Questions
Can you offset the rotation preview grid in GIMP when straightening an image?
Is there free software to automatically split and crop multiple photos from one scanner image?
What software can straighten a tilted photo or correct perspective distortion?
Can Lightroom add black bars to a photo without using Photoshop?
Why don’t two 180°-rotated flatbed scans align perfectly across the page?