# How to mathematically crop photo from one camera to match view of another?

Imagine I take a photo of the same scene using two cameras, one right after the other, from the exact same spot. The cameras may be different in every way possible. They could have very different lenses, image sensor sizes, and image sensor densities, as well as other properties. I then want to crop down the picture taken by the camera with the "larger" view so that the total stuff in it matches the total stuff in the picture taken by the camera with the "smaller" view - not in terms of how things look, but in terms of what each photo contains and how much of each thing, so that at the end if you ignored depth of field, exposure, focus, etc and just looked at the contents you might say they were the same photo.

I keep reading all these articles about crop-sensors and lenses and that's great and they're giving me a great feel for the causes and effects here but I can't find a guide that describes the precise math of the situation. It seems like the two big inputs here are focal length and sensor size, and those two together will determine the field of view, and is that the key value to make the crop?

In my specific case, I'm working with mobile phone cameras and I can interrogate their specs programmatically. It happens that with iPhones I am directly given a field of view value. Is that all I need for the math? Do I simply crop down the larger field of view image proportional to the smaller? e.g. If one camera has 60 degree FOV and one has 70 degree FOV, do I just crop down the larger field of view image to be 6/7 of its original height and width? This seems correct to me but it doesn't seem to be working and I'm having trouble deciding if I'm doing the cropping wrong or if I'm just going in the wrong direction or not factoring something else in.

• Commented May 8, 2020 at 4:55
• Commented May 8, 2020 at 6:25
• Ok, I read those and like the other guides I've read they give me more confidence that I'm correct, however, could you tell me if I am correct in thinking that if one camera has 60 degree angle of view and one has 70 degree angle of view, I could just crop down the larger field of view image to be 6/7 of its original height and width? Commented May 8, 2020 at 6:26
• @KRA2008 Are you assuming the lenses used in both cameras are totally free of geometric distortion (not realistic, especially in the world of phone cameras or wider angle lenses for any camera system)? Commented May 8, 2020 at 18:47
• Are you going to take into account the different amounts each lens "breathes" (for lack of a better quick description of the term, breathes = changes focal length) as it focuses closer than infinity? Commented May 8, 2020 at 18:54

## 2 Answers

while the theoretical approach is interesting I think you will have better results with a more empirical approach.
Setup your cellphones / cameras on a tripod marking clearly its position so it is not going to move in between camera changes.
At a fixed distance setup a board with clearly printed markings. You don't need to do a lot of them. Just enough, especially towards the border.
Take pictures of this board with the different cameras.
Check the results in your computer and write down your findings. How much do you have to crop out in order to go from camera A photo to camera B?
Make a matrix of this crop factors for all of your cameras combinations (which I presume are not too many to do this).

• Well, this is for an app with thousands of users so yes, there actually are too many camera combinations to do this. However, I will try it with the phones I do have. Thanks. Commented May 9, 2020 at 14:20
• I had not realized you were writing an app. Then my approach won't suit you. Actually it may give you false bases if you try to generalize what you may obtain through comparison of just a few cameras. Lens data are not going to be enough to set a rule as also the used sensor plays a role. I don't know if you have access to sensor specifics too. Commented May 9, 2020 at 14:31
• I do have access to specifics. In fact, iOS gives me a property they're calling VideoFieldOfView which they say "indicates the format’s horizontal field of view in degrees." So assuming that value is correct, do you think my original math/logic checks out? Commented May 9, 2020 at 17:48
• My understanding is that differences in focal length and sensor size can be boiled down to differences in the angular field of view, right? Commented May 9, 2020 at 17:49
• Am afraid I don't know enough about this. Among other factors I would think that different lens would give you different results, even with the same field of view degree. We can't just assume they are all perfectly rectilinear lenses. Actually most likely they aren't. Commented May 9, 2020 at 18:36

After some more digging and thinking I've found there are two reasons the approach I outlined in my question won't work.

1. The math is wrong. (but can be corrected)
2. The phones are wrong. (but cannot be corrected)

#2 is the more serious blocker which makes #1 kind of irrelevant. It just really looks like the angular field of view provided by the code does not match what is observed experimentally. It's also only provided by iOS - Android has stopped providing a value in the newest versions.

For completeness, I'll describe the math more but it's pointless anyway. The problem with the math is the lack of trigonometry. A diagram is probably the best way to show the situation:

(CORRECTION: I used tan wrong above. It should be tan(theta/2)=t/2d and tan(phi/2)=p/2d)

Because my answer is ultimately that this problem cannot be solved because of the uncooperative devices, I won't go through solving the equations. However, from that diagram you can solve for the things you need in order to do the cropping, but again, it will fail because the angular field of view given by the phones is either wrong or is simply not provided.

• Part of the problem is that any rectangular image that is not a square has three angle of view measurements: horizontal, vertical, and diagonal. Some cameras/phones measure along the horizontal axis (the longer side of the rectangle in landscape orientation), some measure along the diagonal axis. The mathematical relationship between the two also varies as the aspect ratios vary. The diagonal of a 3:2 aspect ratio sensor is ≈1.2X the long side. The diagonal of a 4:3 aspect sensor is 1.25X the long side of the sensor. Commented Apr 18, 2022 at 3:03