[Paraview] How to generate a depth map from a ParaView scene

David E DeMarle dave.demarle at kitware.com
Wed Dec 8 10:25:26 EST 2010


> I think I found an alternative way which seems to work. It uses more
> VTK functionalities (vtkWindowToImageFilter in particular) as follows:
>
>  from libvtkRenderingPython import vtkWindowToImageFilter
>  from libvtkIOPython import vtkTIFFWriter
>
>  view = GetActiveView().GetRenderWindow()
>
>  w2i = vtkWindowToImageFilter()
>  w2i.SetInputBufferTypeToZBuffer ()
>  w2i.SetInput(view)
>  w2i.Update()
>
>  writer = vtkTIFFWriter()
>  writer.SetInputConnection(w2i.GetOutputPort())
>  writer.SetFileName("/scratch/depthmap.tif")
>
>  view.Render()
>  writer.Write()
>
>
This approach looks great to me as it hides much of the tedious bit
fiddling.


> Slight inconveniences are that I actually expected inverse color scheme
> (eg black for far away, white for closeup), but here it is the other
> way round. Also, I cannot write this to a PNG using vtkPNGWriter instead
> of the TIFF writer (error is: PNGWriter only supports unsigned char and
> unsigned short inputs).
> Any suggestions?
>
>
Nothing specific. You could get direct access to the array and do the Z
inversion from python.
Or you could search around for a set of vtk filters that do the flip and
also find a different writer that works directly for your needs. Consider
the nrrd writer, the nrrd library (http://teem.sourceforge.net/nrrd/) can do
array manipulation quite well.


> Thanks again,
>  Marc
>
>
> dave.demarle at kitware.com said:
> >> I'ld try this path:
> >> from the python shell get a hold of the current render view proxy
> >> http://www.paraview.org/ParaQ/Doc/Nightly/html/classvtkSMRenderViewPro
> >> xy.html
>
> >> from that get a hold of the vtkRenderWindow http://www.vtk.org/doc/
> >> nightly/html/classvtkRenderWindow.html
>
> >> on that call GetZBufferData
>
> >> David E DeMarle
>
>
> --
>  Dr. Marc Baaden  - Institut de Biologie Physico-Chimique, Paris
>  mailto:baaden at smplinux.de      -      http://www.baaden.ibpc.fr
>  FAX: +33 15841 5026  -  Tel: +33 15841 5176  ou  +33 609 843217
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20101208/cc8a552c/attachment.htm>


More information about the ParaView mailing list