简体   繁体   中英

Create depth map from 3d points

I have given 3d points of a scene or a subset of these points comprising one object of the scene. I would like to create a depth image from these points, that is the pixel value in the image encodes the distance of the corresponding 3d point to the camera.

I have found the following similar question

http://www.mathworks.in/matlabcentral/newsreader/view_thread/319097

however the answers there do not help me, since I want to use MATLAB. To get the image values is not difficult (eg simply compute the distance of each 3d point to the camera's origin), however I do not know how to figure out the corresponding locations in the 2d image.

I could only imagine that you project all 3d points on a plane and bin their positions on the plane in discrete, well, rectangles on the plane. Then you could average the depth value for each bin. I could however imagine that the result of such a procedure would be a very pixelated image, not being very smooth. How would you go about this problem?

Assuming you've corrected for camera tilt (a simple matrix multiplication if you know the angle), you can probably just follow this example

X = data(:,1);
Y = data(:,1);
Z = data(:,1);

%// This bit requires you to make some choices like the start X and Z, end X and Z and resolution (X and Z) of your desired depth map
[Xi, Zi] = meshgrid(X_start:X_res:X_end, Z_start:Z_res:Z_end);

depth_map = griddata(X,Z,Y,Xi,Zi)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM