# Is it possible to determine elevation angles from a photograph?

I need to know the elevation angles of various 'features' in a image. I do not know the height or distance to these various features. I do know that one feature has an fixed elevation of x degrees in real life, by using an Inclinometer that is set up in the same position as the camera. There are too many features in the photo to actually measure and record in the real world.

Is there a formula or procedure to use that will allow me to programmatically determine the elevation angle of various points in the jpeg? The only other piece of information that is available is the f stop.

Is the relationship between the pixels and angles linear?

Would it be accurate to say that, if the point that is x degrees is 100 pixels above an artificial horizon, that degrees per pixel is dpp=x/100?

I apologize in advance if the question does not make sense due to the way I have described it. I just cant think of any other way to ask.

Thank you

• This is very broad, and sounds like an XY problem. Is the image aligned with the horizon, or is there at least a known 0º-elevation object in the image? Or is it perhaps an astronomy image? What is the angle of view of the camera+lens that took the image? Please be more specific with what you're trying to do with this computation/estimation.
– scottbb
Commented Jul 30, 2023 at 18:35
• I have a panorama image of the skyline around a point. The camera is mounted on a perfectly balanced turntable. The camera is 90º to the local horizontal plane, 4 feet above the surface. I am using the center of the image as the artificial horizon. The camera rotates thru 360º taking the panorama. There is a utility pole, to the top is 20º. I want to know the angle(s) from horizontal at which the top of the flag pole, the magnolia tree and a barn appears, using xy coordinates from the panorama image. I want to build a shade or shadow profile using just the image. Commented Jul 30, 2023 at 19:00
• There are methods to reconstruct a plan and elevation from a perspective rendering, but they require knowing how to generate perspective in drawing. You have some of the necessary information: the picture plane (film/sensor plane), horizontal and vertical angles of view, and vanishing points. You would need to stipulate the distance from camera to subject, and base estimates of other objects' plan positions on that. This is well into the realm of engineering or architecture, and much less so photography.
– user106382
Commented Jul 30, 2023 at 20:21
• What's this to be used for? tbh, I don't know much at all about exactly how it works, but I see this 'silver balls' setup after every scene on set, for the CGI team to generate lighting/perspective - This article starts as a history, but leads off into more practicality - beforesandafters.com/2021/04/27/… Commented Jul 31, 2023 at 18:15

From your comment, we know that you are talking about a panorama shot, and that makes things difficult. With a non-panorama single shot we can often approximate the camera's optics as doing a central projection (see Wikipedia on projections).

But for a panoramas (as done by standard digital cameras, combining multiple shots via image processing), a cylinder projection probably fits better. But it's hard to tell what the stitching process really does.

Cylinder projection treats horizontal and vertical angle differently.

The horizontal angle from 0 to 360 degrees linearly matches the x-coordinate. Hopefully, the panorama covers a little bit more than 360 degrees, so you can identify the very same objects both at the left and the right edge of the image, and compute the horizontal pixels-per-degree value.

The vertical angle does not have a linear relation with the y-coordinate, but the tangent of the angle produces $$\y\$$ (with some scaling). As $$\y\$$ value, use the number of pixels above the centerline.

$$\text{elevation} = \arctan\left(y \times {\tan(\text{refAngle})\over y_\text{Ref} } \right)$$

• $$\\text{refAngle}\$$ is the elevation of the known point, in degrees.
• $$\y_\text{Ref}\$$ is the y-coordinate of the reference point in your image, counted upwards from the center line.
• $$\y\$$ is the y-coordinate of your unknown feature, also counted upwards from the center line.

Be sure to use degrees (and not radians) when computing tha tangent and arctangent functions.

For small angles, you can approximate the tangent function as being linear (the way you proposed it in your question), but that will already give an error of 5 percent for 20 degrees.

• to OP: note that if you're making multiple calculations, $c = \tan\theta_\text{ref}/y_\text{ref}$ is a one-time calculation (i.e., a "calibration constant"). So really for every vertical pixel ("latitude") of your image, you're just calculating $\theta = \arctan(c\cdot y)$, a pretty simple calculation.
– scottbb
Commented Aug 1, 2023 at 0:55