Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
I've searched quite a bit yet haven't been able to find any software that appears to be able to do automatic horizon correction. However, I did find this:
Horizon detection in still images or video sequences contributes to applications like image understanding, automatic correction of image tilt and image quality enhancement. In this paper, we propose an algorithm for detecting the horizon line in digital images, which employs an edge-based and a new color-based horizon detection technique. The color-based detector calculates an estimate of the horizon line by analyzing the color transition in the clear sky areas of the image. The edge-based detector computes the horizon line by finding the most prominent line or edge in the image, based on Canny edge detection and Hough transformation. The proposed algorithm combines the two detectors into a hybrid detection system, thereby taking advantage of their complimentary strengths. We have applied the algorithm on a manually annotated set of images and evaluated the accuracy of the position and angle of the detected horizon line. The experiments indicate the usefulness of the proposed color-based detector (40% lower error vs. the edge-based detector) and the benefit of the adopted approach for combining the two individual detectors (57% and 17% lower error vs. the edge-based and the color-based detectors, respectively).
IM has no such technique to my knowledge and without knowing exactly how it works, I doubt anyone will want to spend much time on it, but I could be wrong. It would appear to be a rather difficult concept and very image dependent, especially depending upon how separable in color, texture and content the sky is from the ground and with many possible obscurations such as trees and buildings. Ideas and suggestions are certainly welcome from others.
A Hough transform generally detects straight lines (or specific shapes such as circles). More specifically, once you have generated a straight line edge segment, it computes the orthogonal distance from the origin to the line and direction of the line.
However, any real horizon as seen in an image will not generally be straight as it will follow the terrain or be obscured by buildings and trees, etc. Thus a clear definition of what is meant by "horizon" is required. In fact, the true horizon will follow the curve of the earth, however, a picture, depending upon the height taken, might not even see to that horizon. The picture horizon may be even closer. A perspective horizon from a flat plane is also a very different thing.
Furthermore, it is not clear what one's goal is if any proper horizon can be detected? What is meant by "straightening"? Is that correcting for perspective tilt or just rotating the image? The former is very hard, since the location of the horizon line depends not only on perspective tilt, but height from which the image was taken. The latter may be a more reasonable goal.