0

I am trying to calculate the dimensions of an object in an image. This is a sample image I took to get height of blue shirt:

Image of blue shirt

I am following the math from this page with sastanin's answer. How do I calculate the distance of an object in a photo?

The real height of the object is ~90cm, so X=0.9m. I took the image from 92inches away so d=2.3368m. I used a Samsung note 4 phone to get the image. They have a focal length of 4.8mm, so f=4.8mm. They also have 72ppi. I emailed myself the image and opened in photoshop, and measured the pixels of the blue shirt in height, and it came to 1690pixels.

If I convert it to mm using the ppi, I get x=596.19mm.

So then using the equation, I am getting

(596.194444444/4.8)*2.3368 = 290.247328703 which says the shirt is ~290m in height.

So there is clearly something wrong with the math here. Does anyone know?

EXIF data:

ExifTool Version Number         : 10.01
File Name                       : 20160715_202056.jpg
Directory                       : .
File Size                       : 4.1 MB
File Modification Date/Time     : 2016:07:15 22:12:49-04:00
File Access Date/Time           : 2016:07:15 22:13:05-04:00
File Inode Change Date/Time     : 2016:07:15 22:13:02-04:00
File Permissions                : rw-r--r--
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
Exif Byte Order                 : Little-endian (Intel, II)
Make                            : samsung
Camera Model Name               : SM-N910W8
Orientation                     : Rotate 90 CW
X Resolution                    : 72
Y Resolution                    : 72
Resolution Unit                 : inches
Software                        : N910W8VLU1DPE2
Modify Date                     : 2016:07:15 20:20:55
Y Cb Cr Positioning             : Centered
Exposure Time                   : 1/10
F Number                        : 2.2
Exposure Program                : Program AE
ISO                             : 400
Exif Version                    : 0220
Date/Time Original              : 2016:07:15 20:20:55
Create Date                     : 2016:07:15 20:20:55
Components Configuration        : Y, Cb, Cr, -
Shutter Speed Value             : 1/10
Aperture Value                  : 2.2
Brightness Value                : -1.35
Exposure Compensation           : 0
Max Aperture Value              : 2.2
Metering Mode                   : Center-weighted average
Light Source                    : Unknown
Flash                           : No Flash
Focal Length                    : 4.8 mm
User Comment                    : .
Flashpix Version                : 0100
Color Space                     : sRGB
Exif Image Width                : 5312
Exif Image Height               : 2988
Interoperability Index          : R98 - DCF basic file (sRGB)
Interoperability Version        : 0100
Sensing Method                  : One-chip color area
Scene Type                      : Directly photographed
Exposure Mode                   : Auto
White Balance                   : Auto
Focal Length In 35mm Format     : 31 mm
Scene Capture Type              : Standard
Image Unique ID                 : H16USHH04SA
GPS Version ID                  : 2.2.0.0
Compression                     : JPEG (old-style)
Thumbnail Offset                : 3318
Thumbnail Length                : 7352
Image Width                     : 5312
Image Height                    : 2988
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
Aperture                        : 2.2
Image Size                      : 5312x2988
Megapixels                      : 15.9
Scale Factor To 35 mm Equivalent: 6.5
Shutter Speed                   : 1/10
Thumbnail Image                 : (Binary data 7352 bytes, use -b option to extract)
Circle Of Confusion             : 0.005 mm
Field Of View                   : 60.3 deg
Focal Length                    : 4.8 mm (35 mm equivalent: 31.0 mm)
Hyperfocal Distance             : 2.25 m
Light Value                     : 3.6
2

PPI has nothing to do with the calculation. I calculate the Note 4's 1/2.6" sensor's dimensions to be about 5.80mm × 3.27mm. So using 5.80mm as the sensor height (the image is in portrait orientation, so we need the sensor's long dimension for image height) in the equation in Matt Grum's answer in the question you linked to, and rearranging the equation to solve for 'real height(mm)',

enter image description here

Which agrees with your ~90cm jacket height.

3

You are missing something big. The size of the camera sensor is not mentioned. You need to know it, both in mm and in pixels. You didn't say any sizes, but Samsung says 3.7 megapixels, so if 4:3, that is 2221 x 1666 pixels. Samsung specs don't say. Your image will be this size though, you can know its pixel dimensions.

The sensor mm is pretty difficult to determine on most phones. At most, the Samsung Note 4 says it is a 1/2.6" sensor, but this is a fake number, not a real dimension of anything. Wikipedia says a Nokia 1/2.5" is 5.76 x 4.29 mm, but that's not real helpful. All we know though.

Not sure what you are trying to calculate, you seem to know both the size of the object and its distance. The formula you found calculates distance, not size. Here is a calculator that also computes distance, not size. http://www.scantips.com/lights/subjectdistance.html

Both require knowing sensor size, in mm and in pixels. If you knew crop factor, the calculator can compute sensor size in mm. I dare say this is is unknown too though.

Sensor height 4.29mm
Focal length 4.8mm
Sensor size 1667 pixels
Subject size 596 pixels
Subject height 0.9 meters

Then Subject Distance 2.82 meters

So these numbers from plugging in your numbers and my guesses, it computes distance as 2.82 meters, which you said was 2.3 meters. Seems halfway close, since we don't know the numbers.

This works better with bigger cameras for which we actually know specs.

EDIT: Your detailed Exif helps.

It says Image Size : 5312x2988
Megapixels : 15.9
Focal Length : 4.8 mm (35 mm equivalent: 31.0 mm)

Not 3.7 megapixels anymore. :) And 5312x2988 is 1.78 aspect (HDTV). So calculator says with camcorder crop factor of 31/4.8 = 6.48x (compared to 35mm film). We know the size of 35 mm, so using diagonals, it computes sensor height to necessarily be 5.84 mm height.

Other sources say Samsung 1/2.6" is 5.5x4.1 mm (4:3), close to Scott's numbers (but his is 1.44:1, which may be a typo?). I am not aware of where Samsung says it. However your image size says 5312x2988 which is 1.78:1 HD, camcorder mode. That wider image is necessarily shorter height.

Anyway, from that, and corrected to portrait orientation, it computes sensor height (long dimension) as 5.84 mm and the distance computes 2.33 meters, using the numbers we can guess at.

http://www.scantips.com/g2/dist2.png

FWIW, the Exif says 15.9 megapixels (5312x2988 is 15.872 megapixels).

This 15.872 mp allows:

Aspect ratio 1:1 / 3984 x 3984 pixels = 15.872 mp

Aspect ratio 4:3 / 4600 x 3450 pixels = 15.870 mp

Aspect ratio 3:2 / 4879 x 3253 pixels = 15.871 mp

Aspect ratio 16:9 / 5312 x 2988 pixels = 15.872 mp

But 16:9 in a 15.87 mp 4:3 sensor can't be wider than the chips 4600 pixels,
so that 16:9 movie mode would be 4600x2587 pixels But this image is 5312x2988, so this is NOT a 4:3 chip, but 15.87 mp can only be a 16:9 camcorder chip.

  • Comments are not for extended discussion; this conversation has been moved to chat. – John Cavan Jul 17 '16 at 12:41
2

@omega Here's what you are not getting: The 36x24 measurement is the size a classic photo negative taken with 35mm film.

It is a well known and accepted measurement. 35mm film was a very commonly used film for 60+ years. Because format size (sensor or film size) determines angle of view for a particular focal length lens, and because 35mm film was so common for so long, many photographers associate a particular focal length when used with 35mm film with a particular angle of view.

The 43.27mm diagonal of a frame of 35mm film divided by the diagonal of any sensor (or film) gives the camera's "crop factor".

  • If the EXIF gives the actual focal length of the lens and also gives the (35mm) equivalent focal length of the lens then dividing the EFL by the FL will give you the camera's "crop factor".
  • You can then divide the 43.27mm diagonal of a 35mm film frame by the camera's "crop factor" to get the diagonal measurement of the camera's sensor.
  • You can derive the ratio of the sensor's width and height by comparing the number of vertical and horizontal pixels in the EXIF info (Image Width/Image Height)
  • You can then use trigonometry to derive the measurements of the sensor's vertical and horizontal dimensions because you now know the length of the diagonal of the right triangle formed by the length, height, and diagonal of the sensor and you know the ratio of the width to height of the sensor.
1

We draw imaginary line from the top and bottom of the object to the center of the lens. This traces out the image of a triangle. The base of the triangle is the distance, object to lens. The base of this triangle is the object’s height = 90 cementers X 10 = 900mm.

The height of this triangle is the distance lens-to-object = 92 inches = 92 X 25.4 = 2336.8mm.

The ratio of base to height = 900 ÷ 2326.8 = 0.3851.

The image of the object projected by the lens onto the image sensor races out a similar triangle.

The height of this triangle is the focal length of lens = 4.8mm The image height has exactly the same ratio as the i.e. 0.3851

The image height of the projected image = 4.8 X 0.351 = 1.8487mm.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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