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).
Think that's possible with ImageMagick? I have thousands of images that I'd like to automate the straightening of.