I'm trying to calculate the size of an object in pixels in an image, when I have these information:

x * y = the size of the real object in meters
q = the quality of the image in ppi
d = the distance between object and the camera in meters

Do I have to know the size of image as well? If so, how can I calculate the size of the object in pixels?

I don't know if I need to use the crop factor, sensor size, etc.

  • \$\begingroup\$ Related as well to photo.stackexchange.com/questions/48218/… \$\endgroup\$
    – Linwood
    Jun 12, 2017 at 14:15
  • 2
    \$\begingroup\$ It is worth noting as well that "dpi" is a much abused term as it may relate to image scale for export/print as well. Can we assume here you are referring to sensor site pitch, or more specifically how many de-mosaic'd dots are produced per inch of sensor? \$\endgroup\$
    – Linwood
    Jun 12, 2017 at 14:18
  • \$\begingroup\$ You also need the focal length and sensor size of the camera. This should be a big help to you: scantips.com/lights/subjectdistance.html \$\endgroup\$
    – WayneF
    Jun 14, 2017 at 2:20

2 Answers 2


If you know the actual width or height and camera-to-object distant, you can easily calculate a ratio size-to-distance.

Say a object is 3 meters wide and a picture is taken with the camera positioned 12 meters from the subject. The ratio size-to-distance is 3÷ 12 = 0.250.

Inside the camera, the image forming rays from the lens, trace out the same ratio as they travel. In other words, the projection distance inside the camera and the image size yield the same ratio. If one of these values is known, the other is easily calculated.

Likely, of the two, the projection distance is the most easily discoverable. This will be the focal length of the lens at the time the picture was taken.

Suppose the camera’s zoom lens was set to 50mm (or a prime 50mm was used). The span of the projected image will be 50 X 0.250 = 12.5mm.

From the camera specification sheet, we can discover the pixel pitch. Suppose the center-to-center pixel spacing is 3.89 µm (micrometers), 0.00389mm.

Now we calculate the span of the image in pixels is 12.5 ÷ 0.00389 = 3214 pixels (rounded up).

The span of the image covers 3214 pixels = 12.5mm

  • \$\begingroup\$ What if the 3 meter wide object is not occupying exactly the width of the sensor? \$\endgroup\$
    – Michael C
    Jun 12, 2017 at 21:13
  • \$\begingroup\$ @ Michael Clark - My example is the easiest! One could back up, one could choose another smaller object. Best if you carry a meter stick and place it adjacent to the subject. One can latterly count pixels. What would you suggest? \$\endgroup\$ Jun 12, 2017 at 22:22
  • \$\begingroup\$ It is the easiest, perhaps, but it doesn't answer the question as asked. The photographer may not have physical access to get close enough or enough focal length to fill the frame with the subject from the nearest available shooting position. Perhaps the entire point of the question is to determine if a certain focal length from a certain distance will give enough pixels to produce a crop of sufficient quality of an object a specific size? \$\endgroup\$
    – Michael C
    Jun 12, 2017 at 22:33
  • \$\begingroup\$ @AlanMarcus thank you very much for the helpful answer, but as Michael Clark suggests the objects in images are very small. I am trying to calculate the size of vehicles in aerial images (e.g 100 pixels wide in a 1024 pixel image) and it should be quite accurate. \$\endgroup\$ Jun 13, 2017 at 15:03
  • \$\begingroup\$ The ratio method works both ways: Pixel spacing center to center is 0.00389 and the image overlays 10 pixels then the image length is 0.00389 X 10 = 0.389mm. If imaged using a 500mm lens, the ratio of image to focal length is 0.389 ÷ 500 = 0.000078. The image was taken from aircraft flying at 22,000 feet. The object’s length is 0.00078 X 22000 = 17.16 feet = 5.23 meters. \$\endgroup\$ Jun 13, 2017 at 16:42

I'm not very sure, but here goes


Scale factor=f/d //f is the focal length in metres
x'=x*f           //x' length of image in metres
y'=y*f           //y' breadth of image in metres

Convert dot per inch into dots per metres


Convert from metres to pixels



Not the answer you're looking for? Browse other questions tagged or ask your own question.