I need for an algorithm which do steps, displayed on image below. Are solutions for doing this exist? (Preferably on C# or JavaScript).

Skyline alignment algorithm steps

  • $\begingroup$ Remember that this is a signal processing site, not a programming site, so try and avoid simply asking for source-code. $\endgroup$ – Sam Maloney Aug 2 '13 at 20:00

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. :)


I'm not expert in image processing, but if I had to try something I would

1) convert the image to grayscale
2) do some denoising (maybe with a median filter) and thresholding
3) use principal component analysis to find the orientation

  • 1
    $\begingroup$ There is no reason to think that the horizon is going to dominate the principle components. $\endgroup$ – AnonSubmitter85 Aug 1 '13 at 22:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.