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

David E DeMarle dave.demarle at kitware.com
Fri Oct 7 09:05:38 EDT 2016


The data from the slice lives within the server side's context (whether or
not you are actually using paraview in client server mode). Insert a python
programmable filter and use vtk level python coding inside it to get access
to the array.

If you don't ever plan to run in client server mode, other options include
servermanager.Fetch(), and source.SMProxy.GetClientSideObject()


David E DeMarle
Kitware, Inc.
R&D Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909

On Thu, Oct 6, 2016 at 9:33 PM, Magnus Elden <magnus_elden at hotmail.com>
wrote:

> 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
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
>
> Please keep messages on-topic and check the ParaView Wiki at:
> http://paraview.org/Wiki/ParaView
>
> Search the list archives at: http://markmail.org/search/?q=ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/paraview
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20161007/11a9b388/attachment.html>


More information about the ParaView mailing list