Automatical skyline alignment on image
You could try detecting line segments in the image for example using hough transform, or maybe lswms, edlines or lsd.

After detecting the lines, you can compute their length and angle and find the longest almost horizontal line. If you are lucky, this line will be the horizon and you can rotate the whole image in the opposite direction to get the aligned image.

This might work but it will depend on how good the horizon is visible and how well it is detected.

Maybe you could find a number of potential horizon lines and have the user select the best one.

On second thought, if you involve users into this, just let them draw the horizon and then rotate the image. That's not really what you were asking for, but it will probably work better than what I suggested above. :)