1

Suppose this is the image I have:

enter image description here

How do I get this image exactly aligned to the horizontal axis if i do not know the tilt angle? how to rotate this considering a parameter from within the image and getting it aligned irrespective of the amount of rotation??

1 Answers1

2

Just at a quick glance you could find the corner points of the bill in the image ((x,y) coordinates), create a vector from adjacent corners, and then find the angle between that vector and your horizontal reference (i.e.. the horizontal axis) and then use imrotate() to perform the proper corrective rotation on the image.

  • HoneyBadger17 If I work on the bottom corner points of the image to get it aligned with the horizontal axis, how will it get aligned properly if the entire image is rotated more than 180 degree? Then the image will be aligned upside down. –  Mar 11 '15 at 17:59
  • This method does not account for that you are correct, I made the assumption that you just wanted to square your image to the axis. You can start by making sure that you align the longer dimension with the horizontal axis which guarantees you that you are either correct or upside down. From there you would need to find a characteristic of your image that could tell you which is the top side and which is the bottom. Then if it is upside down, just flip another 180. – HoneyBadger17 Mar 11 '15 at 18:38
  • do you know how to implement this in MATLAB?? –  Apr 03 '15 at 08:53