# Reprojectimageto3d output

Using reprojectimageto3d function I calculate the actual coordinate points [X, Y, Z], however, according to the documentation, the results obtained are divided by W. Please answer what the variable W is and how can I calculate it?

why would you need to ? look at the formula again,

`[X Y Z W]`

is theresultof`Q * [x y d 1]`

so, you need to obtain x,y,d and Q.

and here comes the more challenging question: how do you get

`Q`

, the projection matrix, (if not from a real world stereo calibration) ?I am using function stereoCalibrate and stereoRectify to get the Q matrix. The result seems to be correct(baseline and focal are OK). To calculate 'd' l am using disparity image. x, y are taken from the mouse position in the disparity image.

I am using this formulas to get real world cordinates:

reprojectedImage = reprojectimageto3d(disp, Q) # disp - disparity map.

realcords = reprojectedImage(x,y) # _3dImage(x,y) = (X/W, Y/W, Z/W) W???.

The question is whether the cordinates returned to realcords variable are real or must be divided by W?