# Is it possible to determine from only a photo of a cityscape whether it was taken close with wide angle or from a distance with zoom?

I look after a project digitizing and providing access to vintage photos in our city. Something we've always struggled with is determining from where a photo was taken. We have data on building locations dimensions and are looking at creating a tool to determine this automatically based on tagged buildings in an image. I'm confident we will be able to find a line in 3D space on which the camera must have been. However, I don't know if it's possible to determine a point on that line.

Is this even possible?

Update: I should have mentioned this, but the end goal is to have this be an almost entirely automated process. If it takes building corner or edge level tagging or comparing things in Google Earth then we will not have the human resources to do this.

Update To be clear, I'm not asking for a programming solution. I needed to know if it was possible, even manually, before I tried to develop a programming solution. It sounds like it is.

(PS- in case it helps anyone, the method I think will work to find that line of possible camera positions is to use the centrelines of three known buildings in the photo, load their coordinates from my database, and find (either by solving equations or just iteratively) which bearing causes the ratio of the middle's horizontal span to that of the span of the leftmost's and rightmost's to match that same ratio in the photo, once that is known, the same thing can be done with the vertical span in the photo to find an azimuth.)

(PPS- The very first image I tried this on proved me wrong. Three buildings on a straight street. They are basically all in a line, spaced out by perhaps a kilometer, total). Perspective caused separation ratios in the image that can't be duplicated by rotating the 3D model about the vertical axis. It still might (probably is) possible to solve this, but it won't be as simple as I had hoped.)

• – scottbb
Commented May 16, 2019 at 20:32
– scottbb
Commented May 16, 2019 at 20:36
• Not sure if it's exactly what you want, but there a software called fSpy that can calculate all the camera/lens parameters if you select vanishing lines on it -> fspy.io/basics Commented May 16, 2019 at 23:10
• Hi pr3sidentspence, Welcome to photography StackExchange. We hope you enjoy sharing knowledge and experience here with us.
– Stan
Commented May 17, 2019 at 16:17
• Trivia: No matter what, you can be assured that the lens position determines the horizon. Everything that the horizon intersects is at the lens height. Everything below the horizon is below lens height; everything above, is above. Using "two-point" perspective, it's possible to geometrically construct a reference horizon.
– Stan
Commented May 18, 2019 at 20:42

You can often use techniques from piloting. You can find alignments in the picture, for instance the corner of a building that masks off the 2nd vertical line of windows of the building in the back. From this you determine a line on which the camera must have been. With two more such alignments you get three lines that give you a triangle in which the camera must have been, and its size gives you a degree of accuracy. Foreground elements can then give you a very precise position. GoogleEarth is your friend.

Somehow unrelated to photography, I was hunting for new housing a couple years ago and the advertisements never give the complete address, but practicing that technique using the views from windows and balcony in the advertisement pictures I was usually able to spot the building.

I am not knowledgeable on the math and programming needed for this, but I can provide you with some insights into information needed for something such.

What you want to look into, is perspective distortion in photography. In particular, you need to research lens compression (which is a bogus term, but that aside).

A quick overview of perspective distortion and compression:
In photography, the focal length of the lens used determines how wide or narrow the shot is. A small focal length means wide angle, and vice versa.
The choice of focal length does not only affect distortion, as beautifully portrayed by the GIF on the wiki page, but also determines compression.

Say, you are at 10 metres distance from Mike. You take a picture of Mike with a 50mm lens, and then move back to 40 metres and take another picture with, this time, a 200mm lens. Mike's beautiful face occupies the same space on the frame, but this time, the background seems to be way closer to him and Mike's face is 'flatter' than in the previous picture. This is what is generally referred to as compression.

Looking at how compressed the images are could possibly help you in determining the distance. This is already tricky though and would probably require a fair amount of guesswork. It does get trickier, however.

If you don't possess the original files or negatives/positives, it's not unlikely the photo you see is cropped.
Cropping further makes it difficult, because cropping affects compression, too. A picture taken with a 50mm lens cropped to half the size would look the same (from the perspective of compression) as when the photo was taken with a 100mm lens instead, from the same distance.

See the picture?

• @pr3sidentspence here's a great visual of Tim's example with "Mike" - petapixel.com/2016/07/28/camera-adds-10-pounds Commented May 16, 2019 at 18:56
• That's an interesting approach you suggest, but I think the error analysis will show that the result is highly sensitive to variations in the estimated degree of compression of a particular building, facade, etc., in OP's cityscape.
– scottbb
Commented May 18, 2019 at 20:48
• @scottbb I agree and that's why I added the last paragraph Commented May 18, 2019 at 21:32

Yes, it is possible. I am sure there will be an approach to doing this in a general way using the geometry of perspective, but here is an example of doing it in a toy example case to show it can be done. Imagine you have something like this:

Here the camera is at ground level at the left, and there are two points at an equal height, h, separated by s, with the camera being a distance D from the nearest one, and everything is in a line (let's ignore the problem that the nearest object is going to obscure the more distant one: in real life things will not be in a line like this and the maths will be harder).

You know h and s as you know what is where in the city, and you want to work out D from looking at the photograph: can you? Yes, here's how.

Let's imagine that the photograph made by the camera is projected onto a screen a distance d in front of the camera, in such a way that the images of the two points line up with their real positions as seen from the camera. By simple geometry the heights on the image of the images of the two points are

• h1 = hd/D (nearest one)
• h2 = hd/(D + s) (further one)

So now, the things we know are s, h, (from the geometry of the city), h1 and h2 (from measuring the photograph), and we don't know d (and don't care in fact), and we don't know D but do care.

So now we can do a bit of algebra:

h1/h2 = hd(D + s)/(hdD) = (D + s)/D

So

D = s/(h1/h2 - 1)

So two things have happened here, one will always happen and one is because I chose a toy example.

• d has vanished, and all that matters is the ratio of h1 and h2: this should be obvious because, obviously, we can enlarge the photo to any size we like so the only thing that can matter is the ratios of the positions on the image.
• h has vanished. This only happens because I chose both of the points to be at the same height: it won't happen in general.

Finally you can convince yourself that this expression for D is right: if h1 and h2 are the same, then D becomes infinite, and that's right, because you will only see the two towers at the same height if you are infinitely far from them. Similarly if h1/h2 becomes very large then D becomes very small, and this is right: if you're very close to one tower it will appear very big on the image.

Now, as I said, this is a toy example: in real life nothing will be lined up, everything will be different heights &c &c. But if you have enough points on the image for which you know where the real points are then you can tell where the image was made from (interesting question: how many points do you need? I suspect in general it will be 3, although it might be 4: I am sure this is known however).

I am sure that there are books on the maths of perspective, and these will have general solutions you can use: I'd recommend doing some searches on that.

Notes:

• I've assumed there is no distortion introduced by the optical system of the camera – in real life there will be some but for most lenses it should be small enough (don't try this with fisheyes or very wide angle lenses though);
• I have not thought about what camera movements (common for old LF images) might do – or rather I have thought & I haven't drawn a definite conclusion although I don't think they will matter.

The short answer is yes. It's done everyday.

Photogrammetry is measurement from images. Photogrammetry is useful for topographic mapping, architecture, engineering, or even geology! There are a lot of software tools dedicated to aerial photos, photogrammetry is really useful for geographical use. For instance, archeologists are also using it to create plans of complex and remote sites.

Photogrammetry, when I studied it, involved working from aerial photographs and translating pictorial to quantities of water and earth, and distances and directions to maps.

Later, I was able to apply the same techniques on a macro scale to the micro scale when doing research using the electron microscope. Same principles, different scale.

Software exists to apply what you know into what you want to know. A simple search for the term Photogrammetry will give you a precise source for an automated way to check. Some are online.

• Thanks, I will look into this. I had been avoiding it because I was under the impression it generated 3D models from many photos, whereas I (will) have a 3D model but may only have one photo of a feature. Commented May 18, 2019 at 16:57
• @pr3sidentspence As you have the location and dimensions of the subjects of interest, you are way ahead of the problem you want to clarify. While you may not find the exact fit due to your slightly different resources and questions, you should find a workflow for your data that works. Good luck.
– Stan
Commented May 18, 2019 at 17:39

If the picture has very little perspective, resembling an isometric drawing, it was taken from extremely far away with a telescopic lens. EG: You see two 3-storey buildings, one in front of the other. They are both about the same size in the photo.

If the picture has exaggerated perspective, it was taken from close up with a wide angle lens. EG: You see two 3-storey buildings. The one in front takes up almost the whole height of the photo, the one behind looks tiny.

And, naturally, there is a range of possibilities between these two extremes for any combination of distance and lens you can think of.

If you have the lat/lon/alt locations of features that can be associated with x/y pixel locations on the image, it can be done. I did it myself.

For a hypothetical camera position/orientation/focal length, the program computed the projected points on the image, and the offset between these computed points and the observed pixel locations. A multi-dimensional optimizer modified the camera parameters to find those leading to a minimum offset.

Even if only a few lat/lon/alt locations can be used, more hints can come from: