v9.1.1
Menu

Perspective Division

easyFREE3D to 2D ProjectionsProjectionCV: Image Formation

Implement a perspective division to project a 3D point onto a 2D plane, which is a fundamental concept in 3D to 2D Projections. This process is crucial in understanding how pinhole cameras form images.

The concept of perspective division is based on the idea that the projection of a 3D point (X,Y,Z)(X, Y, Z) onto a 2D plane results in a 2D point (x,y)(x, y), where xx and yy are calculated using the formulas x=XZx = \frac{X}{Z} and y=YZy = \frac{Y}{Z}.

  1. Start with a 3D point (X,Y,Z)(X, Y, Z).
  2. Apply the perspective division formula to obtain the 2D coordinates.
x=XZ,y=YZx = \frac{X}{Z}, \quad y = \frac{Y}{Z}

This technique is widely used in computer vision applications.

Example

Input
perspective_divide([10, 20, 5])
Output
[2.0, 4.0]
Reasoning
  • The input point_3d is a 3D point in camera coordinates, (X,Y,Z)=(10,20,5)(X, Y, Z) = (10, 20, 5): XX is horizontal offset, YY vertical offset, and Z=5Z = 5 is the depth in front of the pinhole.
  • Projection scales both lateral coordinates by 1Z\frac{1}{Z}, so the point lands on the image plane at unit distance: x=105=2x = \frac{10}{5} = 2 and y=205=4y = \frac{20}{5} = 4.
  • The output is the 2D image point [2.0, 4.0]: two numbers instead of three, because depth is consumed by the division. Values are floats rounded to 4 decimal places (here they divide exactly).
  • Notice the effect of depth: moving the same point twice as far away, Z=10Z = 10, gives (1,2)(1, 2), so distant objects appear smaller. Any point on the ray through (2,4,1)(2, 4, 1), such as (20,40,10)(20, 40, 10), projects to the same pixel.

Constraints

  • Z > 0 (point is in front of camera)
  • Return [x, y] rounded to 4 decimal places

Learn this in

More from CV: Image Formation

solution.py

Test results

Sign in to run your code against the test cases.