4
$\begingroup$

I am trying to synthetically generate depth image mimicing a real Kinect. So I have set the camera params as below using python script.

enter image description here

I have setup the nodes and able to get the depth image as shown below. Along with render params as shown in the figure. I am able to render the depth image. enter image description here

But when I read the image outside, there is a cutoff after certain depth. This can be seen in the below matlab read of the image. One can see that the top rows in the image are set to constant high values. enter image description here

When I change the viewpoint of the camera to be lower, it seems to gradually improve gradienting. So I believe its having a threshold which says beyond this z value, if there is an object then just assign the highest value or something. I played around with all the camera params and couldn't figure out the issue. Please let me know if you have come across this or know of any parameter that can fix this.

Thanks in advance!

$\endgroup$
1
  • 1
    $\begingroup$ be sure that the limitation in blender : click on the render result image in the UV_Editor and read the values of RGB to be sure, you can normalize the Z depth with Vector_Normalize node and use a HSV color ramp to get the final view inside blender $\endgroup$
    – Chebhou
    Commented Jul 2, 2015 at 4:31

2 Answers 2

6
$\begingroup$

The values of the Z Buffer are in float values, and then they get clipped to <0,1> (<0,255>) range in your file format.

  • Either save the images in some hdr format (.exr for example) that will support float values

  • or re-map the values to the <0,1> range yourself with Map Value node.

$\endgroup$
9
  • $\begingroup$ Can you point me to something where I can know how access the float values from the .exr format? $\endgroup$
    – desinghkar
    Commented Jul 6, 2015 at 20:22
  • $\begingroup$ @desinghkar You can view the exact RGB values under the mouse cursor in UV/ImageEditor when you right-click. $\endgroup$ Commented Jul 7, 2015 at 8:58
  • $\begingroup$ Hey thanks! But the reason I am using the blender is to get render the zbuffer out into a file that I can use for non-visualization purpose. So basically I need the depth values. I am writing them out to .hdr file and getting it now. But I would like to know if I can use python scripting to get to the object that holds these values when I render it out. Because I again have to read the .hdr files into a text file to get hold of these values for my project. $\endgroup$
    – desinghkar
    Commented Jul 9, 2015 at 2:09
  • $\begingroup$ @desinghkar yep you can do this with python. You can render and then access the pixel values and write them into txt or json with single python script. Here is how: blender.stackexchange.com/questions/2170/… $\endgroup$ Commented Jul 9, 2015 at 6:22
  • $\begingroup$ Thanks for the comments. But is there a way to actually access the Z-values directly off the nodes rather than trying to access the pixels. I have that rendered as HDR images on disk. But I don't want to save it on the disk anymore and want to access the values. Can you tell me if there is way to do that. $\endgroup$
    – desinghkar
    Commented Jan 29, 2016 at 17:31
0
$\begingroup$

Go to rendering image (or press F12)

After image renders press Shift+F3 to go to compositor view.

Add Map value node to add vectors. Here offset = -1*near plane clip and Size = 1/(far clip-near clip) Can be found from camera

enter image description here

Inverting makes deep fields of output to be back (1) and higher points to be white (0)

Attach color of invert to file output and give the place to save the file into

Click render active scene (found on Render layer node’s right bottom corner)

Go to your location and a heightmap PNG will be saved. If you aren’t happy with colors you can add a gamma correction node after invert. enter image description here

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .