[Paraview] How to read the RGBA value of a point from a slice given by XYZ coordinates using python?

Magnus Elden magnus_elden at hotmail.com
Thu Oct 6 21:33:31 EDT 2016


Hi,

I have a volume and I Slice this volume. This slice, called slice1 is coloured using a ColorTransferFunction and an OpacityTransferFunction. This works well and when I use Show() and Render() it shows up fine.
Now I want to access these RGBA values so that I can add that colour value to an image I have prepared using the PIL library. The problem is that no matter where I look I am unable to find any access point. No arrays I can access and no functions I can call. The closest thing I have found is this: array = slice1.GetPointData().GetArray("u150-ref0"). This returns an array according, but I am not able to access it.

dir(array) shows that there is no __getItem__ function and I couldn't find any other access method. I went into the source code of the Paraview python modules and I found a function called paraview.numpy_support.vtk_to_numpy(), but this would not work since the objects I tried feeding it did not have __buffer__ at some level.

Please refer to the source file I have attached for the full code. At the very bottom there is a double for loop, within which I want to do the extraction of the coloured pixels.
Here is a link to an image showing a single slice rendered: http://puu.sh/rAijX/ba71c4b7d9.png


Thank you,
Magnus Elden
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20161007/c6671279/attachment.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Paraview.py
URL: <http://public.kitware.com/pipermail/paraview/attachments/20161007/c6671279/attachment.ksh>


More information about the ParaView mailing list