# Size of object from its image [duplicate]

If the quality of the camera (i.e. the megapixels) (assume to be $x$) of the camera is known and an object is kept a known distance from the camera (assume to be $d$), can the actual width and length of the object be determined?

## marked as duplicate by Kyle Kanos, ACuriousMind♦, John Rennie, Qmechanic♦Jul 13 '15 at 7:31

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

• You also need to know the focal length of the camera. And I assume that the camera is properly focused. – Floris Jul 12 '15 at 18:53
• – Kyle Kanos Jul 12 '15 at 19:00

## 1 Answer

Yes it can, if you know the focal length as well.

Assume that the focal length is $f$ and the distance from lens to object is $d$.

To get the object in focus, you need the distance from the lens to the sensor to be

$$f' = \frac{f * d}{f + d}$$

Once you have the distance from the optical center to the sensor, you know the magnification:

$$M = \frac{d}{f'}$$

which in most practical situations will be a "minification" (i.e. $d \gt f'$).

Finally you divide the size of the image on the sensor by the magnification to get the object size. If the image is $m\times n$ pixels of size $p$ each, then the object size is

$$width = \frac{m \cdot p\cdot d }{f'} = \frac{m \cdot p \;(f+d)}{f}$$

and similarly for the height.

Now the size of the pixels can usually be derived from the sensor type. It is not quite enough to know you have a "12 Mpix" camera, as sensors come in (many) different sizes. Typically the best cameras have the largest sensors (and large lenses). To complicate matters further, some camera manufacturers will quote the focal length of the lens in "equivalent for 35 mm" (especially for super zoom cameras with "1200 mm" telephoto capability). But that is going a bit off topic perhaps. See https://mattsassamatt.files.wordpress.com/2011/09/sensor-size7.png for a chart (somewhat out of date) of different sensor sizes, from which you can calculate the parameter $p$ I used above. Let me know if you have enough information here.

• Actually, you need a correction factor to account for the fact that the lens is not a simple thin lens. Real lenses, with complex internal structure, can be significantly longer (physically) than their focal length, and mirror lenses can be significantly shorter. – WhatRoughBeast Jul 12 '15 at 21:27
• @WhatRoughBeast as long as you measure "distance" to the optical center of the lens I am not sure a correction is needed. Are you saying that the concept of an optical center (rays go straight through regardless of angle) doesn't apply in a "real" lens? I am willing to believe you - do you have a reference? – Floris Jul 12 '15 at 22:42
• no immediate reference, just experience with camera lens data sheets. It's fairly common to see EFL (Effective Focal length) specified, with the start point for measuring EFL to the film plane occurring well behind the front element. I'll see if I can find an example. – WhatRoughBeast Jul 12 '15 at 23:33
• Here's an example going the other way. This edmundoptics.com/imaging-lenses/fixed-focal-length-lenses/… is a 1.8 mm fisheye from Edmunds. With a 52 mm body length this lens has a glass-to-image-plane length of 52 mm, but a focal length of 1.8 mm. – WhatRoughBeast Jul 13 '15 at 0:02
• @WhatRoughBeast I understand that the optical center lies well inside the body - my question is whether the sum of $d$ and $f'$ in my equation is the distance from object to focal plane - or is there some "extra"? Incidentally you mean 1.8 cm not mm I believe... – Floris Jul 13 '15 at 0:05