One way that does not depend on selecting a threshold for your image is to use the radon transform. Look how I used it to rotate the football to the two image axes:
Basically the radon transform gets the projection of the image along a line perpendicular to the projection direction. This is the concept of CT - computed tomgraphy - and MRI. You can just read off the angle by looking at the maximum of the radon transform, then call imrotate() to do the rotation by that angle. See attached demo script. Adapt as needed.