How do I convert pixels to real-world size on a flat plane at a known distance?
Asked 6/22/2023
178 views
2 answers
0
I have a camera viewing a flat plane at a known distance, and I know the camera intrinsics. The image has noticeable lens distortion, so I correct it with OpenCV's undistort function.
How can I estimate the real-world size represented by each pixel on that plane? For example, if a rectangle measures 50 pixels wide in the image, how can I convert that to millimeters?
Also, after undistortion, does every pixel correspond to the same physical area on the plane, or can the pixel-to-mm ratio vary across the image?
Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0
Photography Stack Exchange contributor
3y ago
2 Answers
1
How accurate do you expect/need to be?
IMHO between the inaccuracy of the focal length (especially since you are not focused to infinity) and your lens correction, the GIGO principle says that you aren't going to be very accurate. Better put a ruler/tape measure in the photo and calibrate the thing experimentally. You may find that the pixel/mm ratio isn't completely uniform.
Originally by user75947. Source · Licensed CC BY-SA 4.0
user75947
3y ago
0
Generated from our catalog & community — verify before relying on it.
If the plane is perpendicular to the camera and you know the horizontal field of view, you can estimate scale with simple trigonometry:
mm per pixel ≈ 2 × distance × tan(horizontal FOV / 2) ÷ image width in pixels
Then: real width ≈ pixel count × mm per pixel
This gives a useful approximation, especially when the subject distance is much larger than the focal length. At close focus, effective focal length can shift, so accuracy drops.
Undistortion does not guarantee that every pixel corresponds to exactly the same physical area. Depending on the lens, calibration, and how the undistorted image is remapped or cropped, the pixel/mm ratio may vary somewhat across the frame.
For best accuracy, especially with noticeable distortion, the practical recommendation is to calibrate experimentally: place a ruler or tape measure on the plane at the same distance and measure the pixel-to-mm ratio directly in the corrected image. That will account for focus distance, distortion correction, and any non-uniformity better than relying only on intrinsics.
Recommended products
UniqueBot
AI3y ago
Your Answer
Related Questions
How can I estimate horizontal field of view from one image using vanishing points?
How can I estimate an object's real size from one image if I know the camera-to-subject distance?
How can I estimate the real-world width and height covered by an image?
How does blur circle size change with defocus in macro photography?
How can I estimate an object's real size from pixel size, focal length, and subject distance?