Signal Processing Stack Exchange is a question and answer site for practitioners of the art and science of signal, image and video processing. It only takes a minute to sign up.Sign up to join this community
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. :)