# Is it possible to calculate the dimensions of ANY object in a picture having at some known distance an object on know dimensions?

Is it possible to calculate the dimensions of ANY object in a picture having at some known distance an object on know dimensions?

I'm thinking about the scenario where someone is holding a smartphone in one hand and on the other, or at some fixed stand, we have a W x H cm paper rectangle at some distance D cm.

Assuming some lenses characteristics, could it be possible to map the pixels to real objects and estimate their size? I can imagine how to if we assume all the objects are in the same plane or distance, but I'd like to understand the optics principles would allow us to calculate it when the objects aren't at the same distance from the camera as is the reference object.

This question here Size of object from its image answer the question how to estimate actual dimensions of an object at some known distance.

Another one Calculate the distance between two points from iPhone Camera answers how to estimate the distance of 2 objects in the same plane assuming you know the distance from the camera.

Regards

Joao Carlos

• Nope, it's not possible using a single image. However it is possible if you have two images taken from nearby cameras. This is exactly how our brain estimates the distances between your eyes and objects. If you shut one eye, this system fails. You can try this out yourself - the image appears to be flat (but you still can probably memorize approximately how far the objects are). – kristjan Aug 16 '15 at 19:57
• So, if I had 2 cameras fixed on some stand and pointing to the scene, taking the picture at the same time and knowing the distance from each one to my reference object, it would be possible? – jcarlos Aug 17 '15 at 1:01
• Yes, because it is possible to calculate the distance between the two cameras using this reference object and then you can use simple geometry. – kristjan Aug 17 '15 at 17:16

## 2 Answers

No, simply knowing the size and distance of a single object is not good enough.

That will allow you to determine the angle between any two points in a photograph, but to know the size of a second object, you have to know the relative distances to the observer of the two objects.

Obvious example: Just including the moon in a picture doesn't tell you the size of all other objects.

Disclaimer: not an optics expert.

When an image is out of focus, a point of light that would have gone to a single pixel in an in-focus pixel is instead smeared over multiple pixels. There is an algorithm for undoing this called deconvolution which has been used in practice. The process of doing deconvolution involves figuring out how big the 'smearing' is, which in turn can be used to infer how far the object is from the correct focal length. Once we know how far away the objects are, we can infer how big they are.

However, as you can see, the results aren't exactly perfect. There's a lot of noise. As a result, I don't think this process would be good for anything better than an order-of-magnitude calculation.